반응형
요새들어 Github을 많이 하고 있네요. Swing이 재미있다는 생각이 들기도 하구요. Github으로 코드를 치다보면, 스프링부트는... 손 코딩을 하는 코드가 아닐 것이다. 이렇게 혼자 생각하게 되기도 하구요~. 중복코드가 너무 많음...
html파일의 링크적을때... 전에 엔티티 참조하려면, 어질어질... 스트레스이죠. 그런 중복코드를 줄이는 작업을 하고 있습니다. 참조해보세요.
infott2t/SpringAutoCodeJPAEntity3: Automation Code CRUD. SpringBoot JPA + QueryDSL (github.com)
GitHub - infott2t/SpringAutoCodeJPAEntity3: Automation Code CRUD. SpringBoot JPA + QueryDSL
Automation Code CRUD. SpringBoot JPA + QueryDSL . Contribute to infott2t/SpringAutoCodeJPAEntity3 development by creating an account on GitHub.
github.com
코드를 더 잘 정리했어요.
package org.example.v5;
import org.example.themes.MyFlatLaf;
import org.example.v4.UtilStaticV4;
import org.example.v4.result.screen.ReadMeScreen;
import org.example.v4.result.screen.firstinstance.controller.root.RootIndexControllerResultScreen;
import org.example.v4.result.screen.firstinstance.controller.root.domain.InstanceUrlControllerResultScreen;
import org.example.v4.result.screen.firstinstance.controller.root.form.ApiDtoFormResultScreen;
import org.example.v4.result.screen.templates.IndexHTMLResultScreen;
import org.example.v4.result.screen.templates.InsertHTMLResultScreen;
import org.example.v4.result.screen.templates.UpdateHTMLResultScreen;
import org.example.v4.result.screen.templates.root.RootIndexResultScreen;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Sys05 extends JFrame{
private JPanel jp;
private JLabel jl,jl2,jl3,jl4,jl5,jl6,jl7,jl8,jl9,
jl10,jl11,jl12,jl13,jl14;
private JTextField jtf, jtf2,jtf3,jtf4,jtf5,jtf6,jtf7,jtf8,jtf9;
private JTextArea jta,jta2,jta3,jta4;
private JScrollPane jsp,jsp2,jsp3,jsp4;
private JButton btn,btn2;
static UtilStaticV5 usv; // Save input values
String columnStrings;
String columnLongs;
String columnDates;
String columnNames;
String domainStr;
String foreignColStr;
String[] colStrs;
String[] colLongs;
String[] colDates;
String[] colNames;
String thymleafInitUrl;
Sys05()throws Exception{
jp= new JPanel();
jl = new JLabel("Entity name(CamelCase):");
jl2 = new JLabel(": ");
jtf = new JTextField(20);
jl3 = new JLabel("Entity Copy paste. ex) Long id; String nameStr; LocalDateTime dateStr; ");
jta = new JTextArea(5,10);
jta2 = new JTextArea(5, 10);
jsp = new JScrollPane(jta);
jsp.setPreferredSize(new Dimension(480,100));
jsp2 = new JScrollPane(jta2);
jsp2.setPreferredSize(new Dimension(480,100));
jtf2 = new JTextField(27);
jl4 = new JLabel("Spring Mapping. foreign key. ex) UserOne userONe; Post post; --> UserOne,Post");
//jtf3 = new JTextField(20);
jl5 = new JLabel("Starting Controller url: ");
jtf4 = new JTextField();
btn2 = new JButton("ReadMe");
btn = new JButton("Extract Redundant logic...");
jp.add(jl);
jp.add(jl2);
jp.add(jtf);
jp.add(jl3);
jp.add(jsp);
jp.add(jl4);
jp.add(jsp2);
jp.add(jl5);
jp.add(jtf2);
jp.add(btn2);
jp.add(btn);
jp.add(jtf4);
setVisible(true);
setResizable(true);
add(jp);
setBounds(300,300,500,500);
setTitle("v5 SpringBoot JPA + QueryDSL. support many redundant files.");
jtf2.setText("/administer/instanceurl");
jtf4.setText("Github, https://github.com/infott2t/SpringAutoCodeJPAEntity3");
jta.setText("Long id;\n\nString isDel;\nLocalDateTime modifiedDate;\nLocalDateTime createdDate;");;
btn2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ReadMeScreen2();
}
});
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
domainStr = jtf.getText();
String line;
BufferedReader reader = new BufferedReader(new StringReader(jta.getText()));
columnStrings="";
columnLongs="";
columnDates="";
columnNames="";
try{
while((line = reader.readLine())!=null){
System.out.println(line);
if(line.indexOf("Long")>=0) {
// System.out.println(line.indexOf("Long") );
String longStr = line.substring(line.indexOf("Long") + 5);
longStr = longStr.replace(";", "");
columnLongs = columnLongs + longStr + ",";
columnNames = columnNames + longStr + ",";
}
if(line.indexOf("String")>=0) {
// System.out.println(line.indexOf("Long") );
String strings = line.substring(line.indexOf("String") + 7);
strings = strings.replace(";", "");
columnStrings = columnStrings + strings + ",";
columnNames = columnNames + strings + ",";
}
if(line.indexOf("LocalDateTime")>=0){
String dates = line.substring(line.indexOf("LocalDateTime") + 14);
dates = dates.replace(";", "");
columnDates = columnDates + dates + ",";
columnNames = columnNames + dates + ",";
}
}
}catch(Exception ex){
ex.printStackTrace();
}
if(columnLongs!=null && columnLongs.length()>0) {
columnLongs = columnLongs.substring(0, columnLongs.length() - 1);
}
if(columnStrings!=null && columnStrings.length()>0) {
columnStrings = columnStrings.substring(0, columnStrings.length() - 1);
}
if(columnDates!=null && columnDates.length()>0) {
columnDates = columnDates.substring(0, columnDates.length() - 1);
}
//columnDates = columnDates.substring(0,columnDates.length()-1);
columnNames = columnNames.substring(0,columnNames.length()-1);
colStrs = columnStrings.split(",");
colLongs = columnLongs.split(",");
colDates = columnDates.split(",");
colNames = columnNames.split(",");
System.out.println(colStrs.toString());
System.out.println(colLongs.toString());
System.out.println(colNames.toString());
for(int i=0; i< colStrs.length ;i++ ){
System.out.println(colStrs[i]);
}
for (int i = 0; i < colNames.length; i++) {
System.out.println(colNames[i]);
}
//thymleafInitUrl = jtf2.getText();
String foreignColStrs[] = null;
try{
if(jta2.getText()!=null && jta2.getText().length()>0) {
foreignColStr = jta2.getText();
foreignColStrs = foreignColStr.split(",");
for(int i=0; i< foreignColStrs.length ;i++ ){
foreignColStrs[i] = foreignColStrs[i].trim();
}
}
}catch(Exception e1){
e1.printStackTrace();
}
thymleafInitUrl = jtf2.getText();
usv = new UtilStaticV5(domainStr, colStrs, colLongs, colDates,colNames, foreignColStrs, thymleafInitUrl);
/**
* Back-end, SpringBoot JPA, QueryDSL
*
* Make Entity, ApiDto, Repository, RepositoryCustom, RepositoryImpl, Service.
* **/
//folder make. c:/category/print-[MMdd-HHmmss]/
LocalDateTime now = LocalDateTime.now();
String dateStr = now.format(DateTimeFormatter.ofPattern("MMdd-HHmmss"));
String folderStr = "c:\\category\\"+"print-"+dateStr;
//Make folder Back-end. c:/category/print-[MMdd-HHmmss]/[domainStr]/
String folderStrBackend = folderStr +"\\"+usv.toAllLowerCase(domainStr)+"\\";
String entityStr = usv.makeEntity();
new ResultScreen("Entity", entityStr, folderStrBackend, domainStr, usv);
String apiDtoStr = usv.makeApiDto();
new ResultScreen("ApiDto", apiDtoStr, folderStrBackend, domainStr, usv);
String repositoryStr = usv.makeRepository();
new ResultScreen("Repository", repositoryStr, folderStrBackend, domainStr, usv);
String repositoryCustomStr = usv.makeRepositoryCustom();
new ResultScreen("RepositoryCustom", repositoryCustomStr, folderStrBackend, domainStr, usv);
String repositoryImplStr = usv.makeRepositoryImpl();
new ResultScreen("RepositoryImpl", repositoryImplStr, folderStrBackend, domainStr, usv);
String serviceStr = usv.makeService();
new ResultScreen("Service", serviceStr, folderStrBackend, domainStr, usv);
//SearchCondition
String searchConditionStr = usv.makeSearchCondition();
new ResultScreen("SearchCondition", searchConditionStr, folderStrBackend, domainStr, usv);
//Make page,
/**
* Front-end, Thyemleaf Files. 4 Files.
*
* Folder
* templates/firstInstance/
* index.html RootIndexResultScreen(usv)
*
* templates/firstInstance/[domainStr]/
* index.html, IndexHTMLResultScreen(usv)
* insert.html, InsertHTMLResultScreen(usv)
* update.html. UpdateHTMLResultScreen(usv)
* */
//Make folder Front-end. c:/category/print-[MMdd-HHmmss]/firstInstance/[domainStr]/
String folderStrFrontend = folderStr +"\\templates\\firstInstance\\";
//String folderStrFrontend = folderStr +"\\templates\\firstInstance\\"+usv.toAllLowerCase(domainStr)+"\\";
String rootIndexStr = usv.makeRootIndex();
new ResultScreen("RootIndex", rootIndexStr, folderStrFrontend, domainStr, usv);
//new RootIndexResultScreen(usv);
String indexStr = usv.makeIndex();
new ResultScreen("Index", indexStr, folderStrFrontend, domainStr, usv);
//new IndexHTMLResultScreen(usv);
//new InsertHTMLResultScreen(usv);
//new UpdateHTMLResultScreen(usv);
/**
* URL Controller and Dto, ApiDtoForm. Files. 3 Files.
*
*
*
* ROOT URL controller.
* src.main.java.org.example.firstinstanceurl.domain
*
* InstanceUrlController.java, RootIndexControllerResultScreen(usv)
* Entity CRUD URL controller.
* src.main.java.org.example.firstinstanceurl.domain.[domainStr]
*
* InstanceUrl[domainStr]Controller.java, InstanceUrlControllerResultScreen(usv)
* Entity Form Dto.
* src.main.java.org.example.firstinstanceurl.form
* [domainStr]ApiDtoForm.java, ApiDtoFormResultScreen(usv)
* **/
//new RootIndexControllerResultScreen(usv);
//new InstanceUrlControllerResultScreen(usv);
//new ApiDtoFormResultScreen(usv);
// usc = new UtilStrConvV4(tableName,valBefore, "sqlUpper");
// new UpperCaseSQLResultScreen(usc);
//usc = new UtilStrConvV4(tableName,valBefore, "Camel");
//new ExtractVResultScreen(usc);
}
});
}
public static void main(String[] args) throws Exception {
MyFlatLaf.setup();
new Sys05();
}
}
공부해봅시다.
좋은 하루되세요.
저의 글, 봐 주셔서 감사합니다.
반응형
'프로그래밍' 카테고리의 다른 글
[일상] 프로그래밍, 재미있죠~. AI 만들기 부분. 개발해보세요~. 코드크레인이라는 회사도 있네요. (0) | 2023.02.04 |
---|---|
[웹프로그래밍] SpringBoot JPA +QueryDSL CRUD 자동화 사용해보자. -1. (0) | 2023.01.22 |
[웹앱 디자인] 스프링부트JPA 9. 개발 방식- 앱화면 기초, 템플릿 만들기. -2 (2) | 2023.01.16 |
[웹 프로그래밍] 스프링부트JPA 8. 테이블을 자동생성해보자~. (0) | 2023.01.14 |
[웹 프로그래밍] 스프링부트JPA 7-2. QueryDSL설명~. 검색기능. (0) | 2023.01.12 |