Skip to content

Commit cef2940

Browse files
committed
소스 1차 릴리즈
1 parent e5f5abe commit cef2940

35 files changed

+1554
-201
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
HELP.md
22
.gradle
3+
.DS_Store
34
build/
45
!gradle/wrapper/gradle-wrapper.jar
56
!**/src/main/**/build/

build.gradle

+19-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'm.cmp'
8-
version = '0.0.1-SNAPSHOT'
8+
version = 'v0.0.1'
99
sourceCompatibility = '11'
1010

1111
repositories {
@@ -16,22 +16,33 @@ dependencies {
1616
implementation 'org.springframework.boot:spring-boot-starter-actuator'
1717
// spring web mvc
1818
implementation 'org.springframework.boot:spring-boot-starter-web'
19-
// Jeager lib
20-
implementation 'io.opentracing.contrib:opentracing-spring-jaeger-web-starter:3.3.1'
21-
implementation 'io.opentracing.contrib:opentracing-spring-cloud-starter:0.5.9'
2219

2320
// spring docs swagger3.0
2421
implementation 'org.springdoc:springdoc-openapi-ui:1.6.14'
2522

23+
// lombok
24+
compileOnly 'org.projectlombok:lombok'
25+
annotationProcessor 'org.projectlombok:lombok'
26+
27+
//Jenkins-Rest ( https://github.com/cdancy/jenkins-rest )
28+
implementation 'io.github.cdancy:jenkins-rest:1.0.1:all'
29+
30+
//http ssl
31+
implementation 'org.apache.httpcomponents:httpclient:4.5.12'
32+
33+
// org.json
34+
implementation 'org.json:json:20220924'
35+
36+
// org.apache.commons
37+
implementation 'org.apache.commons:commons-collections4:4.0'
38+
2639
testImplementation 'org.springframework.boot:spring-boot-starter-test'
2740

2841
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.3.0'
29-
implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:1.16'
30-
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
42+
implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:1.16'
43+
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
3144

3245

33-
implementation 'org.springframework.boot:spring-boot-starter-security'
34-
3546

3647
}
3748

src/main/java/m/cmp/wfManager/_defaultconfig/DatabaseConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* mybatis-config.xml 생성 안함.
2222
*/
2323
@Configuration
24-
@MapperScan(basePackages = "m.cmp.wfManager.repository")
24+
@MapperScan(basePackages = "m.cmp.wfManager.**.mapper")
2525
public class DatabaseConfig {
2626
@Bean(name = "dbDataSource")
2727
@ConfigurationProperties(prefix = "spring.datasource.hikari")

src/main/java/m/cmp/wfManager/_defaultconfig/SecurityConfig.java

-82
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package m.cmp.wfManager.api.response;
2+
3+
import java.util.Map;
4+
import java.util.Optional;
5+
import java.util.stream.Collectors;
6+
import java.util.stream.Stream;
7+
8+
import lombok.Getter;
9+
import m.cmp.wfManager.exception.McmpException;
10+
11+
@Getter
12+
public enum ResponseCode {
13+
14+
OK(200, "정상처리 되었습니다."),
15+
16+
/* common */
17+
BAD_REQUEST(400, "BAD REQUEST"),
18+
UNAUTHORIZED(401, "UNAUTHORIZED"),
19+
FORBIDDEN(403, "FORBIDDEN"),
20+
NOT_FOUND(404, "NOT FOUND"),
21+
METHOD_NOT_ALLOWED(405,"METHOD NOT ALLOWED"),
22+
CLIENT_ERROR(408,"CLIENT_ERROR"),
23+
CONFLICT(409,"CONFLICT"),
24+
INTERNAL_SERVER_ERROR(500,"INTERNAL SERVER ERROR"),
25+
26+
/* 공통 코드 */
27+
COMMON_CODE_EXISTS(9001, "EXISTS COMMON CODE"),
28+
COMMON_CODE_DELETE_NOT_ALLOWED(9002,"DELETE NOT ALLOWED COMMON CODE"),
29+
30+
/* Exception */
31+
UNKNOWN_ERROR(9999, "Unknown error"),
32+
33+
/* GitLab-Project */
34+
ALREADY_EXISTS(1001, "ALREADY EXISTS"),
35+
CREATE_FAILED_PROJECT_SOURCE(1003, "CREATE FAILED PROJECT SOURCE"),
36+
37+
/* Jenkins */
38+
CREATE_FAILED_JENKINS_JOB(1103, "CREATE FAILED JENKINS JOB"),
39+
EXISTS_JENKINS_JOB(1104, "EXISTS JENKINS JOB"),
40+
NOT_EXISTS_JENKINS_JOB(1105, "NOT EXISTS JENKINS JOB"),
41+
ERROR_JENKINS_API(1106, "ERROR JENKINS API"),
42+
43+
/* Workload Deploy */
44+
RUN_FAILED_DEPLOY(1201, "RUN FAILED DEPLOY"),
45+
46+
/* OSS */
47+
IN_USE_OSS(1501, "OSS IN USE CANNOT BE DELETED"),
48+
IS_NOT_MAPPED_OSS(1502, "IS NOT MAPPED OSS TO SERVICE GROUP.");
49+
50+
private final int code;
51+
private final String message;
52+
53+
ResponseCode(int code, String message) {
54+
this.code = code;
55+
this.message = message;
56+
}
57+
58+
private static final Map<Integer, ResponseCode> map =
59+
Stream.of(values()).collect(Collectors.toMap(ResponseCode::getCode, e -> e));
60+
61+
public static ResponseCode findByCode(int code) {
62+
return Optional.ofNullable(map.get(code)).orElseThrow(() -> new McmpException(ResponseCode.UNKNOWN_ERROR));
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package m.cmp.wfManager.api.response;
2+
3+
import java.io.Serializable;
4+
5+
import lombok.Getter;
6+
7+
@Getter
8+
public class ResponseWrapper<T> implements Serializable {
9+
10+
private static final long serialVersionUID = -1745006582949878939L;
11+
12+
private int code;
13+
private String message;
14+
private String detail;
15+
private T data;
16+
17+
public ResponseWrapper() {
18+
this(ResponseCode.OK);
19+
}
20+
21+
public ResponseWrapper(ResponseCode status){
22+
this.code = status.getCode();
23+
this.message = status.getMessage();
24+
}
25+
26+
public ResponseWrapper(T data) {
27+
this();
28+
this.data = data;
29+
}
30+
31+
public ResponseWrapper(ResponseCode status, String detail){
32+
this(status);
33+
this.detail = detail;
34+
}
35+
36+
public ResponseWrapper(int code, String message, String detail){
37+
this.code = code;
38+
this.message = message;
39+
this.detail = detail;
40+
}
41+
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package m.cmp.wfManager.common.controller;
2+
3+
import java.util.List;
4+
import java.util.regex.Pattern;
5+
6+
import org.apache.commons.lang3.StringUtils;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.web.bind.annotation.DeleteMapping;
9+
import org.springframework.web.bind.annotation.GetMapping;
10+
import org.springframework.web.bind.annotation.PathVariable;
11+
import org.springframework.web.bind.annotation.PostMapping;
12+
import org.springframework.web.bind.annotation.RequestBody;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RestController;
15+
16+
import io.swagger.v3.oas.annotations.Operation;
17+
import io.swagger.v3.oas.annotations.tags.Tag;
18+
import m.cmp.wfManager.api.response.ResponseCode;
19+
import m.cmp.wfManager.api.response.ResponseWrapper;
20+
import m.cmp.wfManager.common.model.CommonCode;
21+
import m.cmp.wfManager.common.service.CommonService;
22+
23+
24+
@Tag(name = "공통코드", description = "공통코드 조회")
25+
@RestController
26+
@RequestMapping("/common")
27+
public class CommonController {
28+
29+
@Autowired
30+
private CommonService commonService;
31+
32+
@Operation(summary = "공통코드 목록 조회", description = "")
33+
@GetMapping("/group/{commonGroupCd}")
34+
public ResponseWrapper<List<CommonCode>> getCommonCodeList(@PathVariable String commonGroupCd) {
35+
List<CommonCode> data = commonService.getCommonCodeList(commonGroupCd);
36+
return new ResponseWrapper<>(data);
37+
}
38+
39+
@Operation(summary = "공통코드 추가", description = "")
40+
@PostMapping("/group/{commonGroupCd}/code")
41+
public ResponseWrapper<String> createCommonCode(@PathVariable String commonGroupCd, @RequestBody CommonCode code) {
42+
if ( StringUtils.isBlank(commonGroupCd) ) {
43+
return new ResponseWrapper<>(ResponseCode.BAD_REQUEST, "commonGroupCd");
44+
}
45+
46+
if ( StringUtils.isBlank(code.getCodeName()) ) {
47+
return new ResponseWrapper<>(ResponseCode.BAD_REQUEST, "codeName");
48+
}
49+
else {
50+
if ( !Pattern.matches("[a-zA-Z0-9\' \']*", code.getCodeName()) ) {
51+
return new ResponseWrapper<>(ResponseCode.BAD_REQUEST, "codeName은 영문/숫자/공백만 가능합니다.");
52+
}
53+
}
54+
55+
if ( StringUtils.isBlank(code.getCommonGroupCd()) ) {
56+
code.setCommonGroupCd(commonGroupCd);
57+
}
58+
59+
code.setRegId("admin");
60+
code.setRegName("admin");
61+
62+
return new ResponseWrapper<>(commonService.createCommonCode(code));
63+
}
64+
65+
@Operation(summary = "공통코드 삭제", description = "")
66+
@DeleteMapping("/group/{commonGroupCd}/code/{commonCd}")
67+
public ResponseWrapper<Integer> deleteCommonCode(@PathVariable String commonGroupCd, @PathVariable String commonCd) {
68+
if ( StringUtils.isBlank(commonGroupCd) ) {
69+
return new ResponseWrapper<>(ResponseCode.BAD_REQUEST, "commonGroupCd");
70+
}
71+
72+
if ( StringUtils.isBlank(commonCd) ) {
73+
return new ResponseWrapper<>(ResponseCode.BAD_REQUEST, "commonCd");
74+
}
75+
76+
return new ResponseWrapper<>(commonService.deleteCommonCode(commonGroupCd, commonCd));
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package m.cmp.wfManager.common.mapper;
2+
3+
import java.util.List;
4+
5+
import org.apache.ibatis.annotations.Mapper;
6+
import org.apache.ibatis.annotations.Param;
7+
8+
import m.cmp.wfManager.common.model.CommonCode;
9+
10+
11+
@Mapper
12+
public interface CommonMapper {
13+
14+
// 공통 코드 목록
15+
List<CommonCode> selectCommonCodeList(String commonGroupCd);
16+
17+
// 공통 코드 상세 정보
18+
CommonCode selectCommonCode(@Param("commonGroupCd") String commonGroupCd, @Param("commonCd") String commonCd);
19+
20+
// 공통 코드 등록
21+
int insertCommonCode(CommonCode code);
22+
23+
// 공통 코드 삭제
24+
int deleteCommonCode(@Param("commonGroupCd") String commonGroupCd, @Param("commonCd") String commonCd);
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package m.cmp.wfManager.common.model;
2+
3+
import io.swagger.v3.oas.annotations.tags.Tag;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
7+
@Getter
8+
@Setter
9+
@Tag(name = "Common", description = "Common")
10+
public class CommonCode {
11+
12+
private String commonGroupCd;
13+
private String commonCd;
14+
private String codeName;
15+
private String codeDesc;
16+
private int codeOrder;
17+
18+
private String protectedYn; // 삭제 가능 여부 ('Y' - 삭제 불가 / 'N' - 삭제 가능)
19+
20+
private String regId;
21+
private String regName;
22+
private String regDate;
23+
private String modId;
24+
private String modName;
25+
private String modDate;
26+
}

0 commit comments

Comments
 (0)