
+++ .gitignore
... | ... | @@ -0,0 +1,32 @@ |
1 | +HELP.md | |
2 | +target/ | |
3 | +### STS ### | |
4 | +.apt_generated | |
5 | +.classpath | |
6 | +.factorypath | |
7 | +.project | |
8 | +.settings | |
9 | +.springBeans | |
10 | +.sts4-cache | |
11 | +bin/ | |
12 | +!**/src/main/**/bin/ | |
13 | +!**/src/test/**/bin/ | |
14 | + | |
15 | +### IntelliJ IDEA ### | |
16 | +.idea | |
17 | +*.iws | |
18 | +*.iml | |
19 | +*.ipr | |
20 | +out/ | |
21 | +!**/src/main/**/out/ | |
22 | +!**/src/test/**/out/ | |
23 | + | |
24 | +### NetBeans ### | |
25 | +/nbproject/private/ | |
26 | +/nbbuild/ | |
27 | +/dist/ | |
28 | +/nbdist/ | |
29 | +/.nb-gradle/ | |
30 | + | |
31 | +### VS Code ### | |
32 | +.vscode/(파일 끝에 줄바꿈 문자 없음) |
+++ pom.xml
... | ... | @@ -0,0 +1,224 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
4 | + <modelVersion>4.0.0</modelVersion> | |
5 | + <groupId>com.takensoft</groupId> | |
6 | + <artifactId>cms</artifactId> | |
7 | + <packaging>jar</packaging> | |
8 | + <version>1.0.0</version> | |
9 | + <name>cms</name> | |
10 | + <url>http://www.egovframe.go.kr</url> | |
11 | + | |
12 | + <licenses> | |
13 | + <license> | |
14 | + <name>The Apache Software License, Version 2.0</name> | |
15 | + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | |
16 | + </license> | |
17 | + </licenses> | |
18 | + | |
19 | + <parent> | |
20 | + <groupId>org.springframework.boot</groupId> | |
21 | + <artifactId>spring-boot-starter-parent</artifactId> | |
22 | + <version>2.7.12</version> | |
23 | + </parent> | |
24 | + | |
25 | + <properties> | |
26 | + <spring.maven.artifact.version>5.3.27</spring.maven.artifact.version> | |
27 | + <org.egovframe.rte.version>4.2.0</org.egovframe.rte.version> | |
28 | + </properties> | |
29 | + | |
30 | + <repositories> | |
31 | + <repository> | |
32 | + <id>mvn2s</id> | |
33 | + <url>https://repo1.maven.org/maven2/</url> | |
34 | + <releases> | |
35 | + <enabled>true</enabled> | |
36 | + </releases> | |
37 | + <snapshots> | |
38 | + <enabled>true</enabled> | |
39 | + </snapshots> | |
40 | + </repository> | |
41 | + <repository> | |
42 | + <id>egovframe</id> | |
43 | + <url>https://maven.egovframe.go.kr/maven/</url> | |
44 | + <releases> | |
45 | + <enabled>true</enabled> | |
46 | + </releases> | |
47 | + <snapshots> | |
48 | + <enabled>false</enabled> | |
49 | + </snapshots> | |
50 | + </repository> | |
51 | + </repositories> | |
52 | + | |
53 | + <dependencies> | |
54 | + <dependency> | |
55 | + <groupId>org.springframework.boot</groupId> | |
56 | + <artifactId>spring-boot-starter-web</artifactId> | |
57 | + <exclusions> | |
58 | + <exclusion> | |
59 | + <groupId>org.springframework.boot</groupId> | |
60 | + <artifactId>spring-boot-starter-logging</artifactId> | |
61 | + </exclusion> | |
62 | + </exclusions> | |
63 | + </dependency> | |
64 | + <dependency> | |
65 | + <groupId>org.springframework.boot</groupId> | |
66 | + <artifactId>spring-boot-starter-thymeleaf</artifactId> | |
67 | + </dependency> | |
68 | + <dependency> | |
69 | + <groupId>org.springframework.boot</groupId> | |
70 | + <artifactId>spring-boot-starter-validation</artifactId> | |
71 | + </dependency> | |
72 | + <dependency> | |
73 | + <groupId>org.springframework.boot</groupId> | |
74 | + <artifactId>spring-boot-devtools</artifactId> | |
75 | + <optional>true</optional> | |
76 | + </dependency> | |
77 | + | |
78 | + <!-- 표준프레임워크 실행환경 --> | |
79 | + <dependency> | |
80 | + <groupId>org.egovframe.rte</groupId> | |
81 | + <artifactId>org.egovframe.rte.ptl.mvc</artifactId> | |
82 | + <version>${org.egovframe.rte.version}</version> | |
83 | + </dependency> | |
84 | + <dependency> | |
85 | + <groupId>org.egovframe.rte</groupId> | |
86 | + <artifactId>org.egovframe.rte.psl.dataaccess</artifactId> | |
87 | + <version>${org.egovframe.rte.version}</version> | |
88 | + </dependency> | |
89 | + <dependency> | |
90 | + <groupId>org.egovframe.rte</groupId> | |
91 | + <artifactId>org.egovframe.rte.fdl.idgnr</artifactId> | |
92 | + <version>${org.egovframe.rte.version}</version> | |
93 | + </dependency> | |
94 | + <dependency> | |
95 | + <groupId>org.egovframe.rte</groupId> | |
96 | + <artifactId>org.egovframe.rte.fdl.property</artifactId> | |
97 | + <version>${org.egovframe.rte.version}</version> | |
98 | + </dependency> | |
99 | + | |
100 | + <dependency> | |
101 | + <groupId>org.hsqldb</groupId> | |
102 | + <artifactId>hsqldb</artifactId> | |
103 | + <version>2.7.2</version> | |
104 | + <classifier>jdk8</classifier> | |
105 | + </dependency> | |
106 | + <dependency> | |
107 | + <groupId>org.projectlombok</groupId> | |
108 | + <artifactId>lombok</artifactId> | |
109 | + <version>1.18.28</version> | |
110 | + <optional>true</optional> | |
111 | + </dependency> | |
112 | + <dependency> | |
113 | + <groupId>org.hibernate</groupId> | |
114 | + <artifactId>hibernate-entitymanager</artifactId> | |
115 | + <version>5.6.15.Final</version> | |
116 | + </dependency> | |
117 | + <dependency> | |
118 | + <groupId>org.springframework.boot</groupId> | |
119 | + <artifactId>spring-boot-starter-test</artifactId> | |
120 | + <scope>test</scope> | |
121 | + </dependency> | |
122 | + | |
123 | + <!-- 추가 --> | |
124 | + <dependency> | |
125 | + <groupId>org.mybatis.spring.boot</groupId> | |
126 | + <artifactId>mybatis-spring-boot-starter</artifactId> | |
127 | + <version>2.2.2</version> | |
128 | + </dependency> | |
129 | + <dependency> | |
130 | + <groupId>org.springframework.boot</groupId> | |
131 | + <artifactId>spring-boot-starter-security</artifactId> | |
132 | + <version>3.2.4</version> | |
133 | + </dependency> | |
134 | + <dependency> | |
135 | + <groupId>org.springframework.boot</groupId> | |
136 | + <artifactId>spring-boot-starter-cache</artifactId> | |
137 | + </dependency> | |
138 | + <dependency> | |
139 | + <groupId>com.github.ben-manes.caffeine</groupId> | |
140 | + <artifactId>caffeine</artifactId> | |
141 | + </dependency> | |
142 | + <dependency> | |
143 | + <groupId>mysql</groupId> | |
144 | + <artifactId>mysql-connector-java</artifactId> | |
145 | + <version>8.0.23</version> | |
146 | + </dependency> | |
147 | + <dependency> | |
148 | + <groupId>org.mariadb.jdbc</groupId> | |
149 | + <artifactId>mariadb-java-client</artifactId> | |
150 | + <version>2.6.2</version> | |
151 | + </dependency> | |
152 | + | |
153 | + <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> | |
154 | + <dependency> | |
155 | + <groupId>org.postgresql</groupId> | |
156 | + <artifactId>postgresql</artifactId> | |
157 | + <version>42.6.0</version> | |
158 | + </dependency> | |
159 | + | |
160 | + <dependency> | |
161 | + <groupId>org.bgee.log4jdbc-log4j2</groupId> | |
162 | + <artifactId>log4jdbc-log4j2-jdbc4</artifactId> | |
163 | + <version>1.16</version> | |
164 | + </dependency> | |
165 | + <dependency> | |
166 | + <groupId>org.apache.poi</groupId> | |
167 | + <artifactId>poi-ooxml</artifactId> | |
168 | + <version>4.1.2</version> | |
169 | + </dependency> | |
170 | + <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-api --> | |
171 | + <dependency> | |
172 | + <groupId>io.jsonwebtoken</groupId> | |
173 | + <artifactId>jjwt-api</artifactId> | |
174 | + <version>0.12.5</version> | |
175 | + </dependency> | |
176 | + <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-impl --> | |
177 | + <dependency> | |
178 | + <groupId>io.jsonwebtoken</groupId> | |
179 | + <artifactId>jjwt-impl</artifactId> | |
180 | + <version>0.12.5</version> | |
181 | + <scope>runtime</scope> | |
182 | + </dependency> | |
183 | + <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-jackson --> | |
184 | + <dependency> | |
185 | + <groupId>io.jsonwebtoken</groupId> | |
186 | + <artifactId>jjwt-jackson</artifactId> | |
187 | + <version>0.12.5</version> | |
188 | + <scope>runtime</scope> | |
189 | + </dependency> | |
190 | + | |
191 | + <!-- 추가 --> | |
192 | + <!-- HTML 엔티티를 처리 관련 https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> | |
193 | + <dependency> | |
194 | + <groupId>org.apache.commons</groupId> | |
195 | + <artifactId>commons-lang3</artifactId> | |
196 | + <version>3.14.0</version> | |
197 | + </dependency> | |
198 | + | |
199 | + <!-- oracle 추가 --> | |
200 | + <dependency> | |
201 | + <groupId>com.oracle.database.jdbc</groupId> | |
202 | + <artifactId>ojdbc10</artifactId> | |
203 | + <version>19.16.0.0</version> | |
204 | + </dependency> | |
205 | + </dependencies> | |
206 | + | |
207 | + <build> | |
208 | + <plugins> | |
209 | + <plugin> | |
210 | + <groupId>org.springframework.boot</groupId> | |
211 | + <artifactId>spring-boot-maven-plugin</artifactId> | |
212 | + <configuration> | |
213 | + <excludes> | |
214 | + <exclude> | |
215 | + <groupId>org.projectlombok</groupId> | |
216 | + <artifactId>lombok</artifactId> | |
217 | + </exclude> | |
218 | + </excludes> | |
219 | + </configuration> | |
220 | + </plugin> | |
221 | + </plugins> | |
222 | + </build> | |
223 | + | |
224 | +</project> |
+++ src/main/java/com/takensoft/CmsApplication.java
... | ... | @@ -0,0 +1,16 @@ |
1 | +package com.takensoft; | |
2 | + | |
3 | +import org.mybatis.spring.annotation.MapperScan; | |
4 | +import org.springframework.boot.SpringApplication; | |
5 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
6 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
7 | + | |
8 | +@SpringBootApplication | |
9 | +//@MapperScan(basePackages="com.takensoft.*.*.dao, com.takensoft.*.*.*.dao") | |
10 | +@EnableScheduling | |
11 | +public class CmsApplication { | |
12 | + | |
13 | + public static void main(String[] args) { | |
14 | + SpringApplication.run(CmsApplication.class, args); | |
15 | + } | |
16 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/accesCtrl/dao/AccesCtrlDAO.java
... | ... | @@ -0,0 +1,60 @@ |
1 | +package com.takensoft.cms.accesCtrl.dao; | |
2 | + | |
3 | +import com.takensoft.cms.accesCtrl.vo.AccesCtrlVO; | |
4 | +import com.takensoft.common.Pagination; | |
5 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : takensoft | |
11 | + * @since : 2024.04.01 | |
12 | + * | |
13 | + * 접근 제어 관련 Mapper | |
14 | + */ | |
15 | +@Mapper("accesCtrlDAO") | |
16 | +public interface AccesCtrlDAO { | |
17 | + | |
18 | + /** | |
19 | + * @author takensoft | |
20 | + * @since 2024.04.09 | |
21 | + * 접근 제어 등록 | |
22 | + */ | |
23 | + int save(AccesCtrlVO accesCtrlVO); | |
24 | + | |
25 | + /** | |
26 | + * @author takensoft | |
27 | + * @since 2024.04.15 | |
28 | + * 접근 제어 수정 | |
29 | + */ | |
30 | + int update(AccesCtrlVO accesCtrlVO); | |
31 | + | |
32 | + /** | |
33 | + * @author takensoft | |
34 | + * @since 2024.04.12 | |
35 | + * 접근 제어 조회(관리자 페이지용) | |
36 | + */ | |
37 | + List<AccesCtrlVO> findAll(Pagination pagination); | |
38 | + | |
39 | + /** | |
40 | + * @author takensoft | |
41 | + * @since 2024.04.12 | |
42 | + * 접근제어 목록 갯수(관리자 페이지용) | |
43 | + */ | |
44 | + int findAllCnt(Pagination pagination); | |
45 | + | |
46 | + /** | |
47 | + * @author takensoft | |
48 | + * @since 2024.04.12 | |
49 | + * 접근 제어 조회(관시스템용 - 시큐리티 접근 제어) | |
50 | + */ | |
51 | + List<AccesCtrlVO> findAllAccesCtrlSecurity(String ip); | |
52 | + | |
53 | + /** | |
54 | + * @author takensoft | |
55 | + * @since 2024.04.12 | |
56 | + * 접근 제어 상세 조회 | |
57 | + */ | |
58 | + AccesCtrlVO findByAccesCtrl(int acsCntrlId); | |
59 | + | |
60 | +} |
+++ src/main/java/com/takensoft/cms/accesCtrl/service/AccesCtrlService.java
... | ... | @@ -0,0 +1,52 @@ |
1 | +package com.takensoft.cms.accesCtrl.service; | |
2 | + | |
3 | +import com.takensoft.cms.accesCtrl.vo.AccesCtrlVO; | |
4 | + | |
5 | +import javax.servlet.http.HttpServletRequest; | |
6 | +import java.util.HashMap; | |
7 | +import java.util.List; | |
8 | +import java.util.Map; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.04.01 | |
13 | + * | |
14 | + * 접근 제어 정보 관련 인터페이스 | |
15 | + */ | |
16 | +public interface AccesCtrlService { | |
17 | + | |
18 | + /** | |
19 | + * @author takensoft | |
20 | + * @since 2024.04.09 | |
21 | + * 접근 제어 등록 | |
22 | + */ | |
23 | + public Map<String, Object> accesCtrlSave(AccesCtrlVO accesCtrlVO) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author takensoft | |
27 | + * @since 2024.04.15 | |
28 | + * 접근 제어 수정 | |
29 | + */ | |
30 | + public int accesCtrlUpdate(AccesCtrlVO accesCtrlVO) throws Exception; | |
31 | + | |
32 | + /** | |
33 | + * @author takensoft | |
34 | + * @since 2024.04.12 | |
35 | + * 접근 제어 조회(관리자 페이지용) | |
36 | + */ | |
37 | + public Map<String, Object> findAll(Map<String, String> params) throws Exception; | |
38 | + | |
39 | + /** | |
40 | + * @author takensoft | |
41 | + * @since 2024.04.09 | |
42 | + * 접근 제어 조회(관시스템용 - 시큐리티 접근 제어) | |
43 | + */ | |
44 | + public List<AccesCtrlVO> findAllAccesCtrlSecurity(String ip) throws Exception; | |
45 | + | |
46 | + /** | |
47 | + * @author takensoft | |
48 | + * @since 2024.04.09 | |
49 | + * 접근 제어 상세 조회 | |
50 | + */ | |
51 | + public Map<String, Object> findByAccesCtrl(int acsCntrlId) throws Exception; | |
52 | +} |
+++ src/main/java/com/takensoft/cms/accesCtrl/service/Impl/AccesCtrlServiceImpl.java
... | ... | @@ -0,0 +1,122 @@ |
1 | +package com.takensoft.cms.accesCtrl.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.accesCtrl.dao.AccesCtrlDAO; | |
4 | +import com.takensoft.cms.accesCtrl.service.AccesCtrlService; | |
5 | +import com.takensoft.cms.accesCtrl.vo.AccesCtrlVO; | |
6 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
7 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
8 | +import com.takensoft.common.Pagination; | |
9 | +import com.takensoft.common.util.JWTUtil; | |
10 | +import lombok.RequiredArgsConstructor; | |
11 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
12 | +import org.slf4j.Logger; | |
13 | +import org.slf4j.LoggerFactory; | |
14 | +import org.springframework.cache.annotation.CacheEvict; | |
15 | +import org.springframework.cache.annotation.Cacheable; | |
16 | +import org.springframework.stereotype.Service; | |
17 | + | |
18 | +import java.util.HashMap; | |
19 | +import java.util.List; | |
20 | +import java.util.Map; | |
21 | + | |
22 | +/** | |
23 | + * @author : takensoft | |
24 | + * @since : 2024.04.01 | |
25 | + * | |
26 | + * 접근 제어 관련 구현체 | |
27 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
28 | + * AccesCtrlService : 접근 제어 관련 인터페이스 상속 | |
29 | + */ | |
30 | +@Service("accesCtrlService") | |
31 | +@RequiredArgsConstructor | |
32 | +public class AccesCtrlServiceImpl extends EgovAbstractServiceImpl implements AccesCtrlService { | |
33 | + | |
34 | + private static final Logger LOGGER = LoggerFactory.getLogger(AccesCtrlServiceImpl.class); | |
35 | + private final JWTUtil jwtUtil; | |
36 | + private final AccesCtrlDAO accesCtrlDAO; | |
37 | + private final CodeManageService codeManageService; | |
38 | + | |
39 | + | |
40 | + /** | |
41 | + * @author takensoft | |
42 | + * @since 2024.04.09 | |
43 | + * 접근 제어 등록 | |
44 | + */ | |
45 | + @Override | |
46 | + @CacheEvict(value = "routerAccesCheck", allEntries = true) | |
47 | + public Map<String, Object> accesCtrlSave(AccesCtrlVO accesCtrlVO) throws Exception { | |
48 | + // 등록된 토큰에서 사용자 정보 조회 | |
49 | + accesCtrlVO.setRgtr(jwtUtil.getWriter()); | |
50 | + int saveResult = accesCtrlDAO.save(accesCtrlVO); | |
51 | + Map<String, Object> result = new HashMap<String, Object>(); | |
52 | + result.put("result", saveResult); | |
53 | + result.put("acsCntrlId", accesCtrlVO.getAcsCntrlId()); | |
54 | + return result; | |
55 | + } | |
56 | + | |
57 | + /** | |
58 | + * @author takensoft | |
59 | + * @since 2024.04.15 | |
60 | + * 접근 제어 수정 | |
61 | + */ | |
62 | + @Override | |
63 | + @CacheEvict(value = "routerAccesCheck", allEntries = true) | |
64 | + public int accesCtrlUpdate(AccesCtrlVO accesCtrlVO) throws Exception { | |
65 | + // 등록된 토큰에서 사용자 정보 조회 | |
66 | + accesCtrlVO.setMdfr(jwtUtil.getWriter()); | |
67 | + return accesCtrlDAO.update(accesCtrlVO); | |
68 | + } | |
69 | + | |
70 | + /** | |
71 | + * @author takensoft | |
72 | + * @since 2024.04.12 | |
73 | + * 접근 제어 조회(관리자 페이지용) | |
74 | + */ | |
75 | + @Override | |
76 | + public Map<String, Object> findAll(Map<String, String> params) throws Exception { | |
77 | + Map<String, Object> result = new HashMap<String, Object>(); // 반환 객체 생성 | |
78 | + Pagination search = new Pagination(0, params); // 검색조건 객체 생성 | |
79 | + int cnt = accesCtrlDAO.findAllCnt(search); // 게시물 갯수 | |
80 | + Pagination pagination = new Pagination(cnt, params); // 게시물 갯수 조회 후 검색조건 객쳄 초기화 | |
81 | + List<AccesCtrlVO> list = accesCtrlDAO.findAll(pagination); // 목록 조회 | |
82 | + List<CodeManageVO> codeList = codeManageService.findByChildCdCache("acsCntrlGroup"); // 검색 조건 | |
83 | + | |
84 | + result.put("list", list); | |
85 | + result.put("pagination", pagination); | |
86 | + result.put("codeList", codeList); | |
87 | + return result; | |
88 | + } | |
89 | + | |
90 | + /** | |
91 | + * @author takensoft | |
92 | + * @since 2024.04.09 | |
93 | + * 접근 제어 조회(관시스템용 - 시큐리티 접근 제어) | |
94 | + */ | |
95 | + @Override | |
96 | + @Cacheable(value = "routerAccesCheck", key = "#ip") | |
97 | + public List<AccesCtrlVO> findAllAccesCtrlSecurity(String ip) throws Exception { | |
98 | + return accesCtrlDAO.findAllAccesCtrlSecurity(ip); | |
99 | + } | |
100 | + | |
101 | + /** | |
102 | + * @author takensoft | |
103 | + * @since 2024.04.09 | |
104 | + * 접근 제어 상세 조회 | |
105 | + */ | |
106 | + @Override | |
107 | + public Map<String, Object> findByAccesCtrl(int acsCntrlId) throws Exception { | |
108 | + Map<String, Object> result = new HashMap<String, Object>(); // 반환 객체 생성 | |
109 | + AccesCtrlVO accesCtrl = new AccesCtrlVO(); | |
110 | + if(acsCntrlId != 0) { | |
111 | + accesCtrl = accesCtrlDAO.findByAccesCtrl(acsCntrlId); | |
112 | + } | |
113 | + List<CodeManageVO> codeList = codeManageService.findByChildCdCache("accesGroup"); // 수정 및 등록에 필요한 접근제어 종류 조회 | |
114 | + | |
115 | + result.put("accesCtrl", accesCtrl); | |
116 | + result.put("codeList", codeList); | |
117 | + | |
118 | + return result; | |
119 | + } | |
120 | + | |
121 | + | |
122 | +} |
+++ src/main/java/com/takensoft/cms/accesCtrl/service/Impl/SystemAccesCtrlServiceImpl.java
... | ... | @@ -0,0 +1,88 @@ |
1 | +package com.takensoft.cms.accesCtrl.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.accesCtrl.service.AccesCtrlService; | |
4 | +import com.takensoft.cms.accesCtrl.service.SystemAccesCtrlService; | |
5 | +import com.takensoft.cms.accesCtrl.vo.AccesCtrlVO; | |
6 | +import com.takensoft.common.util.CommonUtils; | |
7 | +import lombok.RequiredArgsConstructor; | |
8 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
9 | +import org.springframework.stereotype.Service; | |
10 | +import org.springframework.util.AntPathMatcher; | |
11 | + | |
12 | +import javax.servlet.http.HttpServletRequest; | |
13 | +import java.util.List; | |
14 | +import java.util.Map; | |
15 | + | |
16 | +/** | |
17 | + * @author : takensoft | |
18 | + * @since : 2024.05.20 | |
19 | + * | |
20 | + * 시스템 접근 제어 관련 구현체 | |
21 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
22 | + * AuthorService : 시스템 접근 제어 관련 인터페이스 상속 | |
23 | + */ | |
24 | +@Service("systemAccesCtrlService") | |
25 | +@RequiredArgsConstructor | |
26 | +public class SystemAccesCtrlServiceImpl extends EgovAbstractServiceImpl implements SystemAccesCtrlService { | |
27 | + | |
28 | + private final CommonUtils commonUtils; | |
29 | + private final AccesCtrlService accesCtrlService; | |
30 | + | |
31 | + /** | |
32 | + * @author takensoft | |
33 | + * @since 2024.04.09 | |
34 | + * 접근 제어 조회(시스템용 - 라우터) | |
35 | + */ | |
36 | + @Override | |
37 | + public boolean routerAccesCheck(Map params, HttpServletRequest req) throws Exception { | |
38 | + String ipAdrs = commonUtils.getIp(req); // 아이피 정보 | |
39 | + String path = params.get("path").toString(); // 접근 경로 | |
40 | + // 공통 접근 경로인 경우 | |
41 | + if(isPath(path, "/cmmn/**")) { | |
42 | + return true; | |
43 | + } | |
44 | + | |
45 | + List<AccesCtrlVO> list = accesCtrlService.findAllAccesCtrlSecurity(ipAdrs); // 접근 제어 정보 조회 | |
46 | + | |
47 | + // 관리자 경로 접근 검증 | |
48 | + if(isPath(path, "/adm/**")) { | |
49 | + // 관리자 페이지로 접속하였으나 접근 제어 정보가 없을 경우 | |
50 | + if(list.isEmpty()) { | |
51 | + return false; | |
52 | + } | |
53 | + } | |
54 | + return matches(list, path); | |
55 | + } | |
56 | + | |
57 | + /** | |
58 | + * @author takensoft | |
59 | + * @since 2024.05.29 | |
60 | + * @param accesCtrlList : 해당 아이피의 접근 제어 정보 | |
61 | + * @param path : 현재 접근 경로 | |
62 | + * 접근 여부 확인 | |
63 | + */ | |
64 | + private boolean matches(List<AccesCtrlVO> accesCtrlList, String path) throws Exception { | |
65 | + AntPathMatcher matcher = new AntPathMatcher(); | |
66 | + for(AccesCtrlVO vo : accesCtrlList) { | |
67 | + if(matcher.match(vo.getCntrlCrs(), path)) { | |
68 | + return "permit".equals(vo.getCntrlType()); // 접근 허용일 경우 true, 그 외 false | |
69 | + } | |
70 | + } | |
71 | + if(matcher.match("/adm/**", path)) { | |
72 | + return false; | |
73 | + } | |
74 | + return true; | |
75 | + } | |
76 | + | |
77 | + /** | |
78 | + * @author takensoft | |
79 | + * @since 2024.05.29 | |
80 | + * @param path : 현재 접근 경로 | |
81 | + * @param url : 확인 경로 | |
82 | + * 경로 확인 | |
83 | + */ | |
84 | + private boolean isPath(String path, String url) { | |
85 | + AntPathMatcher matcher = new AntPathMatcher(); | |
86 | + return matcher.match(url, path); | |
87 | + } | |
88 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/accesCtrl/service/SystemAccesCtrlService.java
... | ... | @@ -0,0 +1,20 @@ |
1 | +package com.takensoft.cms.accesCtrl.service; | |
2 | + | |
3 | +import javax.servlet.http.HttpServletRequest; | |
4 | +import java.util.Map; | |
5 | + | |
6 | +/** | |
7 | + * @author : takensoft | |
8 | + * @since : 2024.04.01 | |
9 | + * | |
10 | + * 시스템 접근 제어 정보 관련 인터페이스 | |
11 | + */ | |
12 | +public interface SystemAccesCtrlService { | |
13 | + | |
14 | + /** | |
15 | + * @author takensoft | |
16 | + * @since 2024.04.09 | |
17 | + * 접근 제어 조회(시스템용 - 라우터) | |
18 | + */ | |
19 | + public boolean routerAccesCheck(Map params, HttpServletRequest req) throws Exception; | |
20 | +} |
+++ src/main/java/com/takensoft/cms/accesCtrl/vo/AccesCtrlVO.java
... | ... | @@ -0,0 +1,65 @@ |
1 | +package com.takensoft.cms.accesCtrl.vo; | |
2 | + | |
3 | +import com.takensoft.common.Pagination; | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | + | |
9 | +import java.util.HashMap; | |
10 | + | |
11 | +/** | |
12 | + * @author : takensoft | |
13 | + * @since : 2024.04.01 | |
14 | + * | |
15 | + * 접근 제어 관련 VO | |
16 | + */ | |
17 | +@Setter | |
18 | +@Getter | |
19 | +@NoArgsConstructor | |
20 | +@AllArgsConstructor | |
21 | +public class AccesCtrlVO { | |
22 | + /** | |
23 | + * 접근 제어 아이디 | |
24 | + */ | |
25 | + private int acsCntrlId; | |
26 | + /** | |
27 | + * 제어 유형 | |
28 | + * 공통코드 값 등록 - permit: 허용, limit: 제한 | |
29 | + */ | |
30 | + private String cntrlType; | |
31 | + | |
32 | + /** | |
33 | + * 제어 유형명 | |
34 | + */ | |
35 | + private String cntrlTypeNm; | |
36 | + | |
37 | + /** | |
38 | + * 제어 아이피 | |
39 | + */ | |
40 | + private String cntrlIp; | |
41 | + /** | |
42 | + * 제어 경로 | |
43 | + */ | |
44 | + private String cntrlCrs; | |
45 | + /** | |
46 | + * 사용여부 | |
47 | + */ | |
48 | + private String useYn; | |
49 | + /** | |
50 | + * 등록자 | |
51 | + */ | |
52 | + private String rgtr; | |
53 | + /** | |
54 | + * 등록일 | |
55 | + */ | |
56 | + private String regDt; | |
57 | + /** | |
58 | + * 수정자 | |
59 | + */ | |
60 | + private String mdfr; | |
61 | + /** | |
62 | + * 수정일 | |
63 | + */ | |
64 | + private String mdfcnDt; | |
65 | +} |
+++ src/main/java/com/takensoft/cms/accesCtrl/web/AccesCtrlController.java
... | ... | @@ -0,0 +1,170 @@ |
1 | +package com.takensoft.cms.accesCtrl.web; | |
2 | + | |
3 | +import com.takensoft.cms.accesCtrl.service.AccesCtrlService; | |
4 | +import com.takensoft.cms.accesCtrl.vo.AccesCtrlVO; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import lombok.extern.slf4j.Slf4j; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.HttpStatus; | |
10 | +import org.springframework.http.MediaType; | |
11 | +import org.springframework.http.ResponseEntity; | |
12 | +import org.springframework.web.bind.annotation.*; | |
13 | + | |
14 | +import javax.servlet.http.HttpServletRequest; | |
15 | +import java.nio.charset.Charset; | |
16 | +import java.util.HashMap; | |
17 | +import java.util.List; | |
18 | +import java.util.Map; | |
19 | + | |
20 | +/** | |
21 | + * @author : takensoft | |
22 | + * @since : 2024.04.01 | |
23 | + * | |
24 | + * 접근 제어 관련 컨트롤러 | |
25 | + */ | |
26 | +@RestController | |
27 | +@RequiredArgsConstructor | |
28 | +@Slf4j | |
29 | +@RequestMapping(value = "/admin/accesCtrl") | |
30 | +public class AccesCtrlController { | |
31 | + | |
32 | + private final AccesCtrlService accesCtrlService; | |
33 | + | |
34 | + /** | |
35 | + * @author takensoft | |
36 | + * @since 2024.04.09 | |
37 | + * @param accesCtrlVO | |
38 | + * @return | |
39 | + * @throws Exception | |
40 | + * | |
41 | + * 접근제어 등록 | |
42 | + */ | |
43 | + @PostMapping("/saveProc.json") | |
44 | + public ResponseEntity<?> saveProc(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { | |
45 | + | |
46 | + Map<String, Object> result = accesCtrlService.accesCtrlSave(accesCtrlVO); | |
47 | + int saveResult = (int) result.get("result"); | |
48 | + | |
49 | + // 응답 처리 | |
50 | + HttpHeaders headers = new HttpHeaders(); | |
51 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
52 | + ResponseData responseData = new ResponseData(); | |
53 | + if(saveResult > 0) { | |
54 | + responseData.setStatus(HttpStatus.OK); | |
55 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
56 | + responseData.setData(result); | |
57 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
58 | + } else { | |
59 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
60 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
61 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + /** | |
66 | + * @author takensoft | |
67 | + * @since 2024.04.15 | |
68 | + * @param params | |
69 | + * @return | |
70 | + * @throws Exception | |
71 | + * | |
72 | + * 접근제어 목록 조회 | |
73 | + */ | |
74 | + @PostMapping("/findAll.json") | |
75 | + public ResponseEntity<?> findAll(@RequestBody Map<String, String> params) throws Exception { | |
76 | + | |
77 | + // 접근제어 목록 관련 정보 조회 | |
78 | + Map<String, Object> result = accesCtrlService.findAll(params); | |
79 | + // 응답 처리 | |
80 | + HttpHeaders headers = new HttpHeaders(); | |
81 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
82 | + ResponseData responseData = new ResponseData(); | |
83 | + responseData.setStatus(HttpStatus.OK); | |
84 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
85 | + responseData.setData(result); | |
86 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
87 | + } | |
88 | + | |
89 | + /** | |
90 | + * @author takensoft | |
91 | + * @since 2024.04.15 | |
92 | + * @param accesCtrlVO | |
93 | + * @return | |
94 | + * @throws Exception | |
95 | + * | |
96 | + * 접근제어 상세 조회 | |
97 | + */ | |
98 | + @PostMapping("/findByAcces.json") | |
99 | + public ResponseEntity<?> findByAcces(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { | |
100 | + // 상세 조회 | |
101 | + Map<String, Object> result = accesCtrlService.findByAccesCtrl(accesCtrlVO.getAcsCntrlId()); | |
102 | + | |
103 | + // 응답 처리 | |
104 | + HttpHeaders headers = new HttpHeaders(); | |
105 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
106 | + ResponseData responseData = new ResponseData(); | |
107 | + responseData.setStatus(HttpStatus.OK); | |
108 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
109 | + responseData.setData(result); | |
110 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
111 | + } | |
112 | + | |
113 | + /** | |
114 | + * @author takensoft | |
115 | + * @since 2024.04.15 | |
116 | + * @param accesCtrlVO | |
117 | + * @return | |
118 | + * @throws Exception | |
119 | + * | |
120 | + * 접근제어 수정 | |
121 | + */ | |
122 | + @PostMapping("/updateProc.json") | |
123 | + public ResponseEntity<?> updateProc(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { | |
124 | + // 접근제어 수정 처리 | |
125 | + int result = accesCtrlService.accesCtrlUpdate(accesCtrlVO); | |
126 | + | |
127 | + // 응답 처리 | |
128 | + HttpHeaders headers = new HttpHeaders(); | |
129 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
130 | + ResponseData responseData = new ResponseData(); | |
131 | + if(result > 0) { | |
132 | + responseData.setStatus(HttpStatus.OK); | |
133 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
134 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
135 | + } else { | |
136 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
137 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
138 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
139 | + } | |
140 | + } | |
141 | + | |
142 | + /** | |
143 | + * @author takensoft | |
144 | + * @since 2024.04.15 | |
145 | + * @param accesCtrlVO | |
146 | + * @return | |
147 | + * @throws Exception | |
148 | + * | |
149 | + * 접근제어 삭제 | |
150 | + */ | |
151 | + @PostMapping("/deleteProc.json") | |
152 | + public ResponseEntity<?> deleteProc(@RequestBody AccesCtrlVO accesCtrlVO) throws Exception { | |
153 | + // 접근제어 삭제 처리 | |
154 | + int result = accesCtrlService.accesCtrlUpdate(accesCtrlVO); | |
155 | + | |
156 | + // 응답 처리 | |
157 | + HttpHeaders headers = new HttpHeaders(); | |
158 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
159 | + ResponseData responseData = new ResponseData(); | |
160 | + if(result > 0) { | |
161 | + responseData.setStatus(HttpStatus.OK); | |
162 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
163 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
164 | + } else { | |
165 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
166 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
167 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
168 | + } | |
169 | + } | |
170 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/accesCtrl/web/SystemAccesCtrlController.java
... | ... | @@ -0,0 +1,58 @@ |
1 | +package com.takensoft.cms.accesCtrl.web; | |
2 | + | |
3 | +import com.takensoft.cms.accesCtrl.service.AccesCtrlService; | |
4 | +import com.takensoft.cms.accesCtrl.service.SystemAccesCtrlService; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import lombok.extern.slf4j.Slf4j; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.HttpStatus; | |
10 | +import org.springframework.http.MediaType; | |
11 | +import org.springframework.http.ResponseEntity; | |
12 | +import org.springframework.web.bind.annotation.PostMapping; | |
13 | +import org.springframework.web.bind.annotation.RequestBody; | |
14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
15 | +import org.springframework.web.bind.annotation.RestController; | |
16 | + | |
17 | +import javax.servlet.http.HttpServletRequest; | |
18 | +import java.nio.charset.Charset; | |
19 | +import java.util.Map; | |
20 | + | |
21 | +/** | |
22 | + * @author : takensoft | |
23 | + * @since : 2024.05.20 | |
24 | + * | |
25 | + * 접근 제어 확인 관련 컨트롤러 | |
26 | + */ | |
27 | +@RestController | |
28 | +@RequiredArgsConstructor | |
29 | +@Slf4j | |
30 | +@RequestMapping(value = "/sys/accesCtrl") | |
31 | +public class SystemAccesCtrlController { | |
32 | + | |
33 | + private final SystemAccesCtrlService systemAccesCtrlService; | |
34 | + | |
35 | + /** | |
36 | + * @author takensoft | |
37 | + * @since 2024.05.20 | |
38 | + * @param | |
39 | + * @return | |
40 | + * @throws Exception | |
41 | + * | |
42 | + * 접근 제어 관련 사용자 확인 | |
43 | + */ | |
44 | + @PostMapping(value = "/accessCheck.json") | |
45 | + public ResponseEntity<?> accessCheck(@RequestBody Map params, HttpServletRequest req) throws Exception { | |
46 | + boolean result = systemAccesCtrlService.routerAccesCheck(params, req); | |
47 | + | |
48 | + // 응답 처리 | |
49 | + HttpHeaders headers = new HttpHeaders(); | |
50 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
51 | + ResponseData responseData = new ResponseData(); | |
52 | + responseData.setStatus(HttpStatus.OK); | |
53 | + responseData.setMessage("검증"); | |
54 | + responseData.setData(result); | |
55 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
56 | + } | |
57 | + | |
58 | +} |
+++ src/main/java/com/takensoft/cms/bbs/dao/BbsCnDAO.java
... | ... | @@ -0,0 +1,118 @@ |
1 | +package com.takensoft.cms.bbs.dao; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.BbsCnVO; | |
4 | +import com.takensoft.cms.popup.vo.PopupVO; | |
5 | +import com.takensoft.common.Pagination; | |
6 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
7 | + | |
8 | +import java.util.HashMap; | |
9 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * @author : 하석형 | |
13 | + * @since : 2024.05.09 | |
14 | + * | |
15 | + * 게시판 내용 관련 Mapper | |
16 | + */ | |
17 | +@Mapper("bbsCnDAO") | |
18 | +public interface BbsCnDAO { | |
19 | + /** | |
20 | + * @author 하석형 | |
21 | + * @since 2024.05.09 | |
22 | + * 게시판 아이디 중복 검사 | |
23 | + */ | |
24 | + public boolean bbsCnIdCheck(BbsCnVO bbsCnVO) throws Exception; | |
25 | + | |
26 | + /** | |
27 | + * @author 하석형 | |
28 | + * @since 2024.05.09 | |
29 | + * 게시판 내용 등록 | |
30 | + */ | |
31 | + public int save(BbsCnVO bbsCn) throws Exception; | |
32 | + | |
33 | + /** | |
34 | + * @author 하석형 | |
35 | + * @since 2024.05.09 | |
36 | + * 게시판 내용 목록 조회 개수 | |
37 | + */ | |
38 | + public int findAllCnt(Pagination pagination) throws Exception; | |
39 | + | |
40 | + /** | |
41 | + * @author 하석형 | |
42 | + * @since 2024.05.09 | |
43 | + * 게시판 내용 목록 조회 | |
44 | + */ | |
45 | + public List<BbsCnVO> findAll(Pagination pagination) throws Exception; | |
46 | + | |
47 | + /** | |
48 | + * @author 하석형 | |
49 | + * @since 2024.05.09 | |
50 | + * | |
51 | + * 게시판 내용 상세 조회 | |
52 | + */ | |
53 | + public BbsCnVO findByBbsId(String bbsCnId); | |
54 | + | |
55 | + /** | |
56 | + * @author 하석형 | |
57 | + * @since 2024.05.09 | |
58 | + * | |
59 | + * 게시판 내용 수정 | |
60 | + */ | |
61 | + public int update(HashMap<String, Object> params); | |
62 | + | |
63 | + /** | |
64 | + * @author 하석형 | |
65 | + * @since 2024.05.09 | |
66 | + * | |
67 | + * 게시판 내용 삭제 | |
68 | + */ | |
69 | + public int delete(BbsCnVO bbsCnVO); | |
70 | + | |
71 | + /** | |
72 | + * @author 방선주 | |
73 | + * @since 2024.05.22 | |
74 | + * | |
75 | + * 조회수 증가 처리 | |
76 | + */ | |
77 | + public int updateVwCnt(String bbsId) throws Exception; | |
78 | + | |
79 | + /** | |
80 | + * @author 방선주 | |
81 | + * @since 2024.05.23 | |
82 | + * | |
83 | + * 이전글 | |
84 | + */ | |
85 | + public BbsCnVO findPrevBbsCn(BbsCnVO bbsCnVO); | |
86 | + | |
87 | + /** | |
88 | + * @author 방선주 | |
89 | + * @since 2024.05.23 | |
90 | + * | |
91 | + * 다음글 | |
92 | + */ | |
93 | + public BbsCnVO findNextBbsCn(BbsCnVO bbsCnVO); | |
94 | + | |
95 | + /** | |
96 | + * @author : 박정하 | |
97 | + * @since : 2024.05.28 | |
98 | + * | |
99 | + * 게시글 최신 목록 조회 (최신글 5건 출력) | |
100 | + */ | |
101 | + public List<HashMap> selectBbsCnListByNew() throws Exception; | |
102 | + | |
103 | + /** | |
104 | + * @author : 방선주 | |
105 | + * @since : 2024.06.04 | |
106 | + * | |
107 | + * 질의형 게시판 답변 등록 | |
108 | + */ | |
109 | + public int saveAnswer(BbsCnVO bbsCnVO) throws Exception; | |
110 | + | |
111 | + /** | |
112 | + * @author : 방선주 | |
113 | + * @since : 2024.06.13 | |
114 | + * | |
115 | + * 최근 공지 5개 조회 | |
116 | + */ | |
117 | + public List<BbsCnVO> findFiveNotice(BbsCnVO bbsCn); | |
118 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/dao/BbsMngDAO.java
... | ... | @@ -0,0 +1,128 @@ |
1 | +package com.takensoft.cms.bbs.dao; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.BbsMngVO; | |
4 | +import com.takensoft.cms.bbs.vo.BbsRouterVO; | |
5 | +import com.takensoft.common.Pagination; | |
6 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
7 | + | |
8 | +import java.util.*; | |
9 | + | |
10 | +/** | |
11 | + * @author : 박정하 | |
12 | + * @since : 2024.05.08 | |
13 | + * | |
14 | + * 게시판 관리 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("bbsMngDAO") | |
17 | +public interface BbsMngDAO { | |
18 | + /** | |
19 | + * @author 박정하 | |
20 | + * @since 2024.05.08 | |
21 | + * 게시판 아이디 중복 검사 | |
22 | + */ | |
23 | + public boolean bbsMngIdCheck(BbsMngVO bbsMngVO) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author 하석형 | |
27 | + * @since 2024.05.10 | |
28 | + * 게시판 관리 등록 | |
29 | + */ | |
30 | + public int save(BbsMngVO bbsMngVO) throws Exception; | |
31 | + | |
32 | + /** | |
33 | + * @author 하석형 | |
34 | + * @since 2024.05.10 | |
35 | + * 게시판 관리 목록 조회 개수 | |
36 | + */ | |
37 | + public int findAllCnt(Pagination pagination) throws Exception; | |
38 | + | |
39 | + /** | |
40 | + * @author 하석형 | |
41 | + * @since 2024.05.10 | |
42 | + * 게시판 관리 목록 조회 | |
43 | + */ | |
44 | + public List<BbsMngVO> findAll(Pagination pagination) throws Exception; | |
45 | + | |
46 | + /** | |
47 | + * @author 박정하 | |
48 | + * @since 2024.05.16 | |
49 | + * 게시판 관리 목록 조회 (메뉴 관리용) | |
50 | + */ | |
51 | + public List<BbsMngVO> findAllByMenuMng() throws Exception; | |
52 | + | |
53 | + /** | |
54 | + * @author 하석형 | |
55 | + * @since 2024.05.08 | |
56 | + * | |
57 | + * 게시판 관리 상세 조회 | |
58 | + */ | |
59 | + public BbsMngVO findByBbsMngId(String bbsMngId) throws Exception; | |
60 | + | |
61 | + /** | |
62 | + * @author 하석형 | |
63 | + * @since 2024.05.09 | |
64 | + * | |
65 | + * 게시판 관리 수정 | |
66 | + */ | |
67 | + public int update(BbsMngVO bbsMngVO) throws Exception; | |
68 | + | |
69 | + /** | |
70 | + * @author 하석형 | |
71 | + * @since 2024.05.09 | |
72 | + * | |
73 | + * 게시판 관리 삭제 | |
74 | + */ | |
75 | + public int delete(BbsMngVO bbsMngVO) throws Exception; | |
76 | + | |
77 | + | |
78 | + | |
79 | + /** ********************************* 게시판 라우터 (시작) ********************************* */ | |
80 | + /** | |
81 | + * @author 하석형 | |
82 | + * @since 2024.05.13 | |
83 | + * | |
84 | + * 게시판 라우터 등록 | |
85 | + */ | |
86 | + public int saveBbsRouter(BbsRouterVO bbsRouterVO) throws Exception; | |
87 | + | |
88 | + /** | |
89 | + * @author 하석형 | |
90 | + * @since 2024.05.13 | |
91 | + * | |
92 | + * 게시판 라우터 수정 | |
93 | + */ | |
94 | + public int updateBbsRouter(BbsRouterVO bbsRouterVO) throws Exception; | |
95 | + | |
96 | + /** | |
97 | + * @author 하석형 | |
98 | + * @since 2024.05.13 | |
99 | + * | |
100 | + * 게시판 라우터 삭제 | |
101 | + */ | |
102 | + public int deleteBbsRouter(String bbsMngId) throws Exception; | |
103 | + | |
104 | + /** | |
105 | + * @author 방선주 | |
106 | + * @since 2024.06.04 | |
107 | + * | |
108 | + * 게시판 라우터 목록 조회 | |
109 | + */ | |
110 | + public List<BbsRouterVO> findAllBbsRouter(String bbsMngId); | |
111 | + | |
112 | + /** | |
113 | + * @author 방선주 | |
114 | + * @since 2024.06.05 | |
115 | + * | |
116 | + * 게시판 라우터 pshrcrs 수정 | |
117 | + */ | |
118 | + public void updateCrs(BbsRouterVO route); | |
119 | + | |
120 | + /** ********************************* 게시판 라우터 (종료) ********************************* */ | |
121 | + | |
122 | + /** | |
123 | + * @author 박정하 | |
124 | + * @since 2024.07.18 | |
125 | + * 게시판 관리 목록 조회 개수 (접속 통계용) | |
126 | + */ | |
127 | + public int findAllCntNotPagination() throws Exception; | |
128 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/dao/BbsRouterDAO.java
... | ... | @@ -0,0 +1,25 @@ |
1 | +package com.takensoft.cms.bbs.dao; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.BbsCnVO; | |
4 | +import com.takensoft.cms.contsType.vo.ContsAuthrtVO; | |
5 | +import com.takensoft.common.Pagination; | |
6 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @author : 하석형 | |
12 | + * @since : 2024.05.09 | |
13 | + * | |
14 | + * 게시판 내용 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("bbsRouterDAO") | |
17 | +public interface BbsRouterDAO { | |
18 | + /** | |
19 | + * @author takensoft | |
20 | + * @since 2024.05.16 | |
21 | + * 게시판 라우터 정보 호출 | |
22 | + */ | |
23 | + List<ContsAuthrtVO> findByBbsRouterAuthrt(); | |
24 | + | |
25 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/dao/BbsTypeMngDAO.java
... | ... | @@ -0,0 +1,37 @@ |
1 | +package com.takensoft.cms.bbs.dao; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.BbsTypeMngVO; | |
4 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
5 | + | |
6 | +import java.util.HashMap; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : 박정하 | |
11 | + * @since : 2024.05.08 | |
12 | + * | |
13 | + * 게시판 유형 관리 관련 Mapper | |
14 | + */ | |
15 | +@Mapper("bbsTypeMngDAO") | |
16 | +public interface BbsTypeMngDAO { | |
17 | + /** | |
18 | + * @author 박정하 | |
19 | + * @since 2024.05.08 | |
20 | + * 게시판 유형 관리 등록 | |
21 | + */ | |
22 | + public int insertBbsTypeMng(BbsTypeMngVO bbsTypeMngVO) throws Exception; | |
23 | + | |
24 | + /** | |
25 | + * @author 하석형 | |
26 | + * @since 2024.05.13 | |
27 | + * 게시판 유형 관리 목록 조회 | |
28 | + */ | |
29 | + public List<BbsTypeMngVO> findAll(BbsTypeMngVO bbsTypeMngVO) throws Exception; | |
30 | + | |
31 | + /** | |
32 | + * @author 하석형 | |
33 | + * @since 2024.05.13 | |
34 | + * 게시판 유형 관리 상세 조회 | |
35 | + */ | |
36 | + public BbsTypeMngVO findByBbsTypeId(String bbsTypeId) throws Exception; | |
37 | +} |
+++ src/main/java/com/takensoft/cms/bbs/dao/CmntDAO.java
... | ... | @@ -0,0 +1,53 @@ |
1 | +package com.takensoft.cms.bbs.dao; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.CmntVO; | |
4 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
5 | + | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * @author : 방선주 | |
10 | + * @since : 2024.05.27 | |
11 | + * | |
12 | + * 게시판 댓글 관련 DAO | |
13 | + */ | |
14 | + | |
15 | +@Mapper("cmntDAO") | |
16 | +public interface CmntDAO { | |
17 | + /** | |
18 | + * @author 방선주 | |
19 | + * @since 2024.05.27 | |
20 | + * 게시판 댓글 등록 | |
21 | + */ | |
22 | + public int saveCmnt(CmntVO cmntVO) throws Exception; | |
23 | + /** | |
24 | + * @author 방선주 | |
25 | + * @since 2024.05.27 | |
26 | + * 게시판 댓글 카운트 조회 | |
27 | + */ | |
28 | + public int getCmntCount(CmntVO cmntVO) throws Exception; | |
29 | + /** | |
30 | + * @author 방선주 | |
31 | + * @since 2024.05.27 | |
32 | + * 부모 댓글 조회 | |
33 | + */ | |
34 | + public CmntVO findParentCmnt(int upCmntId) throws Exception; | |
35 | + /** | |
36 | + * @author 방선주 | |
37 | + * @since 2024.05.27 | |
38 | + * 게시판 댓글 목록 조회 | |
39 | + */ | |
40 | + public List<CmntVO> findCmntList(String bbsId) throws Exception; | |
41 | + /** | |
42 | + * @author 방선주 | |
43 | + * @since 2024.05.27 | |
44 | + * 게시판 댓글 업데이트 | |
45 | + */ | |
46 | + public int updateCmnt(CmntVO cmntVO) throws Exception; | |
47 | + /** | |
48 | + * @author 방선주 | |
49 | + * @since 2024.05.27 | |
50 | + * 게시판 삭제 | |
51 | + */ | |
52 | + public int deleteCmnt(CmntVO cmntVO) throws Exception; | |
53 | +} |
+++ src/main/java/com/takensoft/cms/bbs/dao/WordMngDAO.java
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.takensoft.cms.bbs.dao; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.WordMngVO; | |
4 | +import com.takensoft.common.Pagination; | |
5 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : 하석형 | |
11 | + * @since : 2024.05.31 | |
12 | + * | |
13 | + * 금지어 관련 Mapper | |
14 | + */ | |
15 | +@Mapper("wordMngDAO") | |
16 | +public interface WordMngDAO { | |
17 | + public int saveWords(WordMngVO wordMngVO) throws Exception; | |
18 | + | |
19 | + public List<WordMngVO> findAllWord(Pagination search) throws Exception; | |
20 | + | |
21 | + public int findAllCnt(Pagination search) throws Exception; | |
22 | + | |
23 | + public int deleteWords(int word) throws Exception; | |
24 | + | |
25 | + public List<String> findWordList() throws Exception; | |
26 | +} |
+++ src/main/java/com/takensoft/cms/bbs/service/BbsCnService.java
... | ... | @@ -0,0 +1,133 @@ |
1 | +package com.takensoft.cms.bbs.service; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.BbsCnVO; | |
4 | +import com.takensoft.cms.popup.vo.PopupVO; | |
5 | +import com.takensoft.common.Pagination; | |
6 | +import org.springframework.web.multipart.MultipartFile; | |
7 | + | |
8 | +import java.util.HashMap; | |
9 | +import java.util.List; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +/** | |
13 | + * @author : 하석형 | |
14 | + * @since : 2024.05.09 | |
15 | + * | |
16 | + * 게시판 관리 관련 인터페이스 | |
17 | + */ | |
18 | +public interface BbsCnService { | |
19 | + /** | |
20 | + * @author 하석형 | |
21 | + * @since 2024.05.09 | |
22 | + * 게시판 아이디 중복 검사 | |
23 | + */ | |
24 | + public boolean bbsCnIdCheck(BbsCnVO bbsCnVO) throws Exception; | |
25 | + | |
26 | + /** | |
27 | + * @author 하석형 | |
28 | + * @since 2024.05.09 | |
29 | + * 게시판 내용 등록 | |
30 | + */ | |
31 | + public HashMap<String, Object> saveBbsCn(BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList) throws Exception; | |
32 | + | |
33 | + /** | |
34 | + * @author 하석형 | |
35 | + * @since 2024.05.13 | |
36 | + * 게시판 내용 목록 조회 개수 | |
37 | + */ | |
38 | + public int findAllCnt(Pagination pagination) throws Exception; | |
39 | + | |
40 | + /** | |
41 | + * @author 하석형 | |
42 | + * @since 2024.05.09 | |
43 | + * 게시판 내용 목록 조회 | |
44 | + */ | |
45 | + public Map<String, Object> findAllBbsCn(HashMap<String, String> params) throws Exception; | |
46 | + | |
47 | + /** | |
48 | + * @author 하석형 | |
49 | + * @since 2024.05.09 | |
50 | + * | |
51 | + * 게시판 관리 상세 조회 | |
52 | + */ | |
53 | + public BbsCnVO findByBbsId(String bbsId) throws Exception; | |
54 | + | |
55 | + /** | |
56 | + * @author 하석형 | |
57 | + * @since 2024.05.09 | |
58 | + * | |
59 | + * 게시판 관리 수정 | |
60 | + */ | |
61 | + public HashMap<String, Object> updateBbsCn(HashMap<String, Object> params, List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList, List<HashMap<String, Object>> deleteImgFileList, List<MultipartFile> multipartImgList) throws Exception; | |
62 | + | |
63 | + /** | |
64 | + * @author 하석형 | |
65 | + * @since 2024.05.09 | |
66 | + * | |
67 | + * 게시판 관리 삭제 | |
68 | + */ | |
69 | + public int deleteBbsCn(BbsCnVO bbsCnVO) throws Exception; | |
70 | + | |
71 | + /** | |
72 | + * @author 방선주 | |
73 | + * @since 2024.05.22 | |
74 | + * | |
75 | + * 조회수 증가 | |
76 | + */ | |
77 | + public int updateVwCnt(HashMap<String, Object> params) throws Exception; | |
78 | + | |
79 | + /** | |
80 | + * @author 방선주 | |
81 | + * @since 2024.05.23 | |
82 | + * | |
83 | + * 이전글 조회 | |
84 | + */ | |
85 | + public BbsCnVO findPrevBbsCn(BbsCnVO bbsCnVO) throws Exception; | |
86 | + | |
87 | + /** | |
88 | + * @author 방선주 | |
89 | + * @since 2024.05.23 | |
90 | + * | |
91 | + * 다음글 조회 | |
92 | + */ | |
93 | + public BbsCnVO findNextBbsCn(BbsCnVO bbsCnVO) throws Exception; | |
94 | + /** | |
95 | + * @author 방선주 | |
96 | + * @since 2024.05.30 | |
97 | + * | |
98 | + * 첨부파일 이미지 경로 변경 | |
99 | + */ | |
100 | + public List<HashMap<String, Object>> fileListPathChange(String fileMngId) throws Exception; | |
101 | + | |
102 | + /** | |
103 | + * @author 방선주 | |
104 | + * @since 2024.05.31 | |
105 | + * | |
106 | + * 질의형 답변 등록 | |
107 | + */ | |
108 | + public HashMap<String, Object> saveAnswer(BbsCnVO bbsCnVO) throws Exception; | |
109 | + | |
110 | + /** | |
111 | + * @author 방선주 | |
112 | + * @since 2024.05.31 | |
113 | + * | |
114 | + * 질의형 답변 수정 | |
115 | + */ | |
116 | + public HashMap<String, Object> updateAnswer(BbsCnVO bbsCnVO) throws Exception; | |
117 | + | |
118 | + /** | |
119 | + * @author 방선주 | |
120 | + * @since 2024.06.07 | |
121 | + * | |
122 | + * 질의형 답변 삭제 | |
123 | + */ | |
124 | + public int deleteAns(BbsCnVO bbsCnVO) throws Exception; | |
125 | + | |
126 | + /** | |
127 | + * @author 방선주 | |
128 | + * @since 2024.06.13 | |
129 | + * | |
130 | + * 최신 공지 5개 | |
131 | + */ | |
132 | + public List<BbsCnVO> findFiveNotice(BbsCnVO bbsCn) throws Exception; | |
133 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/service/BbsMngService.java
... | ... | @@ -0,0 +1,96 @@ |
1 | +package com.takensoft.cms.bbs.service; | |
2 | + | |
3 | +import com.takensoft.cms.author.vo.AuthorVO; | |
4 | +import com.takensoft.cms.bbs.vo.BbsMngVO; | |
5 | +import com.takensoft.cms.bbs.vo.BbsRouterVO; | |
6 | + | |
7 | +import java.util.*; | |
8 | + | |
9 | +/** | |
10 | + * @author : 박정하 | |
11 | + * @since : 2024.05.08 | |
12 | + * | |
13 | + * 게시판 관리 관련 인터페이스 | |
14 | + */ | |
15 | +public interface BbsMngService { | |
16 | + /** | |
17 | + * @author 박정하 | |
18 | + * @since 2024.05.08 | |
19 | + * 게시판 아이디 중복 검사 | |
20 | + */ | |
21 | + public boolean bbsMngIdCheck(BbsMngVO bbsMngVO) throws Exception; | |
22 | + | |
23 | + /** | |
24 | + * @author 하석형 | |
25 | + * @since 2024.05.10 | |
26 | + * 게시판 관리 등록 | |
27 | + */ | |
28 | + public HashMap<String, Object> saveBbsMng(BbsMngVO bbsMngVO) throws Exception; | |
29 | + | |
30 | + /** | |
31 | + * @author 하석형 | |
32 | + * @since 2024.05.10 | |
33 | + * 게시판 관리 목록 조회 | |
34 | + */ | |
35 | + public Map<String, Object> findAllBbsMng(HashMap<String, String> params) throws Exception; | |
36 | + | |
37 | + /** | |
38 | + * @author 박정하 | |
39 | + * @since 2024.05.16 | |
40 | + * 게시판 관리 목록 조회 (메뉴 관리용) | |
41 | + */ | |
42 | + public List<BbsMngVO> findAllByMenuMng() throws Exception; | |
43 | + | |
44 | + /** | |
45 | + * @author 하석형 | |
46 | + * @since 2024.05.08 | |
47 | + * | |
48 | + * 게시판 관리 상세 조회 | |
49 | + */ | |
50 | + public BbsMngVO findByBbsMngId(String bbsMngId) throws Exception; | |
51 | + | |
52 | + /** | |
53 | + * @author 하석형 | |
54 | + * @since 2024.05.09 | |
55 | + * | |
56 | + * 게시판 관리 수정 | |
57 | + */ | |
58 | + public int updateBbsMng(BbsMngVO bbsMngVO) throws Exception; | |
59 | + | |
60 | + /** | |
61 | + * @author 하석형 | |
62 | + * @since 2024.05.09 | |
63 | + * | |
64 | + * 게시판 관리 삭제 | |
65 | + */ | |
66 | + public int deleteBbsMng(BbsMngVO bbsMngVO) throws Exception; | |
67 | + | |
68 | + | |
69 | + | |
70 | + /** ********************************* 게시판 라우터 (시작) ********************************* */ | |
71 | + /** | |
72 | + * @author 하석형 | |
73 | + * @since 2024.05.13 | |
74 | + * | |
75 | + * 게시판 라우터 등록 | |
76 | + */ | |
77 | + public int saveBbsRouter(BbsRouterVO bbsRouterVO) throws Exception; | |
78 | + | |
79 | + /** | |
80 | + * @author 하석형 | |
81 | + * @since 2024.05.13 | |
82 | + * | |
83 | + * 게시판 라우터 수정 | |
84 | + */ | |
85 | + public int updateBbsRouter(BbsRouterVO bbsRouterVO) throws Exception; | |
86 | + | |
87 | + /** | |
88 | + * @author 하석형 | |
89 | + * @since 2024.05.13 | |
90 | + * | |
91 | + * 게시판 라우터 삭제 | |
92 | + */ | |
93 | + public int deleteBbsRouter(String bbsMngId) throws Exception; | |
94 | + | |
95 | + /** ********************************* 게시판 라우터 (종료) ********************************* */ | |
96 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/service/BbsTypeMngService.java
... | ... | @@ -0,0 +1,36 @@ |
1 | +package com.takensoft.cms.bbs.service; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.BbsTypeMngVO; | |
4 | + | |
5 | +import java.util.HashMap; | |
6 | +import java.util.List; | |
7 | +import java.util.Map; | |
8 | + | |
9 | +/** | |
10 | + * @author : 박정하 | |
11 | + * @since : 2024.05.08 | |
12 | + * | |
13 | + * 게시판 유형 관리 관련 인터페이스 | |
14 | + */ | |
15 | +public interface BbsTypeMngService { | |
16 | + /** | |
17 | + * @author 박정하 | |
18 | + * @since 2024.05.08 | |
19 | + * 게시판 유형 관리 등록 | |
20 | + */ | |
21 | + public HashMap<String, Object> insertBbsTypeMng(BbsTypeMngVO bbsTypeMngVO) throws Exception; | |
22 | + | |
23 | + /** | |
24 | + * @author 하석형 | |
25 | + * @since 2024.05.13 | |
26 | + * 게시판 유형 관리 목록 조회 | |
27 | + */ | |
28 | + public Map<String, Object> findAllBbsTypeMng(BbsTypeMngVO bbsTypeMngVO) throws Exception; | |
29 | + | |
30 | + /** | |
31 | + * @author 하석형 | |
32 | + * @since 2024.05.13 | |
33 | + * 게시판 유형 관리 상세 조회 | |
34 | + */ | |
35 | + public BbsTypeMngVO findByBbsTypeId(String bbsTypeId) throws Exception; | |
36 | +} |
+++ src/main/java/com/takensoft/cms/bbs/service/CmntService.java
... | ... | @@ -0,0 +1,23 @@ |
1 | +package com.takensoft.cms.bbs.service; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.CmntVO; | |
4 | + | |
5 | +import java.util.HashMap; | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * @author : 방선주 | |
10 | + * @since : 2024.05.27 | |
11 | + * | |
12 | + * 게시판 댓글 관련 Service | |
13 | + */ | |
14 | +public interface CmntService { | |
15 | + // 댓글 등록 | |
16 | + public HashMap<String, Object> saveCmnt(CmntVO cmntVO) throws Exception; | |
17 | + // 댓글 목록 조회 | |
18 | + public List<CmntVO> findCmntList(String bbsId) throws Exception; | |
19 | + // 댓글 업데이트 | |
20 | + public HashMap<String, Object> updateCmnt(CmntVO cmntVO) throws Exception; | |
21 | + | |
22 | + public int deleteCmnt(CmntVO cmntVO) throws Exception; | |
23 | +} |
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
... | ... | @@ -0,0 +1,557 @@ |
1 | +package com.takensoft.cms.bbs.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.BbsCnDAO; | |
4 | +import com.takensoft.cms.bbs.dao.BbsMngDAO; | |
5 | +import com.takensoft.cms.bbs.dao.WordMngDAO; | |
6 | +import com.takensoft.cms.bbs.service.BbsCnService; | |
7 | +import com.takensoft.cms.bbs.vo.BbsCnVO; | |
8 | +import com.takensoft.cms.bbs.vo.BbsMngVO; | |
9 | +import com.takensoft.cms.bbs.vo.WordMngVO; | |
10 | +import com.takensoft.common.Pagination; | |
11 | +import com.takensoft.common.file.dao.FileDAO; | |
12 | +import com.takensoft.common.file.service.FileMngService; | |
13 | +import com.takensoft.common.file.vo.FileMngVO; | |
14 | +import com.takensoft.common.idgen.service.IdgenService; | |
15 | +import com.takensoft.common.util.JWTUtil; | |
16 | +import lombok.RequiredArgsConstructor; | |
17 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
18 | +import org.springframework.beans.factory.annotation.Value; | |
19 | +import org.springframework.stereotype.Service; | |
20 | +import org.springframework.transaction.annotation.Transactional; | |
21 | +import org.springframework.web.multipart.MultipartFile; | |
22 | + | |
23 | +import java.io.IOException; | |
24 | +import java.nio.file.Path; | |
25 | +import java.nio.file.Paths; | |
26 | +import java.util.HashMap; | |
27 | +import java.util.List; | |
28 | +import java.util.Map; | |
29 | + | |
30 | +/** | |
31 | + * @author : 하석형 | |
32 | + * @since : 2024.05.09 | |
33 | + * | |
34 | + * 게시판 내용 관련 구현체 | |
35 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
36 | + * BbsCnService : 게시판 내용 인터페이스 상속 | |
37 | + */ | |
38 | +@Service("bbsCnService") | |
39 | +@RequiredArgsConstructor | |
40 | +public class BbsCnServiceImpl extends EgovAbstractServiceImpl implements BbsCnService { | |
41 | + private final BbsCnDAO bbsCnDAO; | |
42 | + private final BbsMngDAO bbsMngDAO; | |
43 | + private final FileDAO fileDAO; | |
44 | + private final WordMngDAO wordMngDAO; | |
45 | + | |
46 | + private final IdgenService bbsIdgn; | |
47 | + private final JWTUtil jwtUtil; | |
48 | + | |
49 | + private final FileMngService fileMngService; | |
50 | + | |
51 | + @Value("${front.url}") | |
52 | + private String frontUrl; | |
53 | + | |
54 | + @Value("${server.port}") | |
55 | + private String serverPort; | |
56 | + | |
57 | + @Value("${spring.web.resources.static-locations}") | |
58 | + private String locationPath; | |
59 | + | |
60 | + @Value("${file.file-upload-path}") | |
61 | + private String fileUploadPath; | |
62 | + | |
63 | + /** | |
64 | + * @author 하석형 | |
65 | + * @since 2024.05.09 | |
66 | + * 게시판 아이디 중복 검사 | |
67 | + */ | |
68 | + @Override | |
69 | + public boolean bbsCnIdCheck(BbsCnVO bbsCnVO) throws Exception { | |
70 | + return bbsCnDAO.bbsCnIdCheck(bbsCnVO); | |
71 | + } | |
72 | + | |
73 | + /** | |
74 | + * @author 하석형 | |
75 | + * @since 2024.05.09 | |
76 | + * 게시판 내용 등록 | |
77 | + */ | |
78 | + @Transactional(rollbackFor = Exception.class) | |
79 | + @Override | |
80 | + public HashMap<String, Object> saveBbsCn(BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList) throws Exception { | |
81 | + HashMap<String, Object> result = new HashMap<>(); | |
82 | + List<String> wordList = wordMngDAO.findWordList(); | |
83 | + | |
84 | + // 금지어 포함 여부 체크 | |
85 | + // 제목에 금지어가 포함되어있는가? | |
86 | + if(bbsCn.getBbsNm() != null && !bbsCn.getBbsNm().isEmpty()) { | |
87 | + String bbsNm = bbsCn.getBbsNm(); | |
88 | + for (String word : wordList) { | |
89 | + if (bbsNm.contains(word)) { | |
90 | + result.put("result", -1); | |
91 | + result.put("word", word); | |
92 | + return result; | |
93 | + } | |
94 | + } | |
95 | + } | |
96 | + | |
97 | + // 내용에 금지어가 포함되어있는가? | |
98 | + String content = bbsCn.getBbsCn(); | |
99 | + for (String word : wordList) { | |
100 | + if (content.contains(word)) { | |
101 | + result.put("result", -1); | |
102 | + result.put("word", word); | |
103 | + return result; | |
104 | + } | |
105 | + } | |
106 | + | |
107 | + | |
108 | + // 게시판 내용 아이디 생성 | |
109 | + String bbsId = bbsIdgn.getNextStringId(); | |
110 | + bbsCn.setBbsId(bbsId); | |
111 | + | |
112 | + // 등록된 토큰에서 사용자 정보 조회 | |
113 | + String writer = jwtUtil.getWriter(); | |
114 | + bbsCn.setRgtr(writer); | |
115 | + | |
116 | + // youtube 링크 여부에 따라 처리 | |
117 | + if(bbsCn.getVdoUrl() != null){ | |
118 | + bbsCn.setVdoUrl(vdoUrlCheck(bbsCn.getVdoUrl())); | |
119 | + } | |
120 | + | |
121 | + | |
122 | + // 첨부파일 유무 | |
123 | + if (multipartFileList != null && !multipartFileList.isEmpty()) { | |
124 | + try { | |
125 | + FileMngVO fileMngVO = new FileMngVO(); | |
126 | + | |
127 | + // 파일매니저 등록 | |
128 | + HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); | |
129 | + result.put("multipartFileMngResult", fileMng); | |
130 | + | |
131 | + // 파일매니저 아이디 삽입 | |
132 | + bbsCn.setAtchFileMngId(fileMng.get("fileMngId").toString()); | |
133 | + } catch (IOException e) { | |
134 | + e.printStackTrace(); | |
135 | + return result; | |
136 | + } | |
137 | + } | |
138 | + // 이미지파일 유무 | |
139 | + if (multipartImgList != null && !multipartImgList.isEmpty()) { | |
140 | + try { | |
141 | + FileMngVO fileMngVO = new FileMngVO(); | |
142 | + | |
143 | + // 파일매니저 등록 | |
144 | + HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileMngVO, multipartImgList); | |
145 | + result.put("multipartFileMngResult", imgFileMng); | |
146 | + | |
147 | + // 이미지 파일매니저 아이디 삽입 | |
148 | + bbsCn.setImgFileMngId(imgFileMng.get("fileMngId").toString()); | |
149 | + } catch (IOException e) { | |
150 | + e.printStackTrace(); | |
151 | + return result; | |
152 | + } | |
153 | + } | |
154 | + | |
155 | + // 질의형인 경우 \n을 <br>로 변경 | |
156 | + if(bbsCn.getBbsNm() == null){ | |
157 | + String text = bbsCn.getBbsCn().replaceAll("\n", "<br/>"); | |
158 | + bbsCn.setBbsCn(text); | |
159 | + } | |
160 | + | |
161 | + // 기본정보 DB 등록 | |
162 | + int saveBbsCnResult = bbsCnDAO.save(bbsCn); | |
163 | + result.put("bbsId", bbsId); | |
164 | + result.put("result", saveBbsCnResult); | |
165 | + | |
166 | + return result; | |
167 | + } | |
168 | + | |
169 | + /** | |
170 | + * @author 하석형 | |
171 | + * @since 2024.05.13 | |
172 | + * 게시판 내용 목록 조회 개수 | |
173 | + */ | |
174 | + public int findAllCnt(Pagination pagination) throws Exception{ | |
175 | + return bbsCnDAO.findAllCnt(pagination); | |
176 | + } | |
177 | + | |
178 | + /** | |
179 | + * @author 하석형 | |
180 | + * @since 2024.05.09 | |
181 | + * 게시판 내용 목록 조회 | |
182 | + */ | |
183 | + @Override | |
184 | + public Map<String, Object> findAllBbsCn(HashMap<String, String> params) throws Exception { | |
185 | + Map<String, Object> result = new HashMap<>(); | |
186 | + | |
187 | + // 게시판 관리 정보 | |
188 | + BbsMngVO bbsMng = bbsMngDAO.findByBbsMngId(params.get("id")); | |
189 | + params.put("recordSize", String.valueOf(bbsMng.getArtclCnt())); | |
190 | + | |
191 | + // 게시판 보여줄 갯수 설정 | |
192 | + Pagination search = new Pagination(0, params); | |
193 | + int cnt = bbsCnDAO.findAllCnt(search); | |
194 | + Pagination pagination = new Pagination(cnt, params); | |
195 | + List<BbsCnVO> list = bbsCnDAO.findAll(pagination); | |
196 | + | |
197 | + list.forEach(entity -> { | |
198 | + String imagePath = entity.getAbsltPath(); | |
199 | + entity.setAbsltPath(convertPathToUrl(imagePath)); | |
200 | + }); | |
201 | + | |
202 | + result.put("list", list); | |
203 | + result.put("pagination", pagination); | |
204 | + result.put("codeList", null); // 검색 조건 | |
205 | + result.put("bbsMng", bbsMng); // 게시판 관리 정보 | |
206 | + return result; | |
207 | + } | |
208 | + | |
209 | + private String convertPathToUrl(String filePath) { | |
210 | + | |
211 | + String previewPath = null; | |
212 | + String[] pathArray = locationPath.split("/, "); | |
213 | + for (String path : pathArray) { | |
214 | + if (path.startsWith("file:///")) { | |
215 | + // "file:///" 부분을 제거하고 경로를 반환 | |
216 | + previewPath = path.replace("file:///", "") + fileUploadPath; | |
217 | + } else { | |
218 | + previewPath = locationPath + fileUploadPath; | |
219 | + } | |
220 | + } | |
221 | + if (filePath == null) return null; | |
222 | + // 서버경로를 절대경로에서 상대경로로 변환 | |
223 | + String basePath = previewPath; // 이 부분은 환경설정 파일에서 가져오는 것이 좋습니다. | |
224 | + String relativePath = filePath.substring(basePath.length()); | |
225 | + return frontUrl + ":" + serverPort + fileUploadPath + relativePath; | |
226 | + } | |
227 | + | |
228 | + | |
229 | + /** | |
230 | + * @author 하석형 | |
231 | + * @since 2024.05.09 | |
232 | + * | |
233 | + * 게시판 내용 상세 조회 | |
234 | + */ | |
235 | + @Override | |
236 | + public BbsCnVO findByBbsId(String bbsId) throws Exception { | |
237 | + BbsCnVO result = new BbsCnVO(); | |
238 | + if(bbsId != null && !bbsId.isEmpty()) { | |
239 | + result = bbsCnDAO.findByBbsId(bbsId); | |
240 | + | |
241 | + if(result.getBbsNm() == null){ | |
242 | + String text = result.getBbsCn().replaceAll("<br/>", "\n"); | |
243 | + result.setBbsCn(text); | |
244 | + if(result.getAnsCn() != null){ | |
245 | + String ansText = result.getAnsCn().replaceAll("<br/>", "\n"); | |
246 | + result.setAnsCn(ansText); | |
247 | + } | |
248 | + } | |
249 | + | |
250 | + } else { | |
251 | + result.setUseYn("Y"); | |
252 | + } | |
253 | + return result; | |
254 | + } | |
255 | + | |
256 | + /** | |
257 | + * @author 하석형 | |
258 | + * @since 2024.05.09 | |
259 | + * | |
260 | + * 게시판 내용 수정 | |
261 | + */ | |
262 | + @Transactional(rollbackFor = Exception.class) | |
263 | + @Override | |
264 | + public HashMap<String, Object> updateBbsCn(HashMap<String, Object> params, List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList, List<HashMap<String, Object>> deleteImgFileList, List<MultipartFile> multipartImgList) throws Exception { | |
265 | + HashMap<String, Object> result = new HashMap<>(); | |
266 | + int intResult= 0; | |
267 | + | |
268 | + List<String> wordList = wordMngDAO.findWordList(); | |
269 | + | |
270 | + // 금지어 포함 여부 체크 | |
271 | + // 제목에 금지어가 포함되어있는가? | |
272 | + String bbsNm = (params.get("bbsNm") != null) ? params.get("bbsNm").toString() : null; | |
273 | + if(bbsNm != null && !bbsNm.isEmpty()) { | |
274 | + for (String word : wordList) { | |
275 | + if (bbsNm.contains(word)) { | |
276 | + result.put("result", -1); | |
277 | + result.put("word", word); | |
278 | + return result; | |
279 | + } | |
280 | + } | |
281 | + } | |
282 | + | |
283 | + // 내용에 금지어가 포함되어있는가? | |
284 | + String content = params.get("bbsCn").toString(); | |
285 | + for (String word : wordList) { | |
286 | + if (content.contains(word)) { | |
287 | + result.put("result", -1); | |
288 | + result.put("word", word); | |
289 | + return result; | |
290 | + } | |
291 | + } | |
292 | + | |
293 | + // 등록된 토큰에서 사용자 정보 조회 | |
294 | + String writer = jwtUtil.getWriter(); | |
295 | + params.put("mdfr", writer); | |
296 | + | |
297 | + // youtube 링크 여부에 따라 처리 | |
298 | + if(params.get("vdoUrl") != null){ | |
299 | + params.put("vdoUrl", vdoUrlCheck(params.get("vdoUrl").toString())); | |
300 | + } | |
301 | + | |
302 | + // 파일 업로드 | |
303 | + FileMngVO fileMngVO = new FileMngVO(); | |
304 | + if (params.get("atchFileMngId") != null) { | |
305 | + // 파일매니저 수정 | |
306 | + try { | |
307 | + String fileMngId = params.get("atchFileMngId").toString(); | |
308 | + fileMngVO.setFileMngId(fileMngId); | |
309 | + intResult += fileMngService.fileMngUpadate(fileMngVO, deleteFileList, multipartFileList); | |
310 | + } catch (IOException e) { | |
311 | + e.printStackTrace(); | |
312 | + result.put("result", 0); | |
313 | + return result; | |
314 | + } | |
315 | + } else if (multipartFileList != null && !multipartFileList.isEmpty()){ | |
316 | + // 파일매니저 등록 | |
317 | + try { | |
318 | + HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); | |
319 | + intResult += (int)fileMng.get("fileMngResult"); | |
320 | + params.put("atchFileMngId", fileMng.get("fileMngId").toString()); | |
321 | + } catch (IOException e) { | |
322 | + e.printStackTrace(); | |
323 | + result.put("result", 0); | |
324 | + return result; | |
325 | + } | |
326 | + } | |
327 | + | |
328 | + // 이미지 파일 업로드 | |
329 | + FileMngVO fileImgMngVO = new FileMngVO(); | |
330 | + if (params.get("imgFileMngId") != null) { | |
331 | + // 파일매니저 수정 | |
332 | + try { | |
333 | + String imgFileMng = params.get("imgFileMngId").toString(); | |
334 | + fileImgMngVO.setFileMngId(imgFileMng); | |
335 | + intResult += fileMngService.fileMngUpadate(fileImgMngVO, deleteImgFileList, multipartImgList); | |
336 | + } catch (IOException e) { | |
337 | + e.printStackTrace(); | |
338 | + result.put("result", 0); | |
339 | + return result; | |
340 | + } | |
341 | + } else if (multipartImgList != null && !multipartImgList.isEmpty()){ | |
342 | + // 파일매니저 등록 | |
343 | + try { | |
344 | + HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileImgMngVO, multipartImgList); | |
345 | + intResult += (int)imgFileMng.get("fileMngResult"); | |
346 | + params.put("imgFileMngId", imgFileMng.get("fileMngId").toString()); | |
347 | + } catch (IOException e) { | |
348 | + e.printStackTrace(); | |
349 | + result.put("result", 0); | |
350 | + return result; | |
351 | + } | |
352 | + } | |
353 | + | |
354 | + // 질의형인 경우 \n을 <br>로 변경 | |
355 | + if(params.get("bbsNm") == null){ | |
356 | + String text = params.get("bbsCn").toString().replaceAll("\n", "<br/>"); | |
357 | + params.put("bbsCn", text); | |
358 | + } | |
359 | + | |
360 | + // 게시판 내용 수정 | |
361 | + intResult += bbsCnDAO.update(params); | |
362 | + | |
363 | + result.put("result", intResult); | |
364 | + return result; | |
365 | + } | |
366 | + | |
367 | + /** | |
368 | + * @author 하석형 | |
369 | + * @since 2024.05.09 | |
370 | + * | |
371 | + * 게시판 내용 삭제 | |
372 | + */ | |
373 | + @Override | |
374 | + public int deleteBbsCn(BbsCnVO bbsCnVO) throws Exception { | |
375 | + // 등록된 토큰에서 사용자 정보 조회 | |
376 | + String writer = jwtUtil.getWriter(); | |
377 | + bbsCnVO.setMdfr(writer); | |
378 | + | |
379 | + return bbsCnDAO.delete(bbsCnVO); | |
380 | + } | |
381 | + /** | |
382 | + * @author 방선주 | |
383 | + * @since 2024.05.21 | |
384 | + * | |
385 | + * vdoUrl 조건 처리 | |
386 | + */ | |
387 | + private String vdoUrlCheck(String vdoUrl) { | |
388 | + // youtube 링크가 있을 경우 | |
389 | + if (vdoUrl.contains("youtube.com") || vdoUrl.contains("youtu.be")) { | |
390 | + String[] url = vdoUrl.split("/"); | |
391 | + String videoId = url[url.length - 1]; | |
392 | + String videoUrl = "https://www.youtube.com/embed/" + videoId; | |
393 | + return videoUrl; | |
394 | + } else { | |
395 | + return vdoUrl; | |
396 | + } | |
397 | + } | |
398 | + | |
399 | + /** | |
400 | + * @author 방선주 | |
401 | + * @since 2024.05.22 | |
402 | + * | |
403 | + * 조회수 증가 처리 | |
404 | + */ | |
405 | + @Override | |
406 | + public int updateVwCnt(HashMap<String, Object> params) throws Exception { | |
407 | + return bbsCnDAO.updateVwCnt(params.get("bbsId").toString()); | |
408 | + } | |
409 | + | |
410 | + /** | |
411 | + * @author 방선주 | |
412 | + * @since 2024.05.23 | |
413 | + * | |
414 | + * 이전글 다음글 조회 | |
415 | + * | |
416 | + */ | |
417 | + @Override | |
418 | + public BbsCnVO findPrevBbsCn(BbsCnVO bbsCnVO) throws Exception { | |
419 | + Map<String, Object> result = new HashMap<>(); | |
420 | + | |
421 | + BbsCnVO prevBbsCn = bbsCnDAO.findPrevBbsCn(bbsCnVO); | |
422 | + return prevBbsCn; | |
423 | + } | |
424 | + /** | |
425 | + * @author 방선주 | |
426 | + * @since 2024.05.23 | |
427 | + * | |
428 | + * 이전글 다음글 조회 | |
429 | + * | |
430 | + */ | |
431 | + @Override | |
432 | + public BbsCnVO findNextBbsCn(BbsCnVO bbsCnVO) throws Exception { | |
433 | + Map<String, Object> result = new HashMap<>(); | |
434 | + | |
435 | + BbsCnVO NextBbsCn = bbsCnDAO.findNextBbsCn(bbsCnVO); | |
436 | + return NextBbsCn; | |
437 | + } | |
438 | + | |
439 | + /** | |
440 | + * 첨부파일 이미지 경로 변경 | |
441 | + * @param fileMngId | |
442 | + * @return | |
443 | + * @throws Exception | |
444 | + */ | |
445 | + @Override | |
446 | + public List<HashMap<String, Object>> fileListPathChange(String fileMngId) throws Exception { | |
447 | + | |
448 | + List<HashMap<String, Object>> fileList = fileDAO.fileSelectList(fileMngId); | |
449 | + | |
450 | + for (HashMap<String, Object> file : fileList) { | |
451 | + String absltPath = file.get("absltPath").toString(); | |
452 | + file.put("absltPath", convertPathToUrl(absltPath)); | |
453 | + } | |
454 | + return fileList; | |
455 | + } | |
456 | + | |
457 | + /** | |
458 | + * 질의형 게시판 답변 등록 | |
459 | + * @param bbsCnVO | |
460 | + * @return | |
461 | + * @throws Exception | |
462 | + */ | |
463 | + @Override | |
464 | + public HashMap<String, Object> saveAnswer(BbsCnVO bbsCnVO) throws Exception { | |
465 | + HashMap<String, Object> result = new HashMap<>(); | |
466 | + // 등록된 토큰에서 사용자 정보 조회 | |
467 | + String writer = jwtUtil.getWriter(); | |
468 | + bbsCnVO.setAnswer(writer); | |
469 | + | |
470 | + // 답변 금지어 포함 여부 체크 | |
471 | + List<String> wordList = wordMngDAO.findWordList(); | |
472 | + String ansCn = bbsCnVO.getAnsCn(); | |
473 | + for (String word : wordList) { | |
474 | + if (ansCn.contains(word)) { | |
475 | + result.put("result", -1); | |
476 | + result.put("word", word); | |
477 | + return result; | |
478 | + } | |
479 | + } | |
480 | + | |
481 | + // 질의형인 경우 \n을 <br>로 변경 | |
482 | + if(bbsCnVO.getBbsNm() == null){ | |
483 | + String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>"); | |
484 | + bbsCnVO.setAnsCn(text); | |
485 | + } | |
486 | + | |
487 | + int saveAns = bbsCnDAO.saveAnswer(bbsCnVO); | |
488 | + | |
489 | + result.put("result", saveAns); | |
490 | + return result; | |
491 | + } | |
492 | + | |
493 | + /** | |
494 | + * 질의형 게시판 답변 수정 | |
495 | + * @param bbsCnVO | |
496 | + * @return | |
497 | + * @throws Exception | |
498 | + */ | |
499 | + @Override | |
500 | + public HashMap<String, Object> updateAnswer(BbsCnVO bbsCnVO) throws Exception { | |
501 | + HashMap<String, Object> result = new HashMap<>(); | |
502 | + | |
503 | + // 등록된 토큰에서 사용자 정보 조회 | |
504 | + String writer = jwtUtil.getWriter(); | |
505 | + bbsCnVO.setAnswer(writer); | |
506 | + | |
507 | + // 답변 금지어 포함 여부 체크 | |
508 | + List<String> wordList = wordMngDAO.findWordList(); | |
509 | + String ansCn = bbsCnVO.getAnsCn(); | |
510 | + for (String word : wordList) { | |
511 | + if (ansCn.contains(word)) { | |
512 | + result.put("result", -1); | |
513 | + result.put("word", word); | |
514 | + return result; | |
515 | + } | |
516 | + } | |
517 | + | |
518 | + String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>"); | |
519 | + bbsCnVO.setAnsCn(text); | |
520 | + | |
521 | + int saveAns = bbsCnDAO.saveAnswer(bbsCnVO); | |
522 | + | |
523 | + result.put("result", saveAns); | |
524 | + return result; | |
525 | + } | |
526 | + | |
527 | + /** | |
528 | + * 질의형 게시판 답변 삭제 | |
529 | + * @param bbsCnVO | |
530 | + * @return | |
531 | + * @throws Exception | |
532 | + */ | |
533 | + @Override | |
534 | + public int deleteAns(BbsCnVO bbsCnVO) throws Exception { | |
535 | + // 등록된 토큰에서 사용자 정보 조회 | |
536 | + String writer = jwtUtil.getWriter(); | |
537 | + bbsCnVO.setAnswer(writer); | |
538 | + | |
539 | + bbsCnVO.setAnsCn(null); | |
540 | + bbsCnVO.setAnsStts("N"); | |
541 | + | |
542 | + return bbsCnDAO.saveAnswer(bbsCnVO); | |
543 | + } | |
544 | + | |
545 | + /** | |
546 | + * 최근 공지사항 5개 가져오기 | |
547 | + * @param | |
548 | + * @return | |
549 | + * @throws Exception | |
550 | + */ | |
551 | + @Override | |
552 | + public List<BbsCnVO> findFiveNotice(BbsCnVO bbsCn) throws Exception{ | |
553 | + return bbsCnDAO.findFiveNotice(bbsCn); | |
554 | + } | |
555 | + | |
556 | + | |
557 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsMngServiceImpl.java
... | ... | @@ -0,0 +1,350 @@ |
1 | +package com.takensoft.cms.bbs.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.BbsMngDAO; | |
4 | +import com.takensoft.cms.bbs.service.BbsCnService; | |
5 | +import com.takensoft.cms.bbs.service.BbsMngService; | |
6 | +import com.takensoft.cms.bbs.service.BbsTypeMngService; | |
7 | +import com.takensoft.cms.bbs.vo.BbsMngVO; | |
8 | +import com.takensoft.cms.bbs.vo.BbsRouterVO; | |
9 | +import com.takensoft.cms.bbs.vo.BbsTypeMngVO; | |
10 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
11 | +import com.takensoft.cms.menu.service.MenuService; | |
12 | +import com.takensoft.cms.menu.vo.MenuVO; | |
13 | +import com.takensoft.common.HierachyVO; | |
14 | +import com.takensoft.common.Pagination; | |
15 | +import com.takensoft.common.idgen.service.IdgenService; | |
16 | +import com.takensoft.common.util.JWTUtil; | |
17 | +import lombok.RequiredArgsConstructor; | |
18 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
19 | +import org.springframework.cache.annotation.CacheEvict; | |
20 | +import org.springframework.stereotype.Service; | |
21 | +import org.springframework.transaction.annotation.Transactional; | |
22 | + | |
23 | +import java.util.*; | |
24 | + | |
25 | +/** | |
26 | + * @author : 박정하 | |
27 | + * @since : 2024.05.08 | |
28 | + * | |
29 | + * 게시판 관리 관련 구현체 | |
30 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
31 | + * BbsMngService : 게시판 관리 인터페이스 상속 | |
32 | + */ | |
33 | +@Service("bbsMngService") | |
34 | +@RequiredArgsConstructor | |
35 | +public class BbsMngServiceImpl extends EgovAbstractServiceImpl implements BbsMngService { | |
36 | + private final BbsMngDAO bbsMngDAO; | |
37 | + private final BbsTypeMngService bbsTypeMngService; | |
38 | + private final BbsCnService bbsCnService; | |
39 | + private final IdgenService bbsMngIdgn; | |
40 | + private final IdgenService bbsRouterIdgn; | |
41 | + private final MenuService menuService; | |
42 | + | |
43 | + private final JWTUtil jwtUtil; | |
44 | + | |
45 | + /** | |
46 | + * @author 박정하 | |
47 | + * @since 2024.05.08 | |
48 | + * 게시판 아이디 중복 검사 | |
49 | + */ | |
50 | + @Override | |
51 | + public boolean bbsMngIdCheck(BbsMngVO bbsMngVO) throws Exception { | |
52 | + return bbsMngDAO.bbsMngIdCheck(bbsMngVO); | |
53 | + } | |
54 | + | |
55 | + /** | |
56 | + * @author 하석형 | |
57 | + * @since 2024.05.10 | |
58 | + * 게시판 관리 등록 | |
59 | + */ | |
60 | + @Override | |
61 | + @Transactional(rollbackFor = Exception.class) | |
62 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
63 | + public HashMap<String, Object> saveBbsMng(BbsMngVO bbsMngVO) throws Exception { | |
64 | + HashMap<String, Object> result = new HashMap<>(); | |
65 | + | |
66 | + // 게시판 관리 아이디 생성 | |
67 | + String bbsMngId = bbsMngIdgn.getNextStringId(); | |
68 | + bbsMngVO.setBbsMngId(bbsMngId); | |
69 | + | |
70 | + // 등록된 토큰에서 사용자 정보 조회 | |
71 | + String writer = jwtUtil.getWriter(); | |
72 | + bbsMngVO.setRgtr(writer); | |
73 | + | |
74 | + // 확장자 리스트 문자열로 변경 | |
75 | + bbsMngVO.setFileExtnNm(String.join(",", bbsMngVO.getFileExtnNmList())); | |
76 | + | |
77 | + // 첨부파일 용량 변경 (Mb -> Byte) | |
78 | + bbsMngVO.setFileSzLmt(bbsMngVO.getFileSzLmt() * 1024 * 1024); | |
79 | + | |
80 | + // 게시판 관리 등록 | |
81 | + int insertResult = bbsMngDAO.save(bbsMngVO); | |
82 | + | |
83 | + // 게시판 라우터 등록 프로세스 | |
84 | + saveBbsRouterProc(bbsMngVO); | |
85 | + | |
86 | + // 메뉴 등록 MENU_000000000000032 : 게시판 관리 메뉴 아이디 | |
87 | + | |
88 | + MenuVO menuVO = new MenuVO(); | |
89 | + menuVO.setUpMenuId("MENU_000000000000032"); // 상위메뉴아이디(콘텐츠 관리 메뉴 아이디) | |
90 | + menuVO.setMenuNm(bbsMngVO.getBbsNm()); // 메뉴명 | |
91 | + menuVO.setMenuType("bbs"); // 메뉴타입 | |
92 | + menuVO.setMenuTypeCtgry(bbsMngVO.getBbsMngId()); // 메뉴타입항목(콘텐츠 유형 아이디) | |
93 | + menuVO.setLinkType("0"); // 링크유형(현재창) | |
94 | + menuVO.setDgstfnExmnUseYn("Y"); // 만족도조사사용여부(노출) | |
95 | + menuVO.setMenuExpsrYn("Y"); // 메뉴노출여부(노출) | |
96 | + menuVO.setMenuUser("A"); // 메뉴사용자(관리자) | |
97 | + menuVO.setSysPvsnYn("1"); // 시스템제공여부(시스템등록) | |
98 | + menuService.menuSave(menuVO); | |
99 | + | |
100 | + result.put("bbsMngId", bbsMngId); | |
101 | + result.put("result", insertResult); | |
102 | + return result; | |
103 | + } | |
104 | + | |
105 | + /** | |
106 | + * @author 하석형 | |
107 | + * @since 2024.05.10 | |
108 | + * 게시판 관리 목록 조회 | |
109 | + */ | |
110 | + @Override | |
111 | + public Map<String, Object> findAllBbsMng(HashMap<String, String> params) throws Exception { | |
112 | + Map<String, Object> result = new HashMap<>(); | |
113 | + Pagination search = new Pagination(0, params); | |
114 | + int cnt = bbsMngDAO.findAllCnt(search); | |
115 | + Pagination pagination = new Pagination(cnt, params); | |
116 | + List<BbsMngVO> bbsMngList = bbsMngDAO.findAll(pagination); | |
117 | + | |
118 | + List<HashMap<String, Object>> list = new ArrayList<>(); | |
119 | + | |
120 | + //게시판 관리 목록 별 게시물 수 | |
121 | + for(BbsMngVO vo : bbsMngList) { | |
122 | + HashMap<String, Object> map = new HashMap<>(); | |
123 | + | |
124 | + // 게시판 유형 그룹 | |
125 | + BbsTypeMngVO bbsTypeMng = bbsTypeMngService.findByBbsTypeId(vo.getBbsTypeId()); | |
126 | + String bbsTypeNm = bbsTypeMng.getBbsTypeKornNm(); | |
127 | + int spaceIndex = bbsTypeNm.indexOf(" "); // 첫 번째 공백의 인덱스를 찾음 | |
128 | + if (spaceIndex != -1) { // 공백이 있는 경우 | |
129 | + bbsTypeNm = bbsTypeNm.substring(0, spaceIndex); // 첫 공백 전까지의 문자열을 추출 | |
130 | + } | |
131 | + | |
132 | + map.put("bbsMngId", vo.getBbsMngId()); | |
133 | + map.put("bbsNm", vo.getBbsNm()); | |
134 | + map.put("bbsTypeId", vo.getBbsTypeId()); | |
135 | + map.put("bbsTypeNm", bbsTypeNm); | |
136 | + map.put("atchFileUseYn", vo.getAtchFileUseYn()); | |
137 | + map.put("ntcUseYn", vo.getNtcUseYn()); | |
138 | + map.put("prvtPstUseYn", vo.getPrvtPstUseYn()); | |
139 | + map.put("bfrAftrPstUseYn", vo.getBfrAftrPstUseYn()); | |
140 | + map.put("cmntUseYn", vo.getCmntUseYn()); | |
141 | + map.put("bbsCnCnt", vo.getBbsCnCnt()); // 게시판 관리 목록 별 게시물 수 (수정 필요) | |
142 | + list.add(map); | |
143 | + } | |
144 | + | |
145 | + result.put("list", list); | |
146 | + result.put("pagination", pagination); | |
147 | + return result; | |
148 | + } | |
149 | + | |
150 | + /** | |
151 | + * @author 박정하 | |
152 | + * @since 2024.05.16 | |
153 | + * 게시판 관리 목록 조회 (메뉴 관리용) | |
154 | + */ | |
155 | + @Override | |
156 | + public List<BbsMngVO> findAllByMenuMng() throws Exception { | |
157 | + return bbsMngDAO.findAllByMenuMng(); | |
158 | + } | |
159 | + | |
160 | + /** | |
161 | + * @author 하석형 | |
162 | + * @since 2024.05.08 | |
163 | + * | |
164 | + * 게시판 관리 상세 조회 | |
165 | + */ | |
166 | + @Override | |
167 | + public BbsMngVO findByBbsMngId(String bbsMngId) throws Exception { | |
168 | + BbsMngVO result = new BbsMngVO(); | |
169 | + | |
170 | + if(bbsMngId != null && !bbsMngId.isEmpty()) { | |
171 | + result = bbsMngDAO.findByBbsMngId(bbsMngId); | |
172 | + // 첨부파일 확장자 리스트 분리 | |
173 | + if(result.getFileExtnNm() != null && !result.getFileExtnNm().isEmpty()){ | |
174 | + result.setFileExtnNmList(Arrays.asList(result.getFileExtnNm().split(","))); | |
175 | + } | |
176 | + // 첨부파일 용량 변경 (Byte -> Mb) | |
177 | + result.setFileSzLmt(result.getFileSzLmt() / 1024 / 1024); | |
178 | + | |
179 | + } else { | |
180 | + result.setUseYn("Y"); | |
181 | + } | |
182 | + return result; | |
183 | + } | |
184 | + | |
185 | + /** | |
186 | + * @author 하석형 | |
187 | + * @since 2024.05.09 | |
188 | + * | |
189 | + * 게시판 관리 수정 | |
190 | + */ | |
191 | + @Override | |
192 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
193 | + public int updateBbsMng(BbsMngVO bbsMngVO) throws Exception { | |
194 | + // 등록된 토큰에서 사용자 정보 조회 | |
195 | + String writer = jwtUtil.getWriter(); | |
196 | + bbsMngVO.setMdfr(writer); | |
197 | + | |
198 | + // 확장자 리스트 문자열로 변경 | |
199 | + bbsMngVO.setFileExtnNm(String.join(",", bbsMngVO.getFileExtnNmList())); | |
200 | + | |
201 | + bbsMngVO.setFileSzLmt(bbsMngVO.getFileSzLmt() * 1024 * 1024); | |
202 | + | |
203 | + /** 게시판 라우터 수정 프로세스 */ | |
204 | + BbsMngVO bbsMng = bbsMngDAO.findByBbsMngId(bbsMngVO.getBbsMngId()); | |
205 | + | |
206 | + // 게시판 유형이 변경된 경우 | |
207 | + if(!bbsMng.getBbsTypeId().equals(bbsMngVO.getBbsTypeId())) { | |
208 | + // 기존 게시판 라우터 삭제 | |
209 | + deleteBbsRouter(bbsMngVO.getBbsMngId()); | |
210 | + | |
211 | + // 변경된 유형으로 게시판 라우터 등록 | |
212 | + saveBbsRouterProc(bbsMngVO); | |
213 | + } | |
214 | + // 게시판 페이지 유형이 변경된 경우 | |
215 | + if(!bbsMng.getCd().equals(bbsMngVO.getCd())) { | |
216 | + // 게시판 라우터 페이지 경로 변경 | |
217 | + List<BbsRouterVO> bbsRouterList = bbsMngDAO.findAllBbsRouter(bbsMngVO.getBbsMngId()); | |
218 | + for(BbsRouterVO route : bbsRouterList) { | |
219 | + String pageCrs = route.getPageCrs().replace(bbsMng.getCd(), bbsMngVO.getCd()); | |
220 | + route.setPageCrs(pageCrs); | |
221 | + bbsMngDAO.updateCrs(route); | |
222 | + | |
223 | + } | |
224 | + | |
225 | + } | |
226 | + | |
227 | + return bbsMngDAO.update(bbsMngVO); | |
228 | + } | |
229 | + | |
230 | + /** | |
231 | + * @author 하석형 | |
232 | + * @since 2024.05.09 | |
233 | + * | |
234 | + * 게시판 관리 삭제 | |
235 | + */ | |
236 | + @Transactional(rollbackFor = Exception.class) | |
237 | + @Override | |
238 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
239 | + public int deleteBbsMng(BbsMngVO bbsMngVO) throws Exception { | |
240 | + // 등록된 토큰에서 사용자 정보 조회 | |
241 | + String writer = jwtUtil.getWriter(); | |
242 | + bbsMngVO.setMdfr(writer); | |
243 | + | |
244 | + // 게시판 라우터 비활성화 | |
245 | + BbsRouterVO bbsRouterVO = new BbsRouterVO(); | |
246 | + bbsRouterVO.setBbsMngId(bbsMngVO.getBbsMngId()); | |
247 | + bbsRouterVO.setUseYn("N"); | |
248 | + updateBbsRouter(bbsRouterVO); | |
249 | + | |
250 | + // 메뉴에서도 삭제 처리 | |
251 | + MenuVO menuVO = new MenuVO(); | |
252 | + menuVO.setMenuTypeCtgry(bbsMngVO.getBbsMngId()); | |
253 | + menuVO.setUseYn("N"); | |
254 | + menuVO.setMdfr(writer); | |
255 | + int bbsMngMenuResult = menuService.bbsMngMenuDelete(menuVO); | |
256 | + | |
257 | + | |
258 | + | |
259 | + return bbsMngDAO.delete(bbsMngVO); | |
260 | + } | |
261 | + | |
262 | + | |
263 | + /** ********************************* 게시판 라우터 (시작) ********************************* */ | |
264 | + /** | |
265 | + * @author 하석형 | |
266 | + * @since 2024.05.13 | |
267 | + * | |
268 | + * 게시판 라우터 등록 | |
269 | + */ | |
270 | + @Override | |
271 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
272 | + public int saveBbsRouter(BbsRouterVO bbsRouterVO) throws Exception { | |
273 | + return bbsMngDAO.saveBbsRouter(bbsRouterVO); | |
274 | + } | |
275 | + | |
276 | + /** | |
277 | + * @author 하석형 | |
278 | + * @since 2024.05.13 | |
279 | + * | |
280 | + * 게시판 라우터 수정 | |
281 | + */ | |
282 | + @Override | |
283 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
284 | + public int updateBbsRouter(BbsRouterVO bbsRouterVO) throws Exception { | |
285 | + return bbsMngDAO.updateBbsRouter(bbsRouterVO); | |
286 | + } | |
287 | + | |
288 | + /** | |
289 | + * @author 하석형 | |
290 | + * @since 2024.05.13 | |
291 | + * | |
292 | + * 게시판 라우터 삭제 | |
293 | + */ | |
294 | + @Override | |
295 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
296 | + public int deleteBbsRouter(String bbsMngId) throws Exception { | |
297 | + return bbsMngDAO.deleteBbsRouter(bbsMngId); | |
298 | + } | |
299 | + | |
300 | + /** | |
301 | + * @author 하석형 | |
302 | + * @since 2024.05.13 | |
303 | + * 게시판 라우터 등록 프로세스 | |
304 | + */ | |
305 | + @Transactional(rollbackFor = Exception.class) | |
306 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
307 | + public void saveBbsRouterProc(BbsMngVO bbsMngVO) throws Exception { | |
308 | + int result = 0; | |
309 | + try { | |
310 | + // 게시판 유형 조회 (bbs_type 조회) | |
311 | + BbsTypeMngVO bbsTypeMng = bbsTypeMngService.findByBbsTypeId(bbsMngVO.getBbsTypeId()); | |
312 | + // 동일한 유형의 게시판 유형 목록 조회 | |
313 | + List<BbsTypeMngVO> bbsTypeList = (List<BbsTypeMngVO>) bbsTypeMngService.findAllBbsTypeMng(bbsTypeMng).get("list"); | |
314 | + // 게시판 유형 목록만큼 게시판 라우터 등록 | |
315 | + for (BbsTypeMngVO vo : bbsTypeList) { | |
316 | + // 빈 게시판 라우터 VO 생성 | |
317 | + BbsRouterVO bbsRouterVO = new BbsRouterVO(); | |
318 | + | |
319 | + // 게시판 라우터 아이디 생성 | |
320 | + String bbsRouterId = bbsRouterIdgn.getNextStringId(); | |
321 | + | |
322 | + // 페이지 경로에 게시판 관리 아이디 추가 | |
323 | + String pageCrs = vo.getPageCrs().replace("change", bbsMngVO.getBbsMngId()); | |
324 | + String userPageCrs = pageCrs.replace("cmmn", bbsMngVO.getCd()); | |
325 | + String adminPageCrs = pageCrs.replace("cmmn", "adm"); | |
326 | + String compnCrs = vo.getCompnCrs(); | |
327 | + | |
328 | + bbsRouterVO.setBbsRouterId(bbsRouterId); | |
329 | + bbsRouterVO.setBbsMngId(bbsMngVO.getBbsMngId()); | |
330 | + bbsRouterVO.setBbsKornNm(vo.getBbsTypeKornNm()); | |
331 | + bbsRouterVO.setBbsEngNm(vo.getBbsTypeEngNm() + "_" + bbsMngVO.getBbsMngId()); | |
332 | + bbsRouterVO.setPageCrs(userPageCrs); | |
333 | + bbsRouterVO.setMngrPageCrs(adminPageCrs); | |
334 | + bbsRouterVO.setCompnCrs(compnCrs); | |
335 | + bbsRouterVO.setExpsrYn(vo.getExpsrYn()); | |
336 | + | |
337 | + // 게시판 라우터 등록 | |
338 | + result += saveBbsRouter(bbsRouterVO); | |
339 | + } | |
340 | + | |
341 | + if(result != bbsTypeList.size()) { | |
342 | + throw new Exception("게시판 라우터 등록에 실패했습니다."); | |
343 | + } | |
344 | + } catch (Exception e) { | |
345 | + e.printStackTrace(); | |
346 | + throw new Exception("게시판 라우터 등록 중 오류가 발생했습니다."); | |
347 | + } | |
348 | + } | |
349 | + /** ********************************* 게시판 라우터 (종료) ********************************* */ | |
350 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsTypeMngServiceImpl.java
... | ... | @@ -0,0 +1,76 @@ |
1 | +package com.takensoft.cms.bbs.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.BbsTypeMngDAO; | |
4 | +import com.takensoft.cms.bbs.service.BbsTypeMngService; | |
5 | +import com.takensoft.cms.bbs.vo.BbsTypeMngVO; | |
6 | +import com.takensoft.common.idgen.service.IdgenService; | |
7 | +import com.takensoft.common.util.JWTUtil; | |
8 | +import lombok.RequiredArgsConstructor; | |
9 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
10 | +import org.springframework.stereotype.Service; | |
11 | + | |
12 | +import java.util.HashMap; | |
13 | +import java.util.List; | |
14 | +import java.util.Map; | |
15 | + | |
16 | +/** | |
17 | + * @author : 박정하 | |
18 | + * @since : 2024.05.08 | |
19 | + * | |
20 | + * 게시판 유형 관리 관련 구현체 | |
21 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
22 | + * BbsTypeMngService : 게시판 유형 관리 인터페이스 상속 | |
23 | + */ | |
24 | +@Service("bbsTypeMngService") | |
25 | +@RequiredArgsConstructor | |
26 | +public class BbsTypeMngServiceImpl extends EgovAbstractServiceImpl implements BbsTypeMngService { | |
27 | + private final BbsTypeMngDAO bbsTypeMngDAO; | |
28 | + private final IdgenService bbsTypeIdgn; | |
29 | + private final JWTUtil jwtUtil; | |
30 | + | |
31 | + /** | |
32 | + * @author 박정하 | |
33 | + * @since 2024.05.08 | |
34 | + * 게시판 유형 관리 등록 | |
35 | + */ | |
36 | + public HashMap<String, Object> insertBbsTypeMng(BbsTypeMngVO bbsTypeMngVO) throws Exception { | |
37 | + HashMap<String, Object> result = new HashMap<>(); | |
38 | + | |
39 | + // 게시판 유형 아이디 생성 | |
40 | + String bbsTypeMngId = bbsTypeIdgn.getNextStringId(); | |
41 | + bbsTypeMngVO.setBbsTypeId(bbsTypeMngId); | |
42 | + | |
43 | + // 등록된 토큰에서 사용자 정보 조회 | |
44 | + String writer = jwtUtil.getWriter(); | |
45 | + bbsTypeMngVO.setRgtr(writer); | |
46 | + | |
47 | + // 게시판 관리 등록 | |
48 | + int insertResult = bbsTypeMngDAO.insertBbsTypeMng(bbsTypeMngVO); | |
49 | + | |
50 | + result.put("bbsTypeMngId", bbsTypeMngId); | |
51 | + result.put("result", insertResult); | |
52 | + return result; | |
53 | + } | |
54 | + | |
55 | + /** | |
56 | + * @author 하석형 | |
57 | + * @since 2024.05.13 | |
58 | + * 게시판 유형 관리 목록 조회 | |
59 | + */ | |
60 | + public Map<String, Object> findAllBbsTypeMng(BbsTypeMngVO bbsTypeMngVO) throws Exception { | |
61 | + Map<String, Object> result = new HashMap<>(); | |
62 | + | |
63 | + List<BbsTypeMngVO> list = bbsTypeMngDAO.findAll(bbsTypeMngVO); | |
64 | + result.put("list", list); | |
65 | + return result; | |
66 | + } | |
67 | + | |
68 | + /** | |
69 | + * @author 하석형 | |
70 | + * @since 2024.05.13 | |
71 | + * 게시판 유형 관리 상세 조회 | |
72 | + */ | |
73 | + public BbsTypeMngVO findByBbsTypeId(String bbsTypeId) throws Exception { | |
74 | + return bbsTypeMngDAO.findByBbsTypeId(bbsTypeId); | |
75 | + } | |
76 | +} |
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/CmntServiceImpl.java
... | ... | @@ -0,0 +1,159 @@ |
1 | +package com.takensoft.cms.bbs.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.CmntDAO; | |
4 | +import com.takensoft.cms.bbs.dao.WordMngDAO; | |
5 | +import com.takensoft.cms.bbs.service.CmntService; | |
6 | +import com.takensoft.cms.bbs.vo.CmntVO; | |
7 | +import com.takensoft.common.util.JWTUtil; | |
8 | +import lombok.RequiredArgsConstructor; | |
9 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
10 | +import org.springframework.stereotype.Service; | |
11 | + | |
12 | +import java.util.ArrayList; | |
13 | +import java.util.HashMap; | |
14 | +import java.util.List; | |
15 | +import java.util.Map; | |
16 | + | |
17 | +/** | |
18 | + * @author : 방선주 | |
19 | + * @since : 2024.05.27 | |
20 | + * | |
21 | + * 게시판 댓글 관련 구현체 | |
22 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
23 | + * CmntService : 게시판 댓글 인터페이스 상속 | |
24 | + */ | |
25 | +@Service("cmntService") | |
26 | +@RequiredArgsConstructor | |
27 | +public class CmntServiceImpl extends EgovAbstractServiceImpl implements CmntService { | |
28 | + | |
29 | + private final CmntDAO cmntDAO; | |
30 | + private final JWTUtil jwtUtil; | |
31 | + private final WordMngDAO wordMngDAO; | |
32 | + | |
33 | + /** | |
34 | + * @author 방선주 | |
35 | + * @since 2024.05.27 | |
36 | + * | |
37 | + * 게시판 댓글 등록 | |
38 | + */ | |
39 | + public HashMap<String, Object> saveCmnt(CmntVO cmntVO) throws Exception { | |
40 | + HashMap<String, Object> result = new HashMap<>(); | |
41 | + List<String> wordList = wordMngDAO.findWordList(); | |
42 | + | |
43 | + // 내용에 금지어가 포함되어있는가? | |
44 | + String content = cmntVO.getCmntCn(); | |
45 | + for (String word : wordList) { | |
46 | + if (content.contains(word)) { | |
47 | + result.put("result", -1); | |
48 | + result.put("word", word); | |
49 | + return result; | |
50 | + } | |
51 | + } | |
52 | + | |
53 | + // 등록된 토큰에서 사용자 정보 조회 | |
54 | + String writer = jwtUtil.getWriter(); | |
55 | + if(writer == null) { | |
56 | + result.put("result", -2); | |
57 | + return result; | |
58 | + } | |
59 | + | |
60 | + cmntVO.setRgtr(writer); | |
61 | + | |
62 | + // 댓글 깊이 | |
63 | + // 부모의 깊이 가져와 +1 | |
64 | + | |
65 | + if (cmntVO.getUpCmntId() != 0) { | |
66 | + CmntVO parentCmnt = cmntDAO.findParentCmnt(cmntVO.getUpCmntId()); | |
67 | + cmntVO.setCmntGrd(parentCmnt.getCmntGrd() + 1); | |
68 | + } | |
69 | + | |
70 | + // 댓글 순서 | |
71 | + int count = cmntDAO.getCmntCount(cmntVO); | |
72 | + cmntVO.setCmntSn(count + 1); | |
73 | + | |
74 | + | |
75 | + result.put("result", cmntDAO.saveCmnt(cmntVO)); | |
76 | + | |
77 | + return result; | |
78 | + } | |
79 | + | |
80 | + /** | |
81 | + * @author 방선주 | |
82 | + * @since 2024.05.27 | |
83 | + * | |
84 | + * 게시판 댓글 목록 조회 | |
85 | + */ | |
86 | + public List<CmntVO> findCmntList(String bbsId) throws Exception { | |
87 | + | |
88 | + List<CmntVO> flatCommentList = cmntDAO.findCmntList(bbsId); | |
89 | + return buildCommentTree(flatCommentList); | |
90 | + } | |
91 | + | |
92 | + private List<CmntVO> buildCommentTree(List<CmntVO> comments) { | |
93 | + Map<Integer, CmntVO> commentMap = new HashMap<>(); | |
94 | + List<CmntVO> rootComments = new ArrayList<>(); | |
95 | + | |
96 | + // 댓글 ID를 키로 하여 맵 생성 | |
97 | + for (CmntVO comment : comments) { | |
98 | + commentMap.put(comment.getCmntId(), comment); | |
99 | + } | |
100 | + | |
101 | + // 자식 댓글을 부모의 children 리스트에 추가 | |
102 | + for (CmntVO comment : comments) { | |
103 | + Integer parentId = comment.getUpCmntId(); | |
104 | + if (parentId != null && commentMap.containsKey(parentId)) { // 상위 댓글이 있는 경우 | |
105 | + CmntVO parent = commentMap.get(parentId); | |
106 | + parent.getChildren().add(comment); | |
107 | + } else { // 최상위 댓글인 경우 또는 부모가 맵에 없는 경우(데이터 무결성 문제) | |
108 | + rootComments.add(comment); | |
109 | + } | |
110 | + } | |
111 | + | |
112 | + return rootComments; // 최상위 댓글 리스트 반환 | |
113 | + } | |
114 | + /** | |
115 | + * @author 방선주 | |
116 | + * @since 2024.05.27 | |
117 | + * | |
118 | + * 게시판 댓글 업데이트 | |
119 | + */ | |
120 | + public HashMap<String, Object> updateCmnt(CmntVO cmntVO) throws Exception { | |
121 | + HashMap<String, Object> result = new HashMap<>(); | |
122 | + List<String> wordList = wordMngDAO.findWordList(); | |
123 | + | |
124 | + // 내용에 금지어가 포함되어있는가? | |
125 | + String content = cmntVO.getCmntCn(); | |
126 | + for (String word : wordList) { | |
127 | + if (content.contains(word)) { | |
128 | + result.put("result", -1); | |
129 | + result.put("word", word); | |
130 | + return result; | |
131 | + } | |
132 | + } | |
133 | + | |
134 | + // 등록된 토큰에서 사용자 정보 조회 | |
135 | + String writer = jwtUtil.getWriter(); | |
136 | + cmntVO.setMdfr(writer); | |
137 | + | |
138 | + result.put("result", cmntDAO.updateCmnt(cmntVO)); | |
139 | + | |
140 | + return result; | |
141 | + } | |
142 | + | |
143 | + /** | |
144 | + * @author 방선주 | |
145 | + * @since 2024.05.27 | |
146 | + * | |
147 | + * 게시판 댓글 삭제 | |
148 | + */ | |
149 | + public int deleteCmnt(CmntVO cmntVO) throws Exception { | |
150 | + | |
151 | + // 등록된 토큰에서 사용자 정보 조회 | |
152 | + String writer = jwtUtil.getWriter(); | |
153 | + cmntVO.setMdfr(writer); | |
154 | + | |
155 | + cmntVO.setUseYn("N"); | |
156 | + | |
157 | + return cmntDAO.deleteCmnt(cmntVO); | |
158 | + } | |
159 | +} |
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/WordMngServiceImpl.java
... | ... | @@ -0,0 +1,83 @@ |
1 | +package com.takensoft.cms.bbs.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.WordMngDAO; | |
4 | +import com.takensoft.cms.bbs.service.WordMngService; | |
5 | +import com.takensoft.cms.bbs.vo.WordMngVO; | |
6 | +import com.takensoft.common.Pagination; | |
7 | +import com.takensoft.common.util.JWTUtil; | |
8 | +import lombok.RequiredArgsConstructor; | |
9 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
10 | +import org.springframework.stereotype.Service; | |
11 | + | |
12 | +import java.util.HashMap; | |
13 | +import java.util.List; | |
14 | + | |
15 | +@Service("WordMngService") | |
16 | +@RequiredArgsConstructor | |
17 | +public class WordMngServiceImpl extends EgovAbstractServiceImpl implements WordMngService { | |
18 | + | |
19 | + private final WordMngDAO wordMngDAO; | |
20 | + private final JWTUtil jwtUtil; | |
21 | + | |
22 | + /** | |
23 | + * @author 방선주 | |
24 | + * @since 2024.05.31 | |
25 | + * | |
26 | + * 금지어 추가 | |
27 | + */ | |
28 | + @Override | |
29 | + public int saveWords(HashMap<String, Object> wordList) throws Exception { | |
30 | + // 등록된 토큰에서 사용자 정보 조회 | |
31 | + String writer = jwtUtil.getWriter(); | |
32 | + | |
33 | + List<String> wordsArr = (List<String>) wordList.get("wordsArr"); | |
34 | + // 금지어 등록 | |
35 | + for (String word : wordsArr){ | |
36 | + WordMngVO wordMngVO = new WordMngVO(); | |
37 | + wordMngVO.setCntrlNm(word); | |
38 | + wordMngVO.setRgtr(writer); | |
39 | + wordMngDAO.saveWords(wordMngVO); | |
40 | + } | |
41 | + | |
42 | + return wordList.size(); | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * @author 방선주 | |
47 | + * @since 2024.05.31 | |
48 | + * | |
49 | + * 금지어 목록 조회 | |
50 | + */ | |
51 | + @Override | |
52 | + public HashMap<String, Object> findAllWord(HashMap<String, String> params) throws Exception { | |
53 | + HashMap<String, Object> result = new HashMap<>(); | |
54 | + | |
55 | + Pagination search = new Pagination(0, params); | |
56 | + int cnt = wordMngDAO.findAllCnt(search); | |
57 | + Pagination pagination = new Pagination(cnt, params); | |
58 | + List<WordMngVO> wordList = wordMngDAO.findAllWord(pagination); | |
59 | + | |
60 | + result.put("wordList", wordList); | |
61 | + result.put("pagination", pagination); | |
62 | + result.put("wordsCnt", cnt); | |
63 | + | |
64 | + return result; | |
65 | + } | |
66 | + /** | |
67 | + * @author 방선주 | |
68 | + * @since 2024.05.31 | |
69 | + * | |
70 | + * 금지어 삭제 | |
71 | + */ | |
72 | + @Override | |
73 | + public int deleteWords(HashMap<String, Object> params) throws Exception { | |
74 | + List<Integer> wordsArr = (List<Integer>) params.get("wordsArr"); | |
75 | + | |
76 | + // 금지어 id로 삭제 | |
77 | + for (int cntrlNmId : wordsArr){ | |
78 | + wordMngDAO.deleteWords(cntrlNmId); | |
79 | + } | |
80 | + | |
81 | + return wordsArr.size(); | |
82 | + } | |
83 | +} |
+++ src/main/java/com/takensoft/cms/bbs/service/WordMngService.java
... | ... | @@ -0,0 +1,18 @@ |
1 | +package com.takensoft.cms.bbs.service; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.vo.WordMngVO; | |
4 | + | |
5 | +import java.util.HashMap; | |
6 | +import java.util.List; | |
7 | +import java.util.Map; | |
8 | + | |
9 | +public interface WordMngService { | |
10 | + // 금지어 관리 등록 | |
11 | + public int saveWords(HashMap<String, Object> wordList) throws Exception; | |
12 | + | |
13 | + // 금지어 관리 목록 조회 | |
14 | + public HashMap<String, Object> findAllWord(HashMap<String, String> params) throws Exception; | |
15 | + | |
16 | + // 금지어 관리 삭제 | |
17 | + public int deleteWords(HashMap<String, Object> params) throws Exception; | |
18 | +} |
+++ src/main/java/com/takensoft/cms/bbs/vo/BbsCnVO.java
... | ... | @@ -0,0 +1,144 @@ |
1 | +package com.takensoft.cms.bbs.vo; | |
2 | + | |
3 | +import lombok.*; | |
4 | +import org.springframework.web.multipart.MultipartFile; | |
5 | + | |
6 | +/** | |
7 | + * @author : 하석형 | |
8 | + * @since : 2024.05.09 | |
9 | + * | |
10 | + * 게시판 관리 관련 VO | |
11 | + */ | |
12 | +@Setter | |
13 | +@Getter | |
14 | +@AllArgsConstructor | |
15 | +public class BbsCnVO { | |
16 | + /** | |
17 | + * 게시판 아이디 | |
18 | + */ | |
19 | + private String bbsId; | |
20 | + /** | |
21 | + * 게시판 관리 아이디 | |
22 | + */ | |
23 | + private String bbsMngId; | |
24 | + /** | |
25 | + * 게시판 제목 | |
26 | + */ | |
27 | + private String bbsNm; | |
28 | + /** | |
29 | + * 게시판 내용 | |
30 | + */ | |
31 | + private String bbsCn; | |
32 | + /** | |
33 | + * 조회수 | |
34 | + */ | |
35 | + private int inqCnt; | |
36 | + /** | |
37 | + * 첨부파일 관리 아이디 | |
38 | + */ | |
39 | + private String atchFileMngId; | |
40 | + /** | |
41 | + * 이미지파일 관리 아이디 [ 갤러리형 / 영상형 전용 ] | |
42 | + */ | |
43 | + private String imgFileMngId; | |
44 | + /** | |
45 | + * 썸네일 이미지 경로 | |
46 | + */ | |
47 | + private String absltPath; | |
48 | + /** | |
49 | + * 공지글 여부 | |
50 | + * Y : 사용, N : 미사용 | |
51 | + */ | |
52 | + private String ntcPstYn; | |
53 | + /** | |
54 | + * 공지글 시작일 | |
55 | + */ | |
56 | + private String ntcBgngDt; | |
57 | + /** | |
58 | + * 공지글 종료일 | |
59 | + */ | |
60 | + private String ntcEndDt; | |
61 | + /** | |
62 | + * 비밀글 여부 | |
63 | + * Y : 사용, N : 미사용 | |
64 | + */ | |
65 | + private String prvtPstYn; | |
66 | + /** | |
67 | + * 답변 게시판 아이디 | |
68 | + */ | |
69 | + private String ansBbsId; | |
70 | + /** | |
71 | + * 답변 내용 | |
72 | + */ | |
73 | + private String ansCn; | |
74 | + /** | |
75 | + * 답변 깊이(레벨) | |
76 | + */ | |
77 | + private int ansGrd; | |
78 | + /** | |
79 | + * 답변 순서 | |
80 | + */ | |
81 | + private int ansSn; | |
82 | + /** | |
83 | + * 답변 상태 | |
84 | + * Y : 사용, N : 미사용 | |
85 | + */ | |
86 | + private String ansStts; | |
87 | + /** | |
88 | + * 영상 주소 | |
89 | + */ | |
90 | + private String vdoUrl; | |
91 | + /** | |
92 | + * 사용여부 | |
93 | + * Y : 사용, N : 미사용 | |
94 | + */ | |
95 | + private String useYn; | |
96 | + /** | |
97 | + * 등록자 | |
98 | + */ | |
99 | + private String rgtr; | |
100 | + /** | |
101 | + * 등록일 | |
102 | + */ | |
103 | + private String regDt; | |
104 | + /** | |
105 | + * 등록자 명 | |
106 | + */ | |
107 | + private String rgtrNm; // 화면 표출 용도 | |
108 | + /** | |
109 | + * 수정자 | |
110 | + */ | |
111 | + private String mdfr; | |
112 | + /** | |
113 | + * 수정일 | |
114 | + */ | |
115 | + private String mdfcnDt; | |
116 | + /** | |
117 | + * 수정자 명 | |
118 | + */ | |
119 | + private String mdfrNm; // 화면 표출 용도 | |
120 | + /** | |
121 | + * 현재 공지 여부 | |
122 | + */ | |
123 | + private String nowNtcYn; | |
124 | + /** | |
125 | + * 답변자 | |
126 | + */ | |
127 | + private String answer; | |
128 | + /** | |
129 | + * 답변자명 | |
130 | + */ | |
131 | + private String answerNm; | |
132 | + /** | |
133 | + * 답변일자 | |
134 | + */ | |
135 | + private String ansDt; | |
136 | + | |
137 | + public BbsCnVO() { | |
138 | + this.bbsCn = ""; | |
139 | + this.ntcPstYn = "N"; | |
140 | + this.prvtPstYn = "N"; | |
141 | + this.ntcBgngDt = null; | |
142 | + this.ntcEndDt = null; | |
143 | + } | |
144 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/vo/BbsMngVO.java
... | ... | @@ -0,0 +1,114 @@ |
1 | +package com.takensoft.cms.bbs.vo; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.util.ArrayList; | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * @author : 박정하 | |
10 | + * @since : 2024.05.08 | |
11 | + * | |
12 | + * 게시판 관리 관련 VO | |
13 | + */ | |
14 | +@Data | |
15 | +public class BbsMngVO { | |
16 | + /** | |
17 | + * 게시판관리아이디 | |
18 | + */ | |
19 | + private String bbsMngId; | |
20 | + /** | |
21 | + * 게시판유형아이디 | |
22 | + */ | |
23 | + private String bbsTypeId; | |
24 | + /** | |
25 | + * 게시판유형 | |
26 | + */ | |
27 | + private BbsTypeMngVO bbsType; // 사용 안함 | |
28 | + /** | |
29 | + * 게시판명 | |
30 | + */ | |
31 | + private String bbsNm; | |
32 | + /** | |
33 | + * 게시판상단정보 | |
34 | + */ | |
35 | + private String bbsUpInfo; | |
36 | + /** | |
37 | + * 게시판설명 | |
38 | + */ | |
39 | + private String bbsExpln; | |
40 | + /** | |
41 | + * 목록수 | |
42 | + */ | |
43 | + private int artclCnt; | |
44 | + /** | |
45 | + * 첨부파일 사용여부 | |
46 | + * Y : 사용, N : 미사용 | |
47 | + */ | |
48 | + private String atchFileUseYn; | |
49 | + /** | |
50 | + * 공지글 사용여부 | |
51 | + * Y : 사용, N : 미사용 | |
52 | + */ | |
53 | + private String ntcUseYn; | |
54 | + /** | |
55 | + * 파일확장자 | |
56 | + */ | |
57 | + private List<String> fileExtnNmList; | |
58 | + /** | |
59 | + * 파일확장자 | |
60 | + */ | |
61 | + private String fileExtnNm; | |
62 | + /** | |
63 | + * 파일크기제한 | |
64 | + */ | |
65 | + private int fileSzLmt; | |
66 | + /** | |
67 | + * 비밀글 사용여부 | |
68 | + * Y : 사용, N : 미사용 | |
69 | + */ | |
70 | + private String prvtPstUseYn; | |
71 | + /** | |
72 | + * 이전글/다음글 사용여부 | |
73 | + * Y : 사용, N : 미사용 | |
74 | + */ | |
75 | + private String bfrAftrPstUseYn; | |
76 | + /** | |
77 | + * 댓글 사용여부 | |
78 | + * Y : 사용, N : 미사용 | |
79 | + */ | |
80 | + private String cmntUseYn; | |
81 | + /** | |
82 | + * 사용여부 | |
83 | + * Y : 사용, N : 미사용 | |
84 | + */ | |
85 | + private String useYn; | |
86 | + /** | |
87 | + * 등록자 | |
88 | + */ | |
89 | + private String rgtr; | |
90 | + /** | |
91 | + * 등록일 | |
92 | + */ | |
93 | + private String regDt; | |
94 | + /** | |
95 | + * 수정자 | |
96 | + */ | |
97 | + private String mdfr; | |
98 | + /** | |
99 | + * 수정일 | |
100 | + */ | |
101 | + private String mdfcnDt; | |
102 | + /** | |
103 | + * 페이지 유형 | |
104 | + */ | |
105 | + private String cd; | |
106 | + /** | |
107 | + * 게시물 수 | |
108 | + */ | |
109 | + private int bbsCnCnt; | |
110 | + | |
111 | + public BbsMngVO() { | |
112 | + this.fileExtnNmList = new ArrayList<>(); | |
113 | + } | |
114 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/vo/BbsRouterVO.java
... | ... | @@ -0,0 +1,55 @@ |
1 | +package com.takensoft.cms.bbs.vo; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +/** | |
6 | + * @author : 박정하 | |
7 | + * @since : 2024.05.08 | |
8 | + * | |
9 | + * 게시판 관리 관련 VO | |
10 | + */ | |
11 | +@Data | |
12 | +public class BbsRouterVO { | |
13 | + /** | |
14 | + * 게시판 라우터 아이디 | |
15 | + */ | |
16 | + private String bbsRouterId; | |
17 | + /** | |
18 | + * 게시판 관리 아이디 | |
19 | + */ | |
20 | + private String bbsMngId; | |
21 | + /** | |
22 | + * 게시판 한글명 | |
23 | + */ | |
24 | + private String bbsKornNm; | |
25 | + /** | |
26 | + * 게시판 영문명 | |
27 | + */ | |
28 | + private String bbsEngNm; | |
29 | + /** | |
30 | + * 사용자 페이지 경로 | |
31 | + */ | |
32 | + private String pageCrs; | |
33 | + /** | |
34 | + * 관리자 페이지 경로 | |
35 | + */ | |
36 | + private String mngrPageCrs; | |
37 | + /** | |
38 | + * 컴포넌트 경로 | |
39 | + */ | |
40 | + private String compnCrs; | |
41 | + /** | |
42 | + * 노출여부 | |
43 | + * Y : 노출, N : 미노출 | |
44 | + */ | |
45 | + private String expsrYn; | |
46 | + /** | |
47 | + * 사용여부 | |
48 | + * Y : 사용, N : 미사용 | |
49 | + */ | |
50 | + private String useYn; | |
51 | + /** | |
52 | + * 등록일 | |
53 | + */ | |
54 | + private String regDt; | |
55 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/vo/BbsTypeMngVO.java
... | ... | @@ -0,0 +1,63 @@ |
1 | +package com.takensoft.cms.bbs.vo; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +/** | |
6 | + * @author : 박정하 | |
7 | + * @since : 2024.05.08 | |
8 | + * | |
9 | + * 게시판 유형 관리 관련 VO | |
10 | + */ | |
11 | +@Data | |
12 | +public class BbsTypeMngVO { | |
13 | + /** | |
14 | + * 게시판유형아이디 | |
15 | + */ | |
16 | + private String bbsTypeId; | |
17 | + /** | |
18 | + * 게시판유형한글명 | |
19 | + */ | |
20 | + private String bbsTypeKornNm; | |
21 | + /** | |
22 | + * 게시판유형영문명 | |
23 | + */ | |
24 | + private String bbsTypeEngNm; | |
25 | + /** | |
26 | + * 게시판유형 | |
27 | + */ | |
28 | + private String bbsType; | |
29 | + /** | |
30 | + * 페이지경로 | |
31 | + */ | |
32 | + private String pageCrs; | |
33 | + /** | |
34 | + * 컴포넌트경로 | |
35 | + */ | |
36 | + private String compnCrs; | |
37 | + /** | |
38 | + * 노출여부 | |
39 | + * Y: 예, N: 아니오 | |
40 | + */ | |
41 | + private String expsrYn; | |
42 | + /** | |
43 | + * 사용여부 | |
44 | + * Y: 사용, N: 미사용 | |
45 | + */ | |
46 | + private String useYn; | |
47 | + /** | |
48 | + * 등록자 | |
49 | + */ | |
50 | + private String rgtr; | |
51 | + /** | |
52 | + * 등록일 | |
53 | + */ | |
54 | + private String regDt; | |
55 | + /** | |
56 | + * 수정자 | |
57 | + */ | |
58 | + private String mdfr; | |
59 | + /** | |
60 | + * 수정일 | |
61 | + */ | |
62 | + private String mdfcnDt; | |
63 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/vo/CmntVO.java
... | ... | @@ -0,0 +1,79 @@ |
1 | +package com.takensoft.cms.bbs.vo; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : 방선주 | |
11 | + * @since : 2024.05.27 | |
12 | + * | |
13 | + * 게시판 댓글 관련 VO | |
14 | + */ | |
15 | +@Setter | |
16 | +@Getter | |
17 | +public class CmntVO { | |
18 | + /** | |
19 | + * 게시판 댓글 아이디 | |
20 | + */ | |
21 | + private int cmntId; | |
22 | + /** | |
23 | + * 게시판 아이디 | |
24 | + */ | |
25 | + private String bbsId; | |
26 | + /** | |
27 | + * 상위 댓글 아이디 | |
28 | + */ | |
29 | + private int upCmntId; | |
30 | + /** | |
31 | + * 댓글 내용 | |
32 | + */ | |
33 | + private String cmntCn; | |
34 | + /** | |
35 | + * 댓글 깊이 (레벨) | |
36 | + */ | |
37 | + private int cmntGrd; | |
38 | + /** | |
39 | + * 댓글 순서 | |
40 | + */ | |
41 | + private int cmntSn; | |
42 | + /** | |
43 | + * 사용여부 | |
44 | + */ | |
45 | + private String useYn; | |
46 | + /** | |
47 | + * 작성자 | |
48 | + */ | |
49 | + private String rgtr; | |
50 | + /** | |
51 | + * 작성일자 | |
52 | + */ | |
53 | + private String regDt; | |
54 | + /** | |
55 | + * 등록자 명 | |
56 | + */ | |
57 | + private String rgtrNm; | |
58 | + /** | |
59 | + * 수정자 | |
60 | + */ | |
61 | + private String mdfr; | |
62 | + /** | |
63 | + * 수정일자 | |
64 | + */ | |
65 | + private String mdfcnDt; | |
66 | + /** | |
67 | + * 수정자 명 | |
68 | + */ | |
69 | + private String mdfrNm; // 화면 표출 용도 | |
70 | + | |
71 | + private List<CmntVO> children; // 자식 댓글 목록 | |
72 | + | |
73 | + public CmntVO() { | |
74 | + this.upCmntId = 0; | |
75 | + this.cmntGrd = 0; | |
76 | + this.cmntSn = 0; | |
77 | + this.children = new ArrayList<>(); | |
78 | + } | |
79 | +} |
+++ src/main/java/com/takensoft/cms/bbs/vo/WordMngVO.java
... | ... | @@ -0,0 +1,25 @@ |
1 | +package com.takensoft.cms.bbs.vo; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +/** | |
7 | + * @author : 방선주 | |
8 | + * @since : 2024.05.31 | |
9 | + * | |
10 | + * 금지단어 관련 VO | |
11 | + */ | |
12 | +@Setter | |
13 | +@Getter | |
14 | +public class WordMngVO { | |
15 | + // 금지어 관리 번호 | |
16 | + private int cntrlNmId; | |
17 | + // 금지어 | |
18 | + private String cntrlNm; | |
19 | + // 등록자명 | |
20 | + private String rgtrNm; | |
21 | + // 등록자 아이디 | |
22 | + private String rgtr; | |
23 | + // 등록일 | |
24 | + private String regDt; | |
25 | +} |
+++ src/main/java/com/takensoft/cms/bbs/web/BbsCnController.java
... | ... | @@ -0,0 +1,472 @@ |
1 | +package com.takensoft.cms.bbs.web; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.service.BbsCnService; | |
4 | +import com.takensoft.cms.bbs.service.BbsMngService; | |
5 | +import com.takensoft.cms.bbs.service.CmntService; | |
6 | +import com.takensoft.cms.bbs.vo.BbsCnVO; | |
7 | +import com.takensoft.cms.bbs.vo.BbsMngVO; | |
8 | +import com.takensoft.cms.bbs.vo.CmntVO; | |
9 | +import com.takensoft.common.file.service.FileService; | |
10 | +import com.takensoft.common.file.vo.FileVO; | |
11 | +import com.takensoft.common.util.ResponseData; | |
12 | +import lombok.RequiredArgsConstructor; | |
13 | +import lombok.extern.slf4j.Slf4j; | |
14 | +import org.springframework.http.HttpHeaders; | |
15 | +import org.springframework.http.HttpStatus; | |
16 | +import org.springframework.http.MediaType; | |
17 | +import org.springframework.http.ResponseEntity; | |
18 | +import org.springframework.web.bind.annotation.*; | |
19 | +import org.springframework.web.multipart.MultipartFile; | |
20 | + | |
21 | +import javax.servlet.http.HttpServletResponse; | |
22 | +import java.io.File; | |
23 | +import java.io.FileInputStream; | |
24 | +import java.io.OutputStream; | |
25 | +import java.net.URLEncoder; | |
26 | +import java.nio.charset.Charset; | |
27 | +import java.util.HashMap; | |
28 | +import java.util.List; | |
29 | +import java.util.Map; | |
30 | + | |
31 | +/** | |
32 | + * @author : 하석형 | |
33 | + * @since : 2024.05.09 | |
34 | + * | |
35 | + * 게시판 내용 관련 컨트롤러 | |
36 | + */ | |
37 | +@RestController | |
38 | +@RequiredArgsConstructor | |
39 | +@Slf4j | |
40 | +@RequestMapping(value="/sys/bbsCn") | |
41 | +public class BbsCnController { | |
42 | + | |
43 | + private final BbsCnService bbsCnService; | |
44 | + private final BbsMngService bbsMngService; | |
45 | + private final FileService fileService; | |
46 | + | |
47 | + /** | |
48 | + * @author 하석형 | |
49 | + * @since 2024.05.09 | |
50 | + * @param bbsCnVO | |
51 | + * @return | |
52 | + * @throws Exception | |
53 | + * | |
54 | + * 게시판 내용 등록 | |
55 | + */ | |
56 | +// @PostMapping("/saveProc.json") | |
57 | +// public ResponseEntity<?> saveProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { | |
58 | +// // 응답 처리 | |
59 | +// HttpHeaders headers = new HttpHeaders(); | |
60 | +// headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
61 | +// ResponseData responseData = new ResponseData(); | |
62 | +// | |
63 | +// // 게시판 내용 등록 | |
64 | +// int result = bbsCnService.saveBbsCn(bbsCnVO); | |
65 | +// if(result > 0) { | |
66 | +// responseData.setStatus(HttpStatus.OK); | |
67 | +// responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
68 | +// responseData.setData(result); | |
69 | +// return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
70 | +// } else { | |
71 | +// responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
72 | +// responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
73 | +// return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
74 | +// } | |
75 | +// } | |
76 | + /** | |
77 | + * @author 방선주 | |
78 | + * @since 2024.05.21 | |
79 | + * @param bbsCn, multipartFileList | |
80 | + * @return | |
81 | + * @throws Exception | |
82 | + * | |
83 | + * 게시판 내용 등록 | |
84 | + */ | |
85 | + @PostMapping(path = "/saveBbsCn.file") | |
86 | + public ResponseEntity<?> saveBbsCn(@RequestPart BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList) throws Exception { | |
87 | + | |
88 | + // 응답 처리 | |
89 | + HttpHeaders headers = new HttpHeaders(); | |
90 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
91 | + ResponseData responseData = new ResponseData(); | |
92 | + | |
93 | + // 게시판 내용 등록 | |
94 | + HashMap<String, Object> result = bbsCnService.saveBbsCn(bbsCn, multipartFileList, multipartImgList); | |
95 | + int insertResult = (int) result.get("result"); | |
96 | + | |
97 | + if (insertResult > 0) { | |
98 | + responseData.setStatus(HttpStatus.OK); | |
99 | + responseData.setMessage("정상적으로 등록되었습니다."); | |
100 | + responseData.setData(result); | |
101 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
102 | + } else if (insertResult == -1){ | |
103 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
104 | + responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); | |
105 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
106 | + | |
107 | + } else { | |
108 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
109 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
110 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
111 | + } | |
112 | + } | |
113 | + | |
114 | + /** | |
115 | + * @author 하석형 | |
116 | + * @since 2024.05.09 | |
117 | + * @param params | |
118 | + * @return | |
119 | + * @throws Exception | |
120 | + * | |
121 | + * 게시판 내용 목록 조회 | |
122 | + */ | |
123 | + @PostMapping("/findAll.json") | |
124 | + public ResponseEntity<?> findAll(@RequestBody HashMap<String, String> params) throws Exception { | |
125 | + // 게시판 내용 목록 조회 | |
126 | + Map<String, Object> result = bbsCnService.findAllBbsCn(params); | |
127 | + | |
128 | + // 응답처리 | |
129 | + HttpHeaders headers = new HttpHeaders(); | |
130 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
131 | + ResponseData responseData = new ResponseData(); | |
132 | + responseData.setStatus(HttpStatus.OK); | |
133 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
134 | + responseData.setData(result); | |
135 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
136 | + } | |
137 | + | |
138 | + /** | |
139 | + * @author 하석형 | |
140 | + * @since 2024.05.09 | |
141 | + * @param bbsCnVO | |
142 | + * @return | |
143 | + * @throws Exception | |
144 | + * | |
145 | + * 게시판 내용 상세 조회 | |
146 | + */ | |
147 | + @PostMapping("/findByBbsCn.json") | |
148 | + public ResponseEntity<?> findByBbsCn(@RequestBody BbsCnVO bbsCnVO) throws Exception { | |
149 | + | |
150 | + // 게시판 관리 정보 조회 | |
151 | + BbsMngVO bbsMng = bbsMngService.findByBbsMngId(bbsCnVO.getBbsMngId()); | |
152 | + // 게시판 내용 상세 조회 | |
153 | + BbsCnVO bbsCn = bbsCnService.findByBbsId(bbsCnVO.getBbsId()); | |
154 | + // 첨부파일 목록 조회 | |
155 | + String fileMngId = bbsCn.getAtchFileMngId(); | |
156 | + List<HashMap<String,Object>> fileList = bbsCnService.fileListPathChange(fileMngId); | |
157 | + //이미지 파일 목록 조회 | |
158 | + String imgFileMngId = bbsCn.getImgFileMngId(); | |
159 | + List<HashMap<String,Object>> imgFileList = bbsCnService.fileListPathChange(imgFileMngId); | |
160 | + | |
161 | + | |
162 | + // 이전글 다음글 조회 | |
163 | + BbsCnVO prevBbsCn = bbsCnService.findPrevBbsCn(bbsCnVO); | |
164 | + BbsCnVO nextBbsCn = bbsCnService.findNextBbsCn(bbsCnVO); | |
165 | + | |
166 | + Map<String, Object> result = new HashMap<String, Object>(); | |
167 | + result.put("bbsMng", bbsMng); | |
168 | + result.put("bbsCn", bbsCn); | |
169 | + result.put("fileList", fileList); | |
170 | + result.put("imgFileList", imgFileList); | |
171 | + result.put("prevBbsCn", prevBbsCn); | |
172 | + result.put("nextBbsCn", nextBbsCn); | |
173 | + | |
174 | + // 응답 처리 | |
175 | + HttpHeaders headers = new HttpHeaders(); | |
176 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
177 | + ResponseData responseData = new ResponseData(); | |
178 | + responseData.setStatus(HttpStatus.OK); | |
179 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
180 | + responseData.setData(result); | |
181 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
182 | + } | |
183 | + | |
184 | +// /** | |
185 | +// * @author 하석형 | |
186 | +// * @since 2024.05.09 | |
187 | +// * @param bbsCnVO | |
188 | +// * @return | |
189 | +// * @throws Exception | |
190 | +// * | |
191 | +// * 게시판 내용 수정 | |
192 | +// */ | |
193 | +// @PostMapping("/updateProc.json") | |
194 | +// public ResponseEntity<?> updateProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { | |
195 | +// HttpHeaders headers = new HttpHeaders(); | |
196 | +// headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
197 | +// ResponseData responseData = new ResponseData(); | |
198 | +// | |
199 | +// // 게시판 내용 수정 | |
200 | +// int result = bbsCnService.updateBbsCn(bbsCnVO); | |
201 | +// | |
202 | +// // 응답 처리 | |
203 | +// if(result > 0) { | |
204 | +// responseData.setStatus(HttpStatus.OK); | |
205 | +// responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
206 | +// return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
207 | +// } else { | |
208 | +// responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
209 | +// responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
210 | +// return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
211 | +// } | |
212 | +// } | |
213 | + /** | |
214 | + * @author 방선주 | |
215 | + * @since 2024.05.21 | |
216 | + * @param params, multipartFileList | |
217 | + * @return | |
218 | + * @throws Exception | |
219 | + * | |
220 | + * 게시판 내용 수정 | |
221 | + */ | |
222 | + @PostMapping(path = "/updateBbsCn.file") | |
223 | + public ResponseEntity<?> updateBbsCn(@RequestPart HashMap<String, Object> params, @RequestPart List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList, @RequestPart List<HashMap<String, Object>> deleteImgFileList, List<MultipartFile> multipartImgList) throws Exception { | |
224 | + | |
225 | + // 게시판 내용 수정 | |
226 | + HashMap<String, Object> result = bbsCnService.updateBbsCn(params, deleteFileList, multipartFileList, deleteImgFileList, multipartImgList); | |
227 | + | |
228 | + int updateResult = (int) result.get("result"); | |
229 | + // 응답 처리 | |
230 | + HttpHeaders headers = new HttpHeaders(); | |
231 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
232 | + ResponseData responseData = new ResponseData(); | |
233 | + if (updateResult > 0) { | |
234 | + responseData.setStatus(HttpStatus.OK); | |
235 | + responseData.setMessage("정상적으로 게시글이 수정 되었습니다."); | |
236 | + responseData.setData(params.get("bbsId")); | |
237 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
238 | + } else if (updateResult == -1){ | |
239 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
240 | + responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); | |
241 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
242 | + | |
243 | + } else { | |
244 | + responseData.setStatus(HttpStatus.BAD_REQUEST); | |
245 | + responseData.setMessage("게시글 수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
246 | + return new ResponseEntity<>(responseData, headers, HttpStatus.BAD_REQUEST); | |
247 | + } | |
248 | + } | |
249 | + | |
250 | + /** | |
251 | + * @author 하석형 | |
252 | + * @since 2024.05.09 | |
253 | + * @param bbsCnVO | |
254 | + * @return | |
255 | + * @throws Exception | |
256 | + * | |
257 | + * 게시판 내용 삭제 | |
258 | + */ | |
259 | + @PostMapping("/deleteProc.json") | |
260 | + public ResponseEntity<?> deleteProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { | |
261 | + HttpHeaders headers = new HttpHeaders(); | |
262 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
263 | + ResponseData responseData = new ResponseData(); | |
264 | + | |
265 | + // 게시판 내용 수정 | |
266 | + int result = bbsCnService.deleteBbsCn(bbsCnVO); | |
267 | + | |
268 | + // 응답 처리 | |
269 | + if(result > 0) { | |
270 | + responseData.setStatus(HttpStatus.OK); | |
271 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
272 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
273 | + } else { | |
274 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
275 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
276 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
277 | + } | |
278 | + } | |
279 | + /** | |
280 | + * @author 방선주 | |
281 | + * @since 2024.05.22 | |
282 | + * @param params | |
283 | + * @return | |
284 | + * @throws Exception | |
285 | + * | |
286 | + * 조회수 증가 | |
287 | + */ | |
288 | + @PostMapping("/updateVwCnt.json") | |
289 | + public ResponseEntity<?> updateVwCnt(@RequestBody HashMap<String, Object> params) throws Exception { | |
290 | + HttpHeaders headers = new HttpHeaders(); | |
291 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
292 | + ResponseData responseData = new ResponseData(); | |
293 | + | |
294 | + // 조회수 증가 | |
295 | + int result = bbsCnService.updateVwCnt(params); | |
296 | + | |
297 | + // 응답 처리 | |
298 | + if(result > 0) { | |
299 | + responseData.setStatus(HttpStatus.OK); | |
300 | + responseData.setMessage("정상적으로 조회수가 증가되었습니다."); | |
301 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
302 | + } else { | |
303 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
304 | + responseData.setMessage("조회수 증가에 실패하였습니다.\n담당자에게 문의하세요."); | |
305 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
306 | + } | |
307 | + } | |
308 | + | |
309 | + /** | |
310 | + * @author 방선주 | |
311 | + * @since 2024.05.21 | |
312 | + * @param fileId | |
313 | + * @return | |
314 | + * @throws Exception | |
315 | + * | |
316 | + * 게시판 첨부 파일 다운로드 | |
317 | + */ | |
318 | + @PostMapping("/fileDownload.json") | |
319 | + public void fileDownload(@RequestBody int fileId, HttpServletResponse response) throws Exception { | |
320 | + | |
321 | + // 파일 정보 조회 | |
322 | + FileVO file = fileService.fileSelectOne(fileId); | |
323 | + File downloadFile = null; | |
324 | + // 받은 파일 정보로 파일 다운로드 생성 | |
325 | + if(file != null){ | |
326 | + String filePath = file.getAbsltPath(); | |
327 | + downloadFile = new File(filePath); | |
328 | + | |
329 | + response.setContentType("application/octet-stream"); | |
330 | + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(file.getFileNm(), "UTF-8") + "\""); | |
331 | + response.setHeader("Content-Transfer-Encoding", "binary"); | |
332 | + | |
333 | + try (OutputStream out = response.getOutputStream(); FileInputStream fis = new FileInputStream(downloadFile)) { | |
334 | + byte[] buffer = new byte[1024]; | |
335 | + int bytesRead; | |
336 | + while ((bytesRead = fis.read(buffer)) != -1) { | |
337 | + out.write(buffer, 0, bytesRead); | |
338 | + } | |
339 | + } | |
340 | + } | |
341 | + } | |
342 | + | |
343 | + | |
344 | + /********* 질의형 게시판 **********/ | |
345 | + | |
346 | + /** | |
347 | + * @author 방선주 | |
348 | + * @since 2024.05.31 | |
349 | + * @param bbsCnVO | |
350 | + * @return | |
351 | + * @throws Exception | |
352 | + * | |
353 | + * 질의형 게시판 답변 등록 | |
354 | + */ | |
355 | + @PostMapping("/ansSaveProc.json") | |
356 | + public ResponseEntity<?> ansSaveProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { | |
357 | + // 응답 처리 | |
358 | + HttpHeaders headers = new HttpHeaders(); | |
359 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
360 | + ResponseData responseData = new ResponseData(); | |
361 | + | |
362 | +// int result = 1; | |
363 | + HashMap<String, Object> result = bbsCnService.saveAnswer(bbsCnVO); | |
364 | + int insertResult = (int) result.get("result"); | |
365 | + | |
366 | + | |
367 | + if(insertResult > 0) { | |
368 | + responseData.setStatus(HttpStatus.OK); | |
369 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
370 | + responseData.setData(result); | |
371 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
372 | + } else if (insertResult == -1){ | |
373 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
374 | + responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); | |
375 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
376 | + | |
377 | + } else { | |
378 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
379 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
380 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
381 | + } | |
382 | + } | |
383 | + /** | |
384 | + * @author 방선주 | |
385 | + * @since 2024.05.31 | |
386 | + * @param bbsCnVO | |
387 | + * @return | |
388 | + * @throws Exception | |
389 | + * | |
390 | + * 질의형 게시판 답변 수정 | |
391 | + */ | |
392 | + @PostMapping("/ansUpdateProc.json") | |
393 | + public ResponseEntity<?> ansUpdateProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { | |
394 | + // 응답 처리 | |
395 | + HttpHeaders headers = new HttpHeaders(); | |
396 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
397 | + ResponseData responseData = new ResponseData(); | |
398 | + | |
399 | +// int result = 1; | |
400 | + HashMap<String, Object> result = bbsCnService.updateAnswer(bbsCnVO); | |
401 | + int updateResult = (int) result.get("result"); | |
402 | + | |
403 | + if(updateResult > 0) { | |
404 | + responseData.setStatus(HttpStatus.OK); | |
405 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
406 | + responseData.setData(result); | |
407 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
408 | + } else if (updateResult == -1){ | |
409 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
410 | + responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); | |
411 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
412 | + | |
413 | + } else { | |
414 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
415 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
416 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
417 | + } | |
418 | + } | |
419 | + /** | |
420 | + * @author 방선주 | |
421 | + * @since 2024.06.07 | |
422 | + * @param bbsCnVO | |
423 | + * @return | |
424 | + * @throws Exception | |
425 | + * | |
426 | + * 질의형 게시판 답변 삭제 | |
427 | + */ | |
428 | + @PostMapping("/ansDeleteProc.json") | |
429 | + public ResponseEntity<?> ansDeleteProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { | |
430 | + // 응답 처리 | |
431 | + HttpHeaders headers = new HttpHeaders(); | |
432 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
433 | + ResponseData responseData = new ResponseData(); | |
434 | + | |
435 | +// int result = 1; | |
436 | + int result = bbsCnService.deleteAns(bbsCnVO); | |
437 | + | |
438 | + if(result > 0) { | |
439 | + responseData.setStatus(HttpStatus.OK); | |
440 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
441 | + responseData.setData(result); | |
442 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
443 | + } else { | |
444 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
445 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
446 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
447 | + } | |
448 | + } | |
449 | + /** | |
450 | + * @author 방선주 | |
451 | + * @since 2024.06.13 | |
452 | + * @param | |
453 | + * @return | |
454 | + * @throws Exception | |
455 | + * | |
456 | + * 공지사항 최신 5개 조회 | |
457 | + */ | |
458 | + @PostMapping("/findFiveNotice.json") | |
459 | + public ResponseEntity<?> findFiveNotice(@RequestBody BbsCnVO bbsCn) throws Exception { | |
460 | + // 공지사항 최신 5개 조회 | |
461 | + List<BbsCnVO> result = bbsCnService.findFiveNotice(bbsCn); | |
462 | + | |
463 | + // 응답 처리 | |
464 | + HttpHeaders headers = new HttpHeaders(); | |
465 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
466 | + ResponseData responseData = new ResponseData(); | |
467 | + responseData.setStatus(HttpStatus.OK); | |
468 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
469 | + responseData.setData(result); | |
470 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
471 | + } | |
472 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/web/BbsMngController.java
... | ... | @@ -0,0 +1,224 @@ |
1 | +package com.takensoft.cms.bbs.web; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.service.BbsCnService; | |
4 | +import com.takensoft.cms.bbs.service.BbsMngService; | |
5 | +import com.takensoft.cms.bbs.service.BbsTypeMngService; | |
6 | +import com.takensoft.cms.bbs.vo.BbsMngVO; | |
7 | +import com.takensoft.cms.bbs.vo.BbsTypeMngVO; | |
8 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
9 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
10 | +import com.takensoft.common.HierachyVO; | |
11 | +import com.takensoft.common.util.ResponseData; | |
12 | +import lombok.RequiredArgsConstructor; | |
13 | +import lombok.extern.slf4j.Slf4j; | |
14 | +import org.springframework.http.HttpHeaders; | |
15 | +import org.springframework.http.HttpStatus; | |
16 | +import org.springframework.http.MediaType; | |
17 | +import org.springframework.http.ResponseEntity; | |
18 | +import org.springframework.web.bind.annotation.PostMapping; | |
19 | +import org.springframework.web.bind.annotation.RequestBody; | |
20 | +import org.springframework.web.bind.annotation.RequestMapping; | |
21 | +import org.springframework.web.bind.annotation.RestController; | |
22 | + | |
23 | +import java.nio.charset.Charset; | |
24 | +import java.util.*; | |
25 | + | |
26 | +/** | |
27 | + * @author : 박정하 | |
28 | + * @since : 2024.05.08 | |
29 | + * | |
30 | + * 게시판 관리 관련 컨트롤러 | |
31 | + */ | |
32 | +@RestController | |
33 | +@RequiredArgsConstructor | |
34 | +@Slf4j | |
35 | +@RequestMapping(value="/admin/bbsMng") | |
36 | +public class BbsMngController { | |
37 | + | |
38 | + private final BbsMngService bbsMngService; | |
39 | + private final BbsTypeMngService bbsTypeMngService; | |
40 | + private final CodeManageService codeManageService; | |
41 | + | |
42 | + /** | |
43 | + * @author 하석형 | |
44 | + * @since 2024.05.10 | |
45 | + * @param bbsMngVO | |
46 | + * @return | |
47 | + * @throws Exception | |
48 | + * | |
49 | + * 게시판 관리 등록 | |
50 | + */ | |
51 | + @PostMapping("/saveProc.json") | |
52 | + public ResponseEntity<?> saveProc(@RequestBody BbsMngVO bbsMngVO) throws Exception { | |
53 | + // 응답 처리 | |
54 | + HttpHeaders headers = new HttpHeaders(); | |
55 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
56 | + ResponseData responseData = new ResponseData(); | |
57 | + | |
58 | + // 게시판 관리 아이디 중복 검사 (아이디 입력 삭제로 미사용) | |
59 | + /*boolean isExistence = bbsMngService.bbsMngIdCheck(bbsMngVO); | |
60 | + if(isExistence) { | |
61 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
62 | + responseData.setMessage("이미 존재하는 게시판 아이디입니다."); | |
63 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
64 | + }*/ | |
65 | + | |
66 | + // 게시판 관리 등록 | |
67 | + HashMap<String, Object> result = bbsMngService.saveBbsMng(bbsMngVO); | |
68 | + int insertResult = (int) result.get("result"); | |
69 | + if(insertResult > 0) { | |
70 | + responseData.setStatus(HttpStatus.OK); | |
71 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
72 | + responseData.setData(result); | |
73 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
74 | + } else { | |
75 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
76 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
77 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
78 | + } | |
79 | + } | |
80 | + | |
81 | + /** | |
82 | + * @author 하석형 | |
83 | + * @since 2024.05.10 | |
84 | + * @param params | |
85 | + * @return | |
86 | + * @throws Exception | |
87 | + * | |
88 | + * 게시판 관리 목록 조회 | |
89 | + */ | |
90 | + @PostMapping("/findAll.json") | |
91 | + public ResponseEntity<?> findAll(@RequestBody HashMap<String, String> params) throws Exception { | |
92 | + // 게시판 관리 목록 조회 | |
93 | + Map<String, Object> result = bbsMngService.findAllBbsMng(params); | |
94 | + | |
95 | + // 응답처리 | |
96 | + HttpHeaders headers = new HttpHeaders(); | |
97 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
98 | + ResponseData responseData = new ResponseData(); | |
99 | + responseData.setStatus(HttpStatus.OK); | |
100 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
101 | + responseData.setData(result); | |
102 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
103 | + } | |
104 | + | |
105 | + /** | |
106 | + * @author 박정하 | |
107 | + * @since 2024.05.16 | |
108 | + * @param | |
109 | + * @return | |
110 | + * @throws Exception | |
111 | + * | |
112 | + * 게시판 관리 목록 조회 (메뉴 관리용) | |
113 | + */ | |
114 | + @PostMapping("/findAllByMenuMng.json") | |
115 | + public ResponseEntity<?> findAllByMenuMng() throws Exception { | |
116 | + // 게시판 관리 목록 조회 | |
117 | + List<BbsMngVO> result = bbsMngService.findAllByMenuMng(); | |
118 | + | |
119 | + // 응답처리 | |
120 | + HttpHeaders headers = new HttpHeaders(); | |
121 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
122 | + ResponseData responseData = new ResponseData(); | |
123 | + responseData.setStatus(HttpStatus.OK); | |
124 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
125 | + responseData.setData(result); | |
126 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
127 | + } | |
128 | + | |
129 | + /** | |
130 | + * @author 하석형 | |
131 | + * @since 2024.05.08 | |
132 | + * @param bbsMngVO | |
133 | + * @return | |
134 | + * @throws Exception | |
135 | + * | |
136 | + * 게시판 관리 상세 조회 | |
137 | + */ | |
138 | + @PostMapping("/findByBbsMng.json") | |
139 | + public ResponseEntity<?> findByBbsMng(@RequestBody BbsMngVO bbsMngVO) throws Exception { | |
140 | + // 게시판 관리 상세 조회 | |
141 | + BbsMngVO bbsMng = bbsMngService.findByBbsMngId(bbsMngVO.getBbsMngId()); | |
142 | + | |
143 | + // 게시판 유형 목록 조회 | |
144 | + BbsTypeMngVO bbsTypeMap = new BbsTypeMngVO(); | |
145 | + bbsTypeMap.setExpsrYn("Y"); | |
146 | + List<BbsTypeMngVO> bbsType = (List<BbsTypeMngVO>) bbsTypeMngService.findAllBbsTypeMng(bbsTypeMap).get("list"); | |
147 | + // 페이지 유형 목록 조회 | |
148 | + List<CodeManageVO> pageType = codeManageService.findByChildCdCache("pageType"); | |
149 | + | |
150 | + Map<String, Object> result = new HashMap<String, Object>(); | |
151 | + result.put("bbsMng", bbsMng); | |
152 | + result.put("bbsTypeList", bbsType); | |
153 | + result.put("pageTypeList", pageType); | |
154 | + | |
155 | + // 응답 처리 | |
156 | + HttpHeaders headers = new HttpHeaders(); | |
157 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
158 | + ResponseData responseData = new ResponseData(); | |
159 | + responseData.setStatus(HttpStatus.OK); | |
160 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
161 | + responseData.setData(result); | |
162 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
163 | + } | |
164 | + | |
165 | + /** | |
166 | + * @author 하석형 | |
167 | + * @since 2024.05.09 | |
168 | + * @param bbsMngVO | |
169 | + * @return | |
170 | + * @throws Exception | |
171 | + * | |
172 | + * 게시판 관리 수정 | |
173 | + */ | |
174 | + @PostMapping("/updateProc.json") | |
175 | + public ResponseEntity<?> updateProc(@RequestBody BbsMngVO bbsMngVO) throws Exception { | |
176 | + HttpHeaders headers = new HttpHeaders(); | |
177 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
178 | + ResponseData responseData = new ResponseData(); | |
179 | + | |
180 | + // 게시판 관리 수정 | |
181 | + int result = bbsMngService.updateBbsMng(bbsMngVO); | |
182 | + | |
183 | + // 응답 처리 | |
184 | + if(result > 0) { | |
185 | + responseData.setStatus(HttpStatus.OK); | |
186 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
187 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
188 | + } else { | |
189 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
190 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
191 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
192 | + } | |
193 | + } | |
194 | + | |
195 | + /** | |
196 | + * @author 하석형 | |
197 | + * @since 2024.05.09 | |
198 | + * @param bbsMngVO | |
199 | + * @return | |
200 | + * @throws Exception | |
201 | + * | |
202 | + * 게시판 관리 삭제 | |
203 | + */ | |
204 | + @PostMapping("/deleteProc.json") | |
205 | + public ResponseEntity<?> deleteProc(@RequestBody BbsMngVO bbsMngVO) throws Exception { | |
206 | + HttpHeaders headers = new HttpHeaders(); | |
207 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
208 | + ResponseData responseData = new ResponseData(); | |
209 | + | |
210 | + // 게시판 관리 수정 | |
211 | + int result = bbsMngService.deleteBbsMng(bbsMngVO); | |
212 | + | |
213 | + // 응답 처리 | |
214 | + if(result > 0) { | |
215 | + responseData.setStatus(HttpStatus.OK); | |
216 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
217 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
218 | + } else { | |
219 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
220 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
221 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
222 | + } | |
223 | + } | |
224 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/bbs/web/BbsTypeMngController.java
... | ... | @@ -0,0 +1,85 @@ |
1 | +package com.takensoft.cms.bbs.web; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.service.BbsTypeMngService; | |
4 | +import com.takensoft.cms.bbs.vo.BbsTypeMngVO; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import org.springframework.http.HttpHeaders; | |
8 | +import org.springframework.http.HttpStatus; | |
9 | +import org.springframework.http.MediaType; | |
10 | +import org.springframework.http.ResponseEntity; | |
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 java.nio.charset.Charset; | |
17 | +import java.util.*; | |
18 | + | |
19 | +/** | |
20 | + * @author : 박정하 | |
21 | + * @since : 2024.05.08 | |
22 | + * | |
23 | + * 게시판 유형 관리 관련 컨트롤러 | |
24 | + */ | |
25 | +@RestController | |
26 | +@RequiredArgsConstructor | |
27 | +@RequestMapping(value="/admin/bbsTypeMng") | |
28 | +public class BbsTypeMngController { | |
29 | + private final BbsTypeMngService bbsTypeMngService; | |
30 | + | |
31 | + /** | |
32 | + * @author 박정하 | |
33 | + * @since 2024.05.08 | |
34 | + * @param bbsTypeMngVO | |
35 | + * @return | |
36 | + * @throws Exception | |
37 | + * | |
38 | + * 게시판 유형 관리 등록 | |
39 | + */ | |
40 | + @PostMapping("/insertBbsTypeMng.json") | |
41 | + public ResponseEntity<?> insertBbsTypeMng(@RequestBody BbsTypeMngVO bbsTypeMngVO) throws Exception { | |
42 | + // 게시판 관리 등록 | |
43 | + HashMap<String, Object> result = bbsTypeMngService.insertBbsTypeMng(bbsTypeMngVO); | |
44 | + int insertResult = (int) result.get("result"); | |
45 | + | |
46 | + // 응답 처리 | |
47 | + HttpHeaders headers = new HttpHeaders(); | |
48 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
49 | + ResponseData responseData = new ResponseData(); | |
50 | + if(insertResult > 0) { | |
51 | + responseData.setStatus(HttpStatus.OK); | |
52 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
53 | + responseData.setData(result); | |
54 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
55 | + } else { | |
56 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
57 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
58 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
59 | + } | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * @author 하석형 | |
64 | + * @since 2024.05.13 | |
65 | + * @param bbsTypeMngVO | |
66 | + * @return | |
67 | + * @throws Exception | |
68 | + * | |
69 | + * 게시판 유형 관리 목록 조회 | |
70 | + */ | |
71 | + @PostMapping("/findAll.json") | |
72 | + public ResponseEntity<?> findAll(@RequestBody BbsTypeMngVO bbsTypeMngVO) throws Exception{ | |
73 | + // 게시판 유형 관리 목록 조회 | |
74 | + Map<String, Object> result = bbsTypeMngService.findAllBbsTypeMng(bbsTypeMngVO); | |
75 | + | |
76 | + // 응답처리 | |
77 | + HttpHeaders headers = new HttpHeaders(); | |
78 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
79 | + ResponseData responseData = new ResponseData(); | |
80 | + responseData.setStatus(HttpStatus.OK); | |
81 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
82 | + responseData.setData(result); | |
83 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
84 | + } | |
85 | +} |
+++ src/main/java/com/takensoft/cms/bbs/web/CmntController.java
... | ... | @@ -0,0 +1,174 @@ |
1 | +package com.takensoft.cms.bbs.web; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.service.CmntService; | |
4 | +import com.takensoft.cms.bbs.vo.CmntVO; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import lombok.extern.slf4j.Slf4j; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.HttpStatus; | |
10 | +import org.springframework.http.MediaType; | |
11 | +import org.springframework.http.ResponseEntity; | |
12 | +import org.springframework.web.bind.annotation.PostMapping; | |
13 | +import org.springframework.web.bind.annotation.RequestBody; | |
14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
15 | +import org.springframework.web.bind.annotation.RestController; | |
16 | + | |
17 | +import java.nio.charset.Charset; | |
18 | +import java.util.HashMap; | |
19 | +import java.util.List; | |
20 | +import java.util.Map; | |
21 | + | |
22 | +/** | |
23 | + * @author : 방선주 | |
24 | + * @since : 2024.05.27 | |
25 | + * | |
26 | + * 게시판 댓글 관련 Controller | |
27 | + */ | |
28 | +@RestController | |
29 | +@RequiredArgsConstructor | |
30 | +@Slf4j | |
31 | +@RequestMapping(value="/sys/cmnt") | |
32 | +public class CmntController { | |
33 | + | |
34 | + private final CmntService cmntService; | |
35 | + | |
36 | + /** | |
37 | + * @author 방선주 | |
38 | + * @since 2024.05.27 | |
39 | + * @param cmntVO | |
40 | + * @return | |
41 | + * @throws Exception | |
42 | + * | |
43 | + * 댓글 등록 | |
44 | + */ | |
45 | + @PostMapping("/saveProc.json") | |
46 | + public ResponseEntity<?> saveProc(@RequestBody CmntVO cmntVO) throws Exception { | |
47 | + // 응답 처리 | |
48 | + HttpHeaders headers = new HttpHeaders(); | |
49 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
50 | + ResponseData responseData = new ResponseData(); | |
51 | + | |
52 | + // 댓글 등록 | |
53 | + | |
54 | + HashMap<String,Object> result = cmntService.saveCmnt(cmntVO); | |
55 | + | |
56 | + int insertResult = (int) result.get("result"); | |
57 | + | |
58 | + if(insertResult > 0) { | |
59 | + responseData.setStatus(HttpStatus.OK); | |
60 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
61 | + responseData.setData(result); | |
62 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
63 | + } else if (insertResult == -1) { | |
64 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
65 | + responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); | |
66 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
67 | + } else if (insertResult == -2){ | |
68 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
69 | + responseData.setMessage("로그인 후 이용 가능합니다."); | |
70 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
71 | + } else { | |
72 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
73 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
74 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
75 | + } | |
76 | + | |
77 | + } | |
78 | + | |
79 | + /** | |
80 | + * @author 방선주 | |
81 | + * @since 2024.05.27 | |
82 | + * @param cmntVO | |
83 | + * @return | |
84 | + * @throws Exception | |
85 | + * | |
86 | + * 댓글 목록 조회 | |
87 | + */ | |
88 | + @PostMapping("/findCmntList.json") | |
89 | + public ResponseEntity<?> findCmntList(@RequestBody CmntVO cmntVO) throws Exception { | |
90 | + // 댓글 목록 조회 | |
91 | + List<CmntVO> cmntList = cmntService.findCmntList(cmntVO.getBbsId()); | |
92 | + | |
93 | + Map<String, Object> result = new HashMap<String, Object>(); | |
94 | + result.put("cmntList", cmntList); | |
95 | + | |
96 | + // 응답처리 | |
97 | + HttpHeaders headers = new HttpHeaders(); | |
98 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
99 | + ResponseData responseData = new ResponseData(); | |
100 | + responseData.setStatus(HttpStatus.OK); | |
101 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
102 | + responseData.setData(result); | |
103 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
104 | + | |
105 | + } | |
106 | + | |
107 | + /** | |
108 | + * @author 방선주 | |
109 | + * @since 2024.05.27 | |
110 | + * @param cmntVO | |
111 | + * @return | |
112 | + * @throws Exception | |
113 | + * | |
114 | + * 댓글 수정 | |
115 | + */ | |
116 | + @PostMapping("/updateProc.json") | |
117 | + public ResponseEntity<?> updateProc(@RequestBody CmntVO cmntVO) throws Exception { | |
118 | +// 응답 처리 | |
119 | + HttpHeaders headers = new HttpHeaders(); | |
120 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
121 | + ResponseData responseData = new ResponseData(); | |
122 | + | |
123 | + // 댓글 수정 | |
124 | + HashMap<String, Object> result = cmntService.updateCmnt(cmntVO); | |
125 | + int updateResult = (int) result.get("result"); | |
126 | + | |
127 | + // 응답처리 | |
128 | + if(updateResult > 0) { | |
129 | + responseData.setStatus(HttpStatus.OK); | |
130 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
131 | + responseData.setData(result); | |
132 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
133 | + } else if (updateResult == -1){ | |
134 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
135 | + responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); | |
136 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
137 | + | |
138 | + } else { | |
139 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
140 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
141 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
142 | + } | |
143 | + | |
144 | + } | |
145 | + /** | |
146 | + * @author 방선주 | |
147 | + * @since 2024.05.27 | |
148 | + * @param cmntVO | |
149 | + * @return | |
150 | + * @throws Exception | |
151 | + * | |
152 | + * 댓글 삭제 | |
153 | + */ | |
154 | + @PostMapping("/deleteProc.json") | |
155 | + public ResponseEntity<?> deleteProc(@RequestBody CmntVO cmntVO) throws Exception { | |
156 | + | |
157 | + // 댓글 삭제 처리 (댓글 삭제는 업데이트로 처리 useYn = 'N') | |
158 | + int result = cmntService.deleteCmnt(cmntVO); | |
159 | + | |
160 | + // 응답처리 | |
161 | + HttpHeaders headers = new HttpHeaders(); | |
162 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
163 | + ResponseData responseData = new ResponseData(); | |
164 | + responseData.setStatus(HttpStatus.OK); | |
165 | + responseData.setMessage("정상적으로 삭제가 처리되었습니다."); | |
166 | + responseData.setData(result); | |
167 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
168 | + | |
169 | + } | |
170 | + | |
171 | + | |
172 | + | |
173 | + | |
174 | +} |
+++ src/main/java/com/takensoft/cms/bbs/web/WordMngController.java
... | ... | @@ -0,0 +1,106 @@ |
1 | +package com.takensoft.cms.bbs.web; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.service.WordMngService; | |
4 | +import com.takensoft.cms.bbs.vo.WordMngVO; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import lombok.extern.slf4j.Slf4j; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.HttpStatus; | |
10 | +import org.springframework.http.MediaType; | |
11 | +import org.springframework.http.ResponseEntity; | |
12 | +import org.springframework.web.bind.annotation.PostMapping; | |
13 | +import org.springframework.web.bind.annotation.RequestBody; | |
14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
15 | +import org.springframework.web.bind.annotation.RestController; | |
16 | + | |
17 | +import java.nio.charset.Charset; | |
18 | +import java.util.HashMap; | |
19 | +import java.util.List; | |
20 | +import java.util.Map; | |
21 | + | |
22 | +/** | |
23 | + * @author : 방선주 | |
24 | + * @since : 2024.05.31 | |
25 | + * | |
26 | + * 금지 단어 관리 Controller | |
27 | + */ | |
28 | + | |
29 | +@RestController | |
30 | +@RequiredArgsConstructor | |
31 | +@Slf4j | |
32 | +@RequestMapping(value="/wordMng") | |
33 | +public class WordMngController { | |
34 | + | |
35 | + private final WordMngService wordMngService; | |
36 | + | |
37 | + /** | |
38 | + * @author 방선주 | |
39 | + * @since 2024.05.09 | |
40 | + * @param wordList | |
41 | + * @return | |
42 | + * @throws Exception | |
43 | + * | |
44 | + * 금지어 추가 | |
45 | + */ | |
46 | + @PostMapping("/saveProc.json") | |
47 | + public ResponseEntity<?> saveProc(@RequestBody HashMap<String, Object> wordList) throws Exception { | |
48 | + // 응답 처리 | |
49 | + HttpHeaders headers = new HttpHeaders(); | |
50 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
51 | + ResponseData responseData = new ResponseData(); | |
52 | + | |
53 | + // 금지어 등록 | |
54 | + int result = wordMngService.saveWords(wordList); | |
55 | + | |
56 | + if(result > 0) { | |
57 | + responseData.setStatus(HttpStatus.OK); | |
58 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
59 | + responseData.setData(result); | |
60 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
61 | + } else { | |
62 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
63 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
64 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
65 | + } | |
66 | + } | |
67 | + @PostMapping("/findAll.json") | |
68 | + public ResponseEntity<?> findAll(@RequestBody HashMap<String, String> params) throws Exception { | |
69 | + // 금지어 목록 조회 | |
70 | + Map<String, Object> result = new HashMap<>(); | |
71 | + HashMap<String, Object> wordsList = wordMngService.findAllWord(params); | |
72 | + | |
73 | + | |
74 | + result.put("words", wordsList); | |
75 | + | |
76 | + // 응답처리 | |
77 | + HttpHeaders headers = new HttpHeaders(); | |
78 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
79 | + ResponseData responseData = new ResponseData(); | |
80 | + responseData.setStatus(HttpStatus.OK); | |
81 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
82 | + responseData.setData(result); | |
83 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
84 | + } | |
85 | + | |
86 | + @PostMapping("/deleteProc.json") | |
87 | + public ResponseEntity<?> deleteProc(@RequestBody HashMap<String, Object> params) throws Exception { | |
88 | + HttpHeaders headers = new HttpHeaders(); | |
89 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
90 | + ResponseData responseData = new ResponseData(); | |
91 | + | |
92 | + // 금지어 삭제 | |
93 | + int result = wordMngService.deleteWords(params); | |
94 | + | |
95 | + // 응답 처리 | |
96 | + if(result > 0) { | |
97 | + responseData.setStatus(HttpStatus.OK); | |
98 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
99 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
100 | + } else { | |
101 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
102 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
103 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
104 | + } | |
105 | + } | |
106 | +} |
+++ src/main/java/com/takensoft/cms/cntnStats/dao/CntnStatsDAO.java
... | ... | @@ -0,0 +1,146 @@ |
1 | +package com.takensoft.cms.cntnStats.dao; | |
2 | + | |
3 | +import com.takensoft.cms.cntnStats.vo.CntnStatsVO; | |
4 | +import com.takensoft.cms.popup.vo.PopupVO; | |
5 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
6 | + | |
7 | +import java.util.HashMap; | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.05.23 | |
13 | + * | |
14 | + * 접속통계 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("cntnStatsDAO") | |
17 | +public interface CntnStatsDAO { | |
18 | + | |
19 | + /** | |
20 | + * @author takensoft | |
21 | + * @since 2024.05.23 | |
22 | + * 사용자 접속 통계 등록 검증 | |
23 | + */ | |
24 | + boolean userCntnStatsSaveChck(CntnStatsVO cntnStatsVO); | |
25 | + | |
26 | + /** | |
27 | + * @author takensoft | |
28 | + * @since 2024.05.23 | |
29 | + * 사용자 접속 통계 등록 | |
30 | + */ | |
31 | + int userCntnStatsSave(CntnStatsVO cntnStatsVO); | |
32 | + | |
33 | + /** | |
34 | + * @author takensoft | |
35 | + * @since 2024.05.23 | |
36 | + * 사용자 접속 통계 수정 | |
37 | + */ | |
38 | + int userCntnStatsUpdate(CntnStatsVO cntnStatsVO); | |
39 | + | |
40 | + /** | |
41 | + * @author takensoft | |
42 | + * @since 2024.05.23 | |
43 | + * 컨텐츠 접속 통계 등록 검증 | |
44 | + */ | |
45 | + boolean contsCntnStatsSaveChck(CntnStatsVO cntnStatsVO); | |
46 | + | |
47 | + /** | |
48 | + * @author takensoft | |
49 | + * @since 2024.05.23 | |
50 | + * 컨텐츠 접속 통계 등록 | |
51 | + */ | |
52 | + int contsCntnStatsSave(CntnStatsVO cntnStatsVO); | |
53 | + | |
54 | + /** | |
55 | + * @author takensoft | |
56 | + * @since 2024.05.23 | |
57 | + * 컨텐츠 접속 통계 수정 | |
58 | + */ | |
59 | + int contsCntnStatsUpdate(CntnStatsVO cntnStatsVO); | |
60 | + | |
61 | + /** | |
62 | + * @author takensoft | |
63 | + * @since 2024.05.23 | |
64 | + * 게시판 접속 통계 등록 검증 | |
65 | + */ | |
66 | + boolean bbsCntnStatsSaveChck(CntnStatsVO cntnStatsVO); | |
67 | + /** | |
68 | + * @author takensoft | |
69 | + * @since 2024.05.23 | |
70 | + * 게시판 접속 통계 등록 | |
71 | + */ | |
72 | + int bbsCntnStatsSave(CntnStatsVO cntnStatsVO); | |
73 | + /** | |
74 | + * @author takensoft | |
75 | + * @since 2024.05.23 | |
76 | + * 컨텐츠 접속 통계 수정 | |
77 | + */ | |
78 | + int bbsCntnStatsUpdate(CntnStatsVO cntnStatsVO); | |
79 | + | |
80 | + /** | |
81 | + * @author takensoft | |
82 | + * @since 2024.05.23 | |
83 | + * 메뉴 접속 통계 등록 검증 | |
84 | + */ | |
85 | + boolean menuCntnStatsSaveChck(CntnStatsVO cntnStatsVO); | |
86 | + /** | |
87 | + * @author takensoft | |
88 | + * @since 2024.05.23 | |
89 | + * 메뉴 접속 통계 등록 | |
90 | + */ | |
91 | + int menuCntnStatsSave(CntnStatsVO cntnStatsVO); | |
92 | + /** | |
93 | + * @author takensoft | |
94 | + * @since 2024.05.23 | |
95 | + * 메뉴 접속 통계 수정 | |
96 | + */ | |
97 | + int menuCntnStatsUpdate(CntnStatsVO cntnStatsVO); | |
98 | + | |
99 | + /** | |
100 | + * @author 박정하 | |
101 | + * @since 2024.05.29 | |
102 | + * | |
103 | + * 사용자 접속 통계 | |
104 | + */ | |
105 | + public List<HashMap<String, Object>> selectUserCntnStats(HashMap<String, Object> params) throws Exception; | |
106 | + | |
107 | + /** | |
108 | + * @author 박정하 | |
109 | + * @since 2024.05.29 | |
110 | + * | |
111 | + * 사용자 접속 통계 총 개수 | |
112 | + */ | |
113 | + public int selectUserCntnStatsCnt(HashMap<String, Object> params) throws Exception; | |
114 | + | |
115 | + /** | |
116 | + * @author 박정하 | |
117 | + * @since 2024.05.30 | |
118 | + * | |
119 | + * 메뉴별 접속 통계 | |
120 | + */ | |
121 | + public List<HashMap<String, Object>> selectMenuCntnStats(HashMap<String, Object> params) throws Exception; | |
122 | + | |
123 | + /** | |
124 | + * @author 박정하 | |
125 | + * @since 2024.05.30 | |
126 | + * | |
127 | + * 메뉴별 접속 통계 총 개수 | |
128 | + */ | |
129 | + public int selectMenuCntnStatsCnt(HashMap<String, Object> params) throws Exception; | |
130 | + | |
131 | + /** | |
132 | + * @author 박정하 | |
133 | + * @since 2024.05.30 | |
134 | + * | |
135 | + * 게시판 접속 통계 | |
136 | + */ | |
137 | + public List<HashMap<String, Object>> selectBbsCntnStats(HashMap<String, Object> params) throws Exception; | |
138 | + | |
139 | + /** | |
140 | + * @author 박정하 | |
141 | + * @since 2024.05.30 | |
142 | + * | |
143 | + * 게시판 접속 통계 총 개수 | |
144 | + */ | |
145 | + public int selectBbsCntnStatsCnt(HashMap<String, Object> params) throws Exception; | |
146 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/cntnStats/dto/CntnStatsDTO.java
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.takensoft.cms.cntnStats.dto; | |
2 | + | |
3 | +import lombok.*; | |
4 | + | |
5 | +import java.util.ArrayList; | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * @author : takensoft | |
10 | + * @since : 2024.05.23 | |
11 | + * | |
12 | + * 접속 통계 관련 DTO | |
13 | + */ | |
14 | +@Setter | |
15 | +@Getter | |
16 | +@AllArgsConstructor | |
17 | +@NoArgsConstructor | |
18 | +@Builder | |
19 | +@ToString | |
20 | +public class CntnStatsDTO { | |
21 | + /** | |
22 | + * 타입 아이디 | |
23 | + */ | |
24 | + private String typeId; | |
25 | + /** | |
26 | + * 권한 목록 | |
27 | + */ | |
28 | + private List<String> mbrAuthList = new ArrayList<String>(); | |
29 | +} |
+++ src/main/java/com/takensoft/cms/cntnStats/dto/CntnStatsExcelDTO.java
... | ... | @@ -0,0 +1,42 @@ |
1 | +package com.takensoft.cms.cntnStats.dto; | |
2 | + | |
3 | +import com.takensoft.common.excel.annotation.ExcelColumnName; | |
4 | +import com.takensoft.common.excel.annotation.ExcelFileName; | |
5 | +import lombok.Builder; | |
6 | +import lombok.Getter; | |
7 | +import lombok.NoArgsConstructor; | |
8 | +import lombok.Setter; | |
9 | +import javax.persistence.*; | |
10 | + | |
11 | +@Entity | |
12 | +@Getter | |
13 | +@Setter | |
14 | +@NoArgsConstructor | |
15 | +@ExcelFileName(fileName="게시판 접속 통계") | |
16 | +public class CntnStatsExcelDTO { | |
17 | + @Id | |
18 | + @Column | |
19 | + @GeneratedValue(strategy = GenerationType.IDENTITY) | |
20 | + @ExcelColumnName(headerName = "구분") | |
21 | + private String date; | |
22 | + | |
23 | + @Column | |
24 | + @ExcelColumnName(headerName = "관리자") | |
25 | + private int admin; | |
26 | + | |
27 | + @Column | |
28 | + @ExcelColumnName(headerName = "사용자") | |
29 | + private int user; | |
30 | + | |
31 | + @Column | |
32 | + @ExcelColumnName(headerName = "비로그인 사용자") | |
33 | + private int none; | |
34 | + | |
35 | + @Builder | |
36 | + public CntnStatsExcelDTO(String date, int admin, int user, int none) { | |
37 | + this.date = date; | |
38 | + this.admin = admin; | |
39 | + this.user = user; | |
40 | + this.none = none; | |
41 | + } | |
42 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/cntnStats/service/CntnStatsService.java
... | ... | @@ -0,0 +1,49 @@ |
1 | +package com.takensoft.cms.cntnStats.service; | |
2 | + | |
3 | +import com.takensoft.cms.cntnStats.dto.CntnStatsDTO; | |
4 | +import com.takensoft.cms.popup.vo.PopupVO; | |
5 | + | |
6 | +import java.util.HashMap; | |
7 | +import java.util.List; | |
8 | +import java.util.Map; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.05.23 | |
13 | + * | |
14 | + * 접속통계 관련 인터페이스 | |
15 | + */ | |
16 | +public interface CntnStatsService { | |
17 | + | |
18 | + /** | |
19 | + * @author : takensoft | |
20 | + * @since : 2024.05.23 | |
21 | + * | |
22 | + * 접속 통계 등록 | |
23 | + */ | |
24 | + public int cntnStatsSave(CntnStatsDTO cntnStatsDTO) throws Exception; | |
25 | + | |
26 | + /** | |
27 | + * @author 박정하 | |
28 | + * @since 2024.05.29 | |
29 | + * | |
30 | + * 사용자 접속 통계 | |
31 | + */ | |
32 | + public HashMap<String, Object> userCntnStatsSelect(HashMap<String, Object> params) throws Exception; | |
33 | + | |
34 | + /** | |
35 | + * @author 박정하 | |
36 | + * @since 2024.05.30 | |
37 | + * | |
38 | + * 메뉴별 접속 통계 | |
39 | + */ | |
40 | + public HashMap<String, Object> menuCntnStatsSelect(HashMap<String, Object> params) throws Exception; | |
41 | + | |
42 | + /** | |
43 | + * @author 박정하 | |
44 | + * @since 2024.05.30 | |
45 | + * | |
46 | + * 게시판 접속 통계 | |
47 | + */ | |
48 | + public HashMap<String, Object> bbsCntnStatsSelect(HashMap<String, Object> params) throws Exception; | |
49 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/cntnStats/service/Impl/CntnStatsServiceImpl.java
... | ... | @@ -0,0 +1,207 @@ |
1 | +package com.takensoft.cms.cntnStats.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.BbsMngDAO; | |
4 | +import com.takensoft.cms.cntnStats.dao.CntnStatsDAO; | |
5 | +import com.takensoft.cms.cntnStats.dto.CntnStatsDTO; | |
6 | +import com.takensoft.cms.cntnStats.service.CntnStatsService; | |
7 | +import com.takensoft.cms.cntnStats.vo.CntnStatsVO; | |
8 | +import com.takensoft.cms.menu.dao.MenuDAO; | |
9 | +import lombok.RequiredArgsConstructor; | |
10 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
11 | +import org.slf4j.Logger; | |
12 | +import org.slf4j.LoggerFactory; | |
13 | +import org.springframework.stereotype.Service; | |
14 | +import org.springframework.transaction.annotation.Transactional; | |
15 | + | |
16 | +import java.time.LocalDate; | |
17 | +import java.util.*; | |
18 | + | |
19 | +/** | |
20 | + * @author : takensoft | |
21 | + * @since : 2024.05.23 | |
22 | + * | |
23 | + * 접속통계 관련 구현체 | |
24 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
25 | + * CntnStatsService : 접속 통계 관련 인터페이스 상속 | |
26 | + */ | |
27 | +@Service("cntnStatsService") | |
28 | +@RequiredArgsConstructor | |
29 | +public class CntnStatsServiceImpl extends EgovAbstractServiceImpl implements CntnStatsService { | |
30 | + | |
31 | + private static final Logger LOGGER = LoggerFactory.getLogger(CntnStatsServiceImpl.class); | |
32 | + private final CntnStatsDAO cntnStatsDAO; | |
33 | + private final BbsMngDAO bbsMngDAO; | |
34 | + private final MenuDAO menuDAO; | |
35 | + | |
36 | + /** | |
37 | + * @author : takensoft | |
38 | + * @since : 2024.05.23 | |
39 | + * | |
40 | + * 접속 통계 등록 | |
41 | + */ | |
42 | + @Override | |
43 | + @Transactional(rollbackFor = Exception.class) | |
44 | + public int cntnStatsSave(CntnStatsDTO cntnStatsDTO) throws Exception { | |
45 | + LocalDate date = LocalDate.now(); // 오늘 금일 날짜 출력 | |
46 | + CntnStatsVO vo = new CntnStatsVO(); // 접속 통계 객체 생성 | |
47 | + | |
48 | + vo.setCntnYr(String.valueOf(date.getYear())); // 년도 추출 | |
49 | + vo.setCntnMm(String.format("%02d", date.getMonthValue())); // 월 추출 | |
50 | + vo.setCntnDay(String.format("%02d", date.getDayOfMonth())); // 일 추출 | |
51 | + | |
52 | + int result = 0; | |
53 | + | |
54 | + // 사용자 접속 통계 생성 | |
55 | + if(cntnStatsDTO.getTypeId() == null || cntnStatsDTO.getTypeId().equals("")) { | |
56 | + result += userCntnStatsSave(vo, cntnStatsDTO); | |
57 | + // 메뉴 접속 통계 생성 | |
58 | + } else if(cntnStatsDTO.getTypeId().contains("MENU")) { | |
59 | + result += menuCntnStatsSave(vo, cntnStatsDTO); | |
60 | + // 게시판 접속 통계 생성 | |
61 | + } else if(cntnStatsDTO.getTypeId().contains("BBS")) { | |
62 | + result += bbsCntnStatsSave(vo, cntnStatsDTO); | |
63 | + // 콘텐츠 접속 통게 생성 | |
64 | + } else if(cntnStatsDTO.getTypeId().contains("CONTS")) { | |
65 | + result += contsCntnStatsSave(vo, cntnStatsDTO); | |
66 | + } | |
67 | + | |
68 | + return result; | |
69 | + } | |
70 | + | |
71 | + /** | |
72 | + * @author takensoft | |
73 | + * @since 2024.05.23 | |
74 | + * 사용자 접속 통계 등록 | |
75 | + */ | |
76 | + private int userCntnStatsSave(CntnStatsVO cntnStatsVO, CntnStatsDTO cntnStatsDTO) throws Exception { | |
77 | + int result = 0; | |
78 | + for(String auth : cntnStatsDTO.getMbrAuthList()) { | |
79 | + cntnStatsVO.setAuthrtCd(auth); | |
80 | + boolean chck = cntnStatsDAO.userCntnStatsSaveChck(cntnStatsVO); | |
81 | + // 카운트 증가 | |
82 | + if(chck) { | |
83 | + result += cntnStatsDAO.userCntnStatsUpdate(cntnStatsVO); | |
84 | + // 신규 등록 | |
85 | + } else { | |
86 | + result += cntnStatsDAO.userCntnStatsSave(cntnStatsVO); | |
87 | + } | |
88 | + } | |
89 | + return result; | |
90 | + }; | |
91 | + | |
92 | + /** | |
93 | + * @author takensoft | |
94 | + * @since 2024.05.23 | |
95 | + * 컨텐츠 접속 통계 등록 | |
96 | + */ | |
97 | + private int contsCntnStatsSave(CntnStatsVO cntnStatsVO, CntnStatsDTO cntnStatsDTO)throws Exception { | |
98 | + int result = 0; | |
99 | + for(String auth : cntnStatsDTO.getMbrAuthList()) { | |
100 | + cntnStatsVO.setAuthrtCd(auth); | |
101 | + cntnStatsVO.setTypeId(cntnStatsDTO.getTypeId()); | |
102 | + boolean chck = cntnStatsDAO.contsCntnStatsSaveChck(cntnStatsVO); | |
103 | + // 카운트 증가 | |
104 | + if(chck) { | |
105 | + result += cntnStatsDAO.contsCntnStatsUpdate(cntnStatsVO); | |
106 | + // 신규 등록 | |
107 | + } else { | |
108 | + result += cntnStatsDAO.contsCntnStatsSave(cntnStatsVO); | |
109 | + } | |
110 | + } | |
111 | + return result; | |
112 | + }; | |
113 | + | |
114 | + /** | |
115 | + * @author takensoft | |
116 | + * @since 2024.05.23 | |
117 | + * 게시판 접속 통계 등록 | |
118 | + */ | |
119 | + private int bbsCntnStatsSave(CntnStatsVO cntnStatsVO, CntnStatsDTO cntnStatsDTO)throws Exception { | |
120 | + int result = 0; | |
121 | + for(String auth : cntnStatsDTO.getMbrAuthList()) { | |
122 | + cntnStatsVO.setAuthrtCd(auth); | |
123 | + cntnStatsVO.setTypeId(cntnStatsDTO.getTypeId()); | |
124 | + boolean chck = cntnStatsDAO.bbsCntnStatsSaveChck(cntnStatsVO); | |
125 | + // 카운트 증가 | |
126 | + if(chck) { | |
127 | + result += cntnStatsDAO.bbsCntnStatsUpdate(cntnStatsVO); | |
128 | + // 신규 등록 | |
129 | + } else { | |
130 | + result += cntnStatsDAO.bbsCntnStatsSave(cntnStatsVO); | |
131 | + } | |
132 | + } | |
133 | + return result; | |
134 | + }; | |
135 | + | |
136 | + /** | |
137 | + * @author takensoft | |
138 | + * @since 2024.05.23 | |
139 | + * 메뉴 접속 통계 등록 | |
140 | + */ | |
141 | + private int menuCntnStatsSave(CntnStatsVO cntnStatsVO, CntnStatsDTO cntnStatsDTO)throws Exception { | |
142 | + int result = 0; | |
143 | + for(String auth : cntnStatsDTO.getMbrAuthList()) { | |
144 | + cntnStatsVO.setAuthrtCd(auth); | |
145 | + cntnStatsVO.setTypeId(cntnStatsDTO.getTypeId()); | |
146 | + boolean chck = cntnStatsDAO.menuCntnStatsSaveChck(cntnStatsVO); | |
147 | + // 카운트 증가 | |
148 | + if(chck) { | |
149 | + result += cntnStatsDAO.menuCntnStatsUpdate(cntnStatsVO); | |
150 | + // 신규 등록 | |
151 | + } else { | |
152 | + result += cntnStatsDAO.menuCntnStatsSave(cntnStatsVO); | |
153 | + } | |
154 | + } | |
155 | + return result; | |
156 | + }; | |
157 | + | |
158 | + /** | |
159 | + * @author 박정하 | |
160 | + * @since 2024.05.29 | |
161 | + * | |
162 | + * 사용자 접속 통계 | |
163 | + */ | |
164 | + @Override | |
165 | + public HashMap<String, Object> userCntnStatsSelect(HashMap<String, Object> params) throws Exception { | |
166 | + HashMap<String, Object> result = new HashMap<>(); | |
167 | + result.put("list", cntnStatsDAO.selectUserCntnStats(params)); | |
168 | + result.put("totalCnt", cntnStatsDAO.selectUserCntnStatsCnt(params)); | |
169 | + return result; | |
170 | + }; | |
171 | + | |
172 | + /** | |
173 | + * @author 박정하 | |
174 | + * @since 2024.05.30 | |
175 | + * | |
176 | + * 메뉴별 접속 통계 | |
177 | + */ | |
178 | + @Override | |
179 | + public HashMap<String, Object> menuCntnStatsSelect(HashMap<String, Object> params) throws Exception { | |
180 | + HashMap<String, Object> result = new HashMap<>(); | |
181 | + int menuCnt = menuDAO.findAllCnt(params); | |
182 | + result.put("menuCnt", menuCnt); | |
183 | + if (menuCnt > 0) { | |
184 | + result.put("list", cntnStatsDAO.selectMenuCntnStats(params)); | |
185 | + result.put("totalCnt", cntnStatsDAO.selectMenuCntnStatsCnt(params)); | |
186 | + } | |
187 | + return result; | |
188 | + } | |
189 | + | |
190 | + /** | |
191 | + * @author 박정하 | |
192 | + * @since 2024.05.30 | |
193 | + * | |
194 | + * 게시판 접속 통계 | |
195 | + */ | |
196 | + @Override | |
197 | + public HashMap<String, Object> bbsCntnStatsSelect(HashMap<String, Object> params) throws Exception { | |
198 | + HashMap<String, Object> result = new HashMap<>(); | |
199 | + int bbsCnt = bbsMngDAO.findAllCntNotPagination(); | |
200 | + result.put("bbsCnt", bbsCnt); | |
201 | + if (bbsCnt > 0) { | |
202 | + result.put("list", cntnStatsDAO.selectBbsCntnStats(params)); | |
203 | + result.put("totalCnt", cntnStatsDAO.selectBbsCntnStatsCnt(params)); | |
204 | + } | |
205 | + return result; | |
206 | + } | |
207 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/cntnStats/vo/CntnStatsVO.java
... | ... | @@ -0,0 +1,39 @@ |
1 | +package com.takensoft.cms.cntnStats.vo; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import lombok.Setter; | |
7 | + | |
8 | +/** | |
9 | + * @author : takensoft | |
10 | + * @since : 2024.05.23 | |
11 | + * | |
12 | + * 접속 통계 관련 VO | |
13 | + */ | |
14 | +@Setter | |
15 | +@Getter | |
16 | +@NoArgsConstructor | |
17 | +@AllArgsConstructor | |
18 | +public class CntnStatsVO { | |
19 | + /** | |
20 | + * 타입 아이디 (게시판/콘텐츠/메뉴) | |
21 | + */ | |
22 | + private String typeId; | |
23 | + /** | |
24 | + * 권한 코드 | |
25 | + */ | |
26 | + private String authrtCd; | |
27 | + /** | |
28 | + * 접속 년도 | |
29 | + */ | |
30 | + private String cntnYr; | |
31 | + /** | |
32 | + * 접속 월 | |
33 | + */ | |
34 | + private String cntnMm; | |
35 | + /** | |
36 | + * 접속 일 | |
37 | + */ | |
38 | + private String cntnDay; | |
39 | +} |
+++ src/main/java/com/takensoft/cms/cntnStats/web/CntnStatsController.java
... | ... | @@ -0,0 +1,148 @@ |
1 | +package com.takensoft.cms.cntnStats.web; | |
2 | + | |
3 | +import com.takensoft.cms.cntnStats.dto.CntnStatsDTO; | |
4 | +import com.takensoft.cms.cntnStats.dto.CntnStatsExcelDTO; | |
5 | +import com.takensoft.cms.cntnStats.service.CntnStatsService; | |
6 | +import com.takensoft.common.excel.service.ExcelService; | |
7 | +import com.takensoft.common.util.ResponseData; | |
8 | +import lombok.RequiredArgsConstructor; | |
9 | +import lombok.extern.slf4j.Slf4j; | |
10 | +import org.springframework.http.HttpHeaders; | |
11 | +import org.springframework.http.HttpStatus; | |
12 | +import org.springframework.http.MediaType; | |
13 | +import org.springframework.http.ResponseEntity; | |
14 | +import org.springframework.web.bind.annotation.*; | |
15 | + | |
16 | +import javax.servlet.http.HttpServletResponse; | |
17 | +import java.nio.charset.Charset; | |
18 | +import java.util.*; | |
19 | + | |
20 | +/** | |
21 | + * @author : takensoft | |
22 | + * @since : 2024.05.23 | |
23 | + * | |
24 | + * 접속 통계 관련 컨트롤러 | |
25 | + */ | |
26 | +@RestController | |
27 | +@RequiredArgsConstructor | |
28 | +@Slf4j | |
29 | +@RequestMapping(value = "/sys/cntnStats") | |
30 | +public class CntnStatsController { | |
31 | + private final CntnStatsService cntnStatsService; | |
32 | + private final ExcelService excelService; | |
33 | + | |
34 | + /** | |
35 | + * @author takensoft | |
36 | + * @since 2024.05.23 | |
37 | + * @param cntnStatsDTO | |
38 | + * @return | |
39 | + * @throws Exception | |
40 | + * | |
41 | + * 접속 통게 등록 | |
42 | + */ | |
43 | + @PostMapping("/saveProc.json") | |
44 | + public ResponseEntity<?> saveProc(@RequestBody CntnStatsDTO cntnStatsDTO) throws Exception { | |
45 | + int result = cntnStatsService.cntnStatsSave(cntnStatsDTO); | |
46 | + | |
47 | + // 응답 처리 | |
48 | + HttpHeaders headers = new HttpHeaders(); | |
49 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
50 | + ResponseData responseData = new ResponseData(); | |
51 | + if(result > 0) { | |
52 | + responseData.setStatus(HttpStatus.OK); | |
53 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
54 | + responseData.setData(result); | |
55 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
56 | + } else { | |
57 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
58 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
59 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
60 | + } | |
61 | + } | |
62 | + | |
63 | + /** | |
64 | + * @author 박정하 | |
65 | + * @since 2024.05.29 | |
66 | + * @param | |
67 | + * @return | |
68 | + * @throws Exception | |
69 | + * | |
70 | + * 사용자 접속 통계 | |
71 | + */ | |
72 | + @PostMapping("/selectUserCntnStatsProc.json") | |
73 | + public ResponseEntity<?> selectUserCntnStatsProc(@RequestBody HashMap<String, Object> params) throws Exception { | |
74 | + // 사용자 접속 통계 조회 | |
75 | + HashMap<String, Object> result = cntnStatsService.userCntnStatsSelect(params); | |
76 | + | |
77 | + // 응답 처리 | |
78 | + HttpHeaders headers = new HttpHeaders(); | |
79 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
80 | + ResponseData responseData = new ResponseData(); | |
81 | + responseData.setStatus(HttpStatus.OK); | |
82 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
83 | + responseData.setData(result); | |
84 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
85 | + } | |
86 | + | |
87 | + /** | |
88 | + * @author 박정하 | |
89 | + * @since 2024.05.30 | |
90 | + * @param | |
91 | + * @return | |
92 | + * @throws Exception | |
93 | + * | |
94 | + * 메뉴별 접속 통계 | |
95 | + */ | |
96 | + @PostMapping("/selectMenuCntnStatsProc.json") | |
97 | + public ResponseEntity<?> selectMenuCntnStatsProc(@RequestBody HashMap<String, Object> params) throws Exception { | |
98 | + // 메뉴별 접속 통계 조회 | |
99 | + HashMap<String, Object> result = cntnStatsService.menuCntnStatsSelect(params); | |
100 | + | |
101 | + // 응답 처리 | |
102 | + HttpHeaders headers = new HttpHeaders(); | |
103 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
104 | + ResponseData responseData = new ResponseData(); | |
105 | + responseData.setStatus(HttpStatus.OK); | |
106 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
107 | + responseData.setData(result); | |
108 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
109 | + } | |
110 | + | |
111 | + /** | |
112 | + * @author 박정하 | |
113 | + * @since 2024.05.30 | |
114 | + * @param | |
115 | + * @return | |
116 | + * @throws Exception | |
117 | + * | |
118 | + * 게시판 접속 통계 | |
119 | + */ | |
120 | + @PostMapping("/selectBbsCntnStatsProc.json") | |
121 | + public ResponseEntity<?> selectBbsCntnStatsProc(@RequestBody HashMap<String, Object> params) throws Exception { | |
122 | + // 게시판 접속 통계 조회 | |
123 | + HashMap<String, Object> result = cntnStatsService.bbsCntnStatsSelect(params); | |
124 | + | |
125 | + // 응답 처리 | |
126 | + HttpHeaders headers = new HttpHeaders(); | |
127 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
128 | + ResponseData responseData = new ResponseData(); | |
129 | + responseData.setStatus(HttpStatus.OK); | |
130 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
131 | + responseData.setData(result); | |
132 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
133 | + } | |
134 | + | |
135 | + /** | |
136 | + * @author 박정하 | |
137 | + * @since 2024.05.30 | |
138 | + * @param | |
139 | + * @return | |
140 | + * @throws Exception | |
141 | + * | |
142 | + * 접속 통계 엑셀 다운로드 | |
143 | + */ | |
144 | + @PostMapping("/excelDownload.file") | |
145 | + public void excelDownload(HttpServletResponse response, @RequestPart List<CntnStatsExcelDTO> cntnStats, @RequestPart String chart) throws Exception { | |
146 | + excelService.cntnStatsExcelDownload(response, cntnStats, chart); | |
147 | + } | |
148 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/codeManage/dao/CodeManageDAO.java
... | ... | @@ -0,0 +1,116 @@ |
1 | +package com.takensoft.cms.codeManage.dao; | |
2 | + | |
3 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
4 | +import com.takensoft.cms.dept.vo.DeptVO; | |
5 | +import com.takensoft.common.HierachyVO; | |
6 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.04.09 | |
13 | + * | |
14 | + * 공통코드 정보 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("codeManageDAO") | |
17 | +public interface CodeManageDAO { | |
18 | + /** | |
19 | + * @author takensoft | |
20 | + * @since 2024.04.09 | |
21 | + * 공통 코드 중복 검사 | |
22 | + */ | |
23 | + boolean findByCheckCd(CodeManageVO codeManageVO); | |
24 | + | |
25 | + /** | |
26 | + * @author takensoft | |
27 | + * @since 2024.04.09 | |
28 | + * 코드 등록 | |
29 | + */ | |
30 | + int save(CodeManageVO codeManageVO); | |
31 | + | |
32 | + /** | |
33 | + * @author takensoft | |
34 | + * @since 2024.04.15 | |
35 | + * 코드 수정 | |
36 | + */ | |
37 | + int update(CodeManageVO codeManageVO); | |
38 | + | |
39 | + /** | |
40 | + * @author takensoft | |
41 | + * @since 2024.04.26 | |
42 | + * 상위코드가 수정됨에 따라 하위코드의 상위코드값 변경 | |
43 | + */ | |
44 | + int updateUpCd(CodeManageVO codeManageVO); | |
45 | + | |
46 | + /** | |
47 | + * @author takensoft | |
48 | + * @since 2024.04.09 | |
49 | + * 코드 깊이 조회 | |
50 | + */ | |
51 | + int findByCdGrd(String upCd); | |
52 | + | |
53 | + /** | |
54 | + * @author takensoft | |
55 | + * @since 2024.04.09 | |
56 | + * 코드 순서 조회 | |
57 | + */ | |
58 | + int findByCdSn(String upCd); | |
59 | + | |
60 | + /** | |
61 | + * @author takensoft | |
62 | + * @since 2024.04.09 | |
63 | + * 최상위 코드 조회 | |
64 | + */ | |
65 | + List<CodeManageVO> findTopCd(); | |
66 | + | |
67 | + /** | |
68 | + * @author takensoft | |
69 | + * @since 2024.04.09 | |
70 | + * 하위 코드 조회[관리자용] | |
71 | + */ | |
72 | + List<CodeManageVO> findChildCd(String cd); | |
73 | + | |
74 | + /** | |
75 | + * @author takensoft | |
76 | + * @since 2024.04.09 | |
77 | + * 하위 코드 조회[사용자용] | |
78 | + */ | |
79 | + List<CodeManageVO> findChildCdUser(String cd); | |
80 | + | |
81 | + /** | |
82 | + * @author takensoft | |
83 | + * @since 2024.04.09 | |
84 | + * 코드 상세 조회 | |
85 | + */ | |
86 | + CodeManageVO findByCd(String cd); | |
87 | + | |
88 | + /** | |
89 | + * @author takensoft | |
90 | + * @since 2024.04.23 | |
91 | + * 코드 삭제 | |
92 | + */ | |
93 | + int deleteCd(String cd); | |
94 | + | |
95 | + /************************************** Hierachy 전용 **************************************/ | |
96 | + /** | |
97 | + * @author takensoft | |
98 | + * @since 2024.04.24 | |
99 | + * 최상위 코드 조회 | |
100 | + */ | |
101 | + List<HierachyVO> findByTopNode(); | |
102 | + /** | |
103 | + * @author takensoft | |
104 | + * @since 2024.04.24 | |
105 | + * 하위 코드 조회 | |
106 | + */ | |
107 | + List<HierachyVO> findChildNode(String id); | |
108 | + /************************************** Hierachy 전용 **************************************/ | |
109 | + | |
110 | + /** | |
111 | + * @author 박정하 | |
112 | + * @since 2024.05.10 | |
113 | + * 공통 코드 목록 정보 수정 (hierachyVO 사용) | |
114 | + */ | |
115 | + public int codeUpdateByHierachy(CodeManageVO codeManageVO) throws Exception; | |
116 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/codeManage/service/CodeManageService.java
... | ... | @@ -0,0 +1,106 @@ |
1 | +package com.takensoft.cms.codeManage.service; | |
2 | + | |
3 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
4 | +import com.takensoft.cms.dept.vo.DeptVO; | |
5 | +import com.takensoft.common.HierachyVO; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : takensoft | |
11 | + * @since : 2024.04.09 | |
12 | + * | |
13 | + * 공통코드 정보 관련 인터페이스 | |
14 | + */ | |
15 | +public interface CodeManageService { | |
16 | + /** | |
17 | + * @author takensoft | |
18 | + * @since 2024.04.09 | |
19 | + * 코드 중복 검사 | |
20 | + */ | |
21 | + public boolean findByCheckCd(CodeManageVO codeManageVO) throws Exception; | |
22 | + | |
23 | + /** | |
24 | + * @author takensoft | |
25 | + * @since 2024.04.09 | |
26 | + * 코드 등록 | |
27 | + */ | |
28 | + public int cdSave(CodeManageVO codeManageVO) throws Exception; | |
29 | + | |
30 | + /** | |
31 | + * @author takensoft | |
32 | + * @since 2024.04.15 | |
33 | + * 코드 수정 | |
34 | + */ | |
35 | + public int cdUpdate(CodeManageVO codeManageVO) throws Exception; | |
36 | + | |
37 | + /** | |
38 | + * @author takensoft | |
39 | + * @since 2024.04.09 | |
40 | + * 전체 코드 조회 [관리자용 ] | |
41 | + */ | |
42 | + public List<CodeManageVO> findTopCd() throws Exception; | |
43 | + | |
44 | + /** | |
45 | + * @author takensoft | |
46 | + * @since 2024.04.09 | |
47 | + * 하위 코드 조회 | |
48 | + */ | |
49 | + public List<CodeManageVO> findByChildCd(String cd) throws Exception; | |
50 | + | |
51 | + /** | |
52 | + * @author takensoft | |
53 | + * @since 2024.04.09 | |
54 | + * 코드 상세 조회 | |
55 | + */ | |
56 | + public CodeManageVO findByCd(String cd) throws Exception; | |
57 | + | |
58 | + /** | |
59 | + * @author takensoft | |
60 | + * @since 2024.04.15 | |
61 | + * 특정 공통 목록 코드 조회(시스템 처리용) | |
62 | + */ | |
63 | + public CodeManageVO findByCdSystem(String cd) throws Exception; | |
64 | + | |
65 | + /** | |
66 | + * @author takensoft | |
67 | + * @since 2024.04.19 | |
68 | + * 하위 코드 조회(cache) | |
69 | + */ | |
70 | + public List<CodeManageVO> findByChildCdCache(String cd) throws Exception; | |
71 | + | |
72 | + /** | |
73 | + * @author takensoft | |
74 | + * @since 2024.04.23 | |
75 | + * 코드 삭제 | |
76 | + */ | |
77 | + public int cdDelete(String cd) throws Exception; | |
78 | + | |
79 | + /************************************** Hierachy 전용 **************************************/ | |
80 | + /** | |
81 | + * @author takensoft | |
82 | + * @since 2024.04.24 | |
83 | + * 최상위 코드 조회 | |
84 | + */ | |
85 | + public List<HierachyVO> findByTopNode(); | |
86 | + /** | |
87 | + * @author takensoft | |
88 | + * @since 2024.04.24 | |
89 | + * 하위 코드 조회 | |
90 | + */ | |
91 | + public List<HierachyVO> findChildNode(String id); | |
92 | + /************************************** Hierachy 전용 **************************************/ | |
93 | + | |
94 | + /** | |
95 | + * @author 박정하 | |
96 | + * @since 2024.05.10 | |
97 | + * 공통 코드 목록 수정 | |
98 | + */ | |
99 | + public int updateList(List<HierachyVO> deptList) throws Exception; | |
100 | + /** | |
101 | + * @author 박정하 | |
102 | + * @since 2024.05.10 | |
103 | + * 하위 코드 수정 | |
104 | + */ | |
105 | + public int updateChildNode(List<HierachyVO> childList, CodeManageVO upCodeManageVO) throws Exception; | |
106 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/codeManage/service/Impl/CodeManageServiceImpl.java
... | ... | @@ -0,0 +1,256 @@ |
1 | +package com.takensoft.cms.codeManage.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.codeManage.dao.CodeManageDAO; | |
4 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
5 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
6 | +import com.takensoft.cms.dept.vo.DeptVO; | |
7 | +import com.takensoft.common.util.JWTUtil; | |
8 | +import com.takensoft.common.HierachyVO; | |
9 | +import lombok.RequiredArgsConstructor; | |
10 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
11 | +import org.slf4j.Logger; | |
12 | +import org.slf4j.LoggerFactory; | |
13 | +import org.springframework.cache.annotation.Cacheable; | |
14 | +import org.springframework.stereotype.Service; | |
15 | +import org.springframework.transaction.annotation.Transactional; | |
16 | + | |
17 | +import java.util.List; | |
18 | + | |
19 | +/** | |
20 | + * @author : takensoft | |
21 | + * @since : 2024.04.09 | |
22 | + * | |
23 | + * 공통코드 정보 관련 구현체 | |
24 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
25 | + * AuthorService : 공통코드 정보 인터페이스 상속 | |
26 | + */ | |
27 | +@Service("codeManageService") | |
28 | +@RequiredArgsConstructor | |
29 | +public class CodeManageServiceImpl extends EgovAbstractServiceImpl implements CodeManageService { | |
30 | + | |
31 | + private static final Logger LOGGER = LoggerFactory.getLogger(CodeManageServiceImpl.class); | |
32 | + private final JWTUtil jwtUtil; | |
33 | + private final CodeManageDAO codeManageDAO; | |
34 | + | |
35 | + /** | |
36 | + * @author takensoft | |
37 | + * @since 2024.04.09 | |
38 | + * 코드 중복 검사 | |
39 | + */ | |
40 | + @Override | |
41 | + public boolean findByCheckCd(CodeManageVO codeManageVO) throws Exception { | |
42 | + return codeManageDAO.findByCheckCd(codeManageVO); | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * @author takensoft | |
47 | + * @since 2024.04.09 | |
48 | + * 코드 등록 | |
49 | + */ | |
50 | + @Override | |
51 | + public int cdSave(CodeManageVO codeManageVO) throws Exception { | |
52 | + // 상위 코드가 존재 하는 경우 | |
53 | + if(codeManageVO.getUpCd() != null && !codeManageVO.getUpCd().equals("")) { | |
54 | + // 상위 메뉴 아이디 보다 깊이(레벨) 1 추가 | |
55 | + codeManageVO.setCdGrd(codeManageDAO.findByCdGrd(codeManageVO.getUpCd()) + 1); | |
56 | + // 동일한 깊이의 코드 순서 보다 1 추가 | |
57 | + codeManageVO.setCdSn(codeManageDAO.findByCdSn(codeManageVO.getUpCd()) + 1); | |
58 | + // 상위 코드가 존재 하지 않는 경우 | |
59 | + } else { | |
60 | + codeManageVO.setCdGrd(0); | |
61 | + codeManageVO.setCdSn(codeManageDAO.findByCdSn(null) + 1); | |
62 | + } | |
63 | + // 등록된 토큰에서 사용자 정보 조회 | |
64 | + codeManageVO.setRgtr(jwtUtil.getWriter()); | |
65 | + return codeManageDAO.save(codeManageVO); | |
66 | + } | |
67 | + | |
68 | + /** | |
69 | + * @author takensoft | |
70 | + * @since 2024.04.15 | |
71 | + * 코드 수정 | |
72 | + */ | |
73 | + @Override | |
74 | + public int cdUpdate(CodeManageVO codeManageVO) throws Exception { | |
75 | + // 등록된 토큰에서 사용자 정보 조회 | |
76 | + codeManageVO.setMdfr(jwtUtil.getWriter()); | |
77 | + // 코드 수정 | |
78 | + int result = codeManageDAO.update(codeManageVO); | |
79 | + // 해당 코드가 변경됨에 따라 하위 코드의 상위코드값 변경 | |
80 | + result += codeManageDAO.updateUpCd(codeManageVO); | |
81 | + return result; | |
82 | + } | |
83 | + | |
84 | + /** | |
85 | + * @author takensoft | |
86 | + * @since 2024.04.09 | |
87 | + * 전체 코드 조회 [관리자용 ] | |
88 | + */ | |
89 | + @Override | |
90 | + public List<CodeManageVO> findTopCd() throws Exception { | |
91 | + // 상위 코드 조회 | |
92 | + List<CodeManageVO> topCdList = codeManageDAO.findTopCd(); | |
93 | + // 상위 코드에 따른 하위 코드 조회 | |
94 | + for(CodeManageVO codeManage : topCdList) { | |
95 | + List<CodeManageVO> childCd = findByChildCd(codeManage.getCd()); | |
96 | + codeManage.setChildCdList(childCd); | |
97 | + } | |
98 | + return topCdList; | |
99 | + } | |
100 | + | |
101 | + /** | |
102 | + * @author takensoft | |
103 | + * @since 2024.04.09 | |
104 | + * 하위 코드 조회 | |
105 | + */ | |
106 | + @Override | |
107 | + public List<CodeManageVO> findByChildCd(String cd) throws Exception { | |
108 | + List<CodeManageVO> childCdList = codeManageDAO.findChildCd(cd); | |
109 | + for(CodeManageVO codeManage : childCdList) { | |
110 | + List<CodeManageVO> childCd = findByChildCd(codeManage.getCd()); | |
111 | + codeManage.setChildCdList(childCd); | |
112 | + } | |
113 | + return childCdList; | |
114 | + } | |
115 | + | |
116 | + /** | |
117 | + * @author takensoft | |
118 | + * @since 2024.04.09 | |
119 | + * 코드 상세 조회 | |
120 | + */ | |
121 | + @Override | |
122 | + public CodeManageVO findByCd(String cd) throws Exception { | |
123 | + return codeManageDAO.findByCd(cd); | |
124 | + } | |
125 | + | |
126 | + /** | |
127 | + * @author takensoft | |
128 | + * @since 2024.04.15 | |
129 | + * 특정 공통 목록 코드 조회(시스템 처리용) | |
130 | + */ | |
131 | + @Override | |
132 | + public CodeManageVO findByCdSystem(String cd) throws Exception { | |
133 | + CodeManageVO codeManage = codeManageDAO.findByCd(cd); | |
134 | + codeManage.setChildCdList(findByChildCd(cd)); | |
135 | + return codeManage; | |
136 | + } | |
137 | + | |
138 | + /** | |
139 | + * @author takensoft | |
140 | + * @since 2024.04.19 | |
141 | + * 하위 코드 조회(cache) | |
142 | + */ | |
143 | + @Override | |
144 | + @Cacheable(value = "findByChildCdCache", key = "#cd") | |
145 | + public List<CodeManageVO> findByChildCdCache(String cd) throws Exception { | |
146 | + LOGGER.info("Loading search conditions from the database for boardType: {}", cd); | |
147 | + return codeManageDAO.findChildCdUser(cd); | |
148 | + } | |
149 | + | |
150 | + /** | |
151 | + * @author takensoft | |
152 | + * @since 2024.04.23 | |
153 | + * 코드 삭제 | |
154 | + */ | |
155 | + @Override | |
156 | + @Transactional(rollbackFor = Exception.class) | |
157 | + public int cdDelete(String cd) throws Exception { | |
158 | + return codeManageDAO.deleteCd(cd); | |
159 | + } | |
160 | + /************************************** Hierachy 전용 **************************************/ | |
161 | + /** | |
162 | + * @author takensoft | |
163 | + * @since 2024.04.24 | |
164 | + * 최상위 코드 조회 | |
165 | + */ | |
166 | + @Override | |
167 | + public List<HierachyVO> findByTopNode() { | |
168 | + // 상위 코드 조회 | |
169 | + List<HierachyVO> topCdList = codeManageDAO.findByTopNode(); | |
170 | + // 상위 코드에 따른 하위 코드 조회 | |
171 | + for(HierachyVO hierachy : topCdList) { | |
172 | + List<HierachyVO> child = findChildNode(hierachy.getId()); | |
173 | + hierachy.setChildList(child); | |
174 | + } | |
175 | + return topCdList; | |
176 | + } | |
177 | + | |
178 | + /** | |
179 | + * @author takensoft | |
180 | + * @since 2024.04.24 | |
181 | + * 하위 코드 조회 | |
182 | + */ | |
183 | + @Override | |
184 | + public List<HierachyVO> findChildNode(String id) { | |
185 | + List<HierachyVO> childList = codeManageDAO.findChildNode(id); | |
186 | + for(HierachyVO hierachyVO : childList) { | |
187 | + List<HierachyVO> child = findChildNode(hierachyVO.getId()); | |
188 | + hierachyVO.setChildList(child); | |
189 | + } | |
190 | + return childList; | |
191 | + } | |
192 | + /************************************** Hierachy 전용 **************************************/ | |
193 | + | |
194 | + /** | |
195 | + * @author 박정하 | |
196 | + * @since 2024.05.10 | |
197 | + * 부서 코드 수정 (hierachyVO 사용) | |
198 | + */ | |
199 | + @Override | |
200 | + @Transactional(rollbackFor = Exception.class) | |
201 | + public int updateList(List<HierachyVO> deptList) throws Exception { | |
202 | + int result = 0; | |
203 | + String writer = jwtUtil.getWriter(); | |
204 | + | |
205 | + if(deptList != null && deptList.size() > 0) { | |
206 | + int sn = 1; | |
207 | + for(HierachyVO hierachyVO : deptList) { | |
208 | + // 최상위 노드 수정 | |
209 | + CodeManageVO vo = new CodeManageVO(); | |
210 | + vo.setCd(hierachyVO.getId()); | |
211 | + vo.setUpCd(null); | |
212 | + vo.setCdGrd(0); | |
213 | + vo.setCdSn(sn); | |
214 | + vo.setMdfr(writer); | |
215 | + result += codeManageDAO.codeUpdateByHierachy(vo); | |
216 | + | |
217 | + // 하위 노드 수정 | |
218 | + if (hierachyVO.getChildList() != null && hierachyVO.getChildList().size() > 0) { | |
219 | + result += updateChildNode(hierachyVO.getChildList(), vo); | |
220 | + } | |
221 | + sn++; | |
222 | + } | |
223 | + } | |
224 | + return result; | |
225 | + } | |
226 | + /** | |
227 | + * @author 박정하 | |
228 | + * @since 2024.05.10 | |
229 | + * 하위 코드 수정 | |
230 | + */ | |
231 | + @Override | |
232 | + public int updateChildNode(List<HierachyVO> childList, CodeManageVO upCodeManageVO) throws Exception { | |
233 | + int result = 0; | |
234 | + String upDeptId = upCodeManageVO.getCd(); | |
235 | + int grd = upCodeManageVO.getCdGrd() + 1; | |
236 | + int sn = 1; | |
237 | + String mdfr = upCodeManageVO.getMdfr(); | |
238 | + for(HierachyVO hierachyVO : childList) { | |
239 | + // 현재 노드 수정 | |
240 | + CodeManageVO vo = new CodeManageVO(); | |
241 | + vo.setCd(hierachyVO.getId()); | |
242 | + vo.setUpCd(upDeptId); | |
243 | + vo.setCdGrd(grd); | |
244 | + vo.setCdSn(sn); | |
245 | + vo.setMdfr(mdfr); | |
246 | + result += codeManageDAO.codeUpdateByHierachy(vo); | |
247 | + | |
248 | + // 하위 노드 수정 | |
249 | + if (hierachyVO.getChildList() != null && hierachyVO.getChildList().size() > 0) { | |
250 | + result += updateChildNode(hierachyVO.getChildList(), vo); | |
251 | + } | |
252 | + sn++; | |
253 | + } | |
254 | + return result; | |
255 | + } | |
256 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/codeManage/vo/CodeManageVO.java
... | ... | @@ -0,0 +1,86 @@ |
1 | +package com.takensoft.cms.codeManage.vo; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import lombok.Setter; | |
7 | + | |
8 | +import java.util.ArrayList; | |
9 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * @author : takensoft | |
13 | + * @since : 2024.04.09 | |
14 | + * | |
15 | + * 공통코드 정보 관련 VO | |
16 | + */ | |
17 | +@Setter | |
18 | +@Getter | |
19 | +@NoArgsConstructor | |
20 | +@AllArgsConstructor | |
21 | +public class CodeManageVO { | |
22 | + /** | |
23 | + * 코드 | |
24 | + */ | |
25 | + private String cd; | |
26 | + /** | |
27 | + * 변경전 코드 | |
28 | + */ | |
29 | + private String originCd; | |
30 | + /** | |
31 | + * 상위코드 | |
32 | + */ | |
33 | + private String upCd; | |
34 | + /** | |
35 | + * 상위코드명 | |
36 | + */ | |
37 | + private String upCdNm; | |
38 | + /** | |
39 | + * 코드명 | |
40 | + */ | |
41 | + private String cdNm; | |
42 | + /** | |
43 | + * 코드값 | |
44 | + */ | |
45 | + private String cdVl; | |
46 | + /** | |
47 | + * 코드설명 | |
48 | + */ | |
49 | + private String cdExpln; | |
50 | + /** | |
51 | + * 코드깊이(레벨) | |
52 | + */ | |
53 | + private int cdGrd; | |
54 | + /** | |
55 | + * 코드순서 | |
56 | + */ | |
57 | + private int cdSn; | |
58 | + /** | |
59 | + * 사용여부 | |
60 | + */ | |
61 | + private String useYn; | |
62 | + /** | |
63 | + * 시스템 제공 여부 | |
64 | + */ | |
65 | + private String sysPvsnYn; | |
66 | + /** | |
67 | + * 등록자 | |
68 | + */ | |
69 | + private String rgtr; | |
70 | + /** | |
71 | + * 등록일 | |
72 | + */ | |
73 | + private String regDt; | |
74 | + /** | |
75 | + * 수정자 | |
76 | + */ | |
77 | + private String mdfr; | |
78 | + /** | |
79 | + * 수정일 | |
80 | + */ | |
81 | + private String mdfcnDt; | |
82 | + /** | |
83 | + * 하위 코드 목록 | |
84 | + */ | |
85 | + private List<CodeManageVO> childCdList = new ArrayList<CodeManageVO>(); | |
86 | +} |
+++ src/main/java/com/takensoft/cms/codeManage/web/CodeManageController.java
... | ... | @@ -0,0 +1,254 @@ |
1 | +package com.takensoft.cms.codeManage.web; | |
2 | + | |
3 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
4 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import com.takensoft.common.HierachyVO; | |
7 | +import lombok.RequiredArgsConstructor; | |
8 | +import lombok.extern.slf4j.Slf4j; | |
9 | +import org.springframework.http.HttpHeaders; | |
10 | +import org.springframework.http.HttpStatus; | |
11 | +import org.springframework.http.MediaType; | |
12 | +import org.springframework.http.ResponseEntity; | |
13 | +import org.springframework.web.bind.annotation.*; | |
14 | + | |
15 | +import java.nio.charset.Charset; | |
16 | +import java.util.HashMap; | |
17 | +import java.util.List; | |
18 | +import java.util.Map; | |
19 | + | |
20 | +/** | |
21 | + * @author : takensoft | |
22 | + * @since : 2024.04.09 | |
23 | + * | |
24 | + * 공통코드 정보 관련 컨트롤러 | |
25 | + */ | |
26 | +@RestController | |
27 | +@RequiredArgsConstructor | |
28 | +@Slf4j | |
29 | +@RequestMapping("/admin/code") | |
30 | +public class CodeManageController { | |
31 | + | |
32 | + private final CodeManageService codeManageService; | |
33 | + | |
34 | + /** | |
35 | + * @author takensoft | |
36 | + * @since 2024.04.09 | |
37 | + * @param codeManageVO | |
38 | + * @return | |
39 | + * @throws Exception | |
40 | + * | |
41 | + * 공통코드 등록 | |
42 | + */ | |
43 | + @PostMapping("/saveProc.json") | |
44 | + public ResponseEntity<?> saveProc(@RequestBody CodeManageVO codeManageVO) throws Exception { | |
45 | + // 코드 중복 검사 | |
46 | + boolean isExistence = codeManageService.findByCheckCd(codeManageVO); | |
47 | + | |
48 | + // 응답 처리 | |
49 | + HttpHeaders headers = new HttpHeaders(); | |
50 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
51 | + ResponseData responseData = new ResponseData(); | |
52 | + | |
53 | + if(isExistence) { | |
54 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
55 | + responseData.setMessage("이미 존재하는 코드입니다."); | |
56 | + log.error("이미 존재하는 코드입니다."); | |
57 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
58 | + } | |
59 | + | |
60 | + // 코드 등록 | |
61 | + int result = codeManageService.cdSave(codeManageVO); | |
62 | + if(result > 0) { | |
63 | + responseData.setStatus(HttpStatus.OK); | |
64 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
65 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
66 | + } else { | |
67 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
68 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
69 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
70 | + } | |
71 | + } | |
72 | + | |
73 | + /** | |
74 | + * @author takensoft | |
75 | + * @since 2024.04.09 | |
76 | + * @param | |
77 | + * @return | |
78 | + * @throws Exception | |
79 | + * | |
80 | + * 공통코드 목록 조회 (관리자용) | |
81 | + */ | |
82 | + @GetMapping(value = "/findAll.json") | |
83 | + public ResponseEntity<?> findAll() throws Exception { | |
84 | + // Tree용 | |
85 | + List<HierachyVO> hierachyList = codeManageService.findByTopNode(); | |
86 | + | |
87 | + Map<String, Object> result = new HashMap<String, Object>(); | |
88 | + result.put("hierachyList", hierachyList); | |
89 | + result.put("newCode", new CodeManageVO()); | |
90 | + | |
91 | + // 응답 처리 | |
92 | + HttpHeaders headers = new HttpHeaders(); | |
93 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
94 | + ResponseData responseData = new ResponseData(); | |
95 | + responseData.setStatus(HttpStatus.OK); | |
96 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
97 | + responseData.setData(result); | |
98 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
99 | + } | |
100 | + | |
101 | + /** | |
102 | + * @author takensoft | |
103 | + * @since 2024.04.09 | |
104 | + * @param codeManageVO | |
105 | + * @return | |
106 | + * @throws Exception | |
107 | + * | |
108 | + * 공통코드 상세 조회 (관리자용) | |
109 | + */ | |
110 | + @PostMapping("/findByCd.json") | |
111 | + public ResponseEntity<?> findByCd(@RequestBody CodeManageVO codeManageVO) throws Exception { | |
112 | + // 공통코드 조회 | |
113 | + CodeManageVO code = codeManageService.findByCd(codeManageVO.getCd()); | |
114 | + | |
115 | + Map<String, Object> result = new HashMap<String, Object>(); | |
116 | + result.put("code", code); | |
117 | + | |
118 | + // 응답 처리 | |
119 | + HttpHeaders headers = new HttpHeaders(); | |
120 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
121 | + ResponseData responseData = new ResponseData(); | |
122 | + responseData.setStatus(HttpStatus.OK); | |
123 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
124 | + responseData.setData(result); | |
125 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
126 | + } | |
127 | + | |
128 | + /** | |
129 | + * @author takensoft | |
130 | + * @since 2024.04.15 | |
131 | + * @param codeManageVO | |
132 | + * @return | |
133 | + * @throws Exception | |
134 | + * | |
135 | + * 공통코드 수정 | |
136 | + */ | |
137 | + @PostMapping("/updateProc.json") | |
138 | + public ResponseEntity<?> updateProc(@RequestBody CodeManageVO codeManageVO) throws Exception { | |
139 | + | |
140 | + HttpHeaders headers = new HttpHeaders(); | |
141 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
142 | + ResponseData responseData = new ResponseData(); | |
143 | + | |
144 | + // 코드의 변경 사항이 있을 때만 코드 중복 검사 진행 | |
145 | + if(codeManageVO.getOriginCd() != null && !codeManageVO.getOriginCd().equals("") && !codeManageVO.getOriginCd().equals(codeManageVO.getCd())) { | |
146 | + // 코드 중복 검사 | |
147 | + boolean isExistence = codeManageService.findByCheckCd(codeManageVO); | |
148 | + if(isExistence) { | |
149 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
150 | + responseData.setMessage("이미 존재하는 코드입니다."); | |
151 | + log.error("이미 존재하는 코드입니다."); | |
152 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
153 | + } | |
154 | + } | |
155 | + // 코드 수정 | |
156 | + int result = codeManageService.cdUpdate(codeManageVO); | |
157 | + | |
158 | + // 응답 처리 | |
159 | + if(result > 0) { | |
160 | + responseData.setStatus(HttpStatus.OK); | |
161 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
162 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
163 | + } else { | |
164 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
165 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
166 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
167 | + } | |
168 | + } | |
169 | + | |
170 | + /** | |
171 | + * @author takensoft | |
172 | + * @since 2024.04.15 | |
173 | + * @param codeManageVO | |
174 | + * @return | |
175 | + * @throws Exception | |
176 | + * | |
177 | + * 공통코드 삭제 | |
178 | + */ | |
179 | + @PostMapping("/deleteProc.json") | |
180 | + public ResponseEntity<?> deleteProc(@RequestBody CodeManageVO codeManageVO) throws Exception { | |
181 | + // 공통 코드 삭제(하위 항목 모두) | |
182 | + int result = codeManageService.cdDelete(codeManageVO.getCd()); | |
183 | + | |
184 | + // 응답 처리 | |
185 | + HttpHeaders headers = new HttpHeaders(); | |
186 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
187 | + ResponseData responseData = new ResponseData(); | |
188 | + if(result > 0) { | |
189 | + responseData.setStatus(HttpStatus.OK); | |
190 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
191 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
192 | + } else { | |
193 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
194 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
195 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
196 | + } | |
197 | + } | |
198 | + | |
199 | + /** | |
200 | + * @author takensoft | |
201 | + * @since 2024.04.09 | |
202 | + * @param codeManageVO | |
203 | + * @return | |
204 | + * @throws Exception | |
205 | + * | |
206 | + * 특정 공통 목록 코드 조회(시스템 처리용) | |
207 | + */ | |
208 | + @PostMapping("/findByCdSystem.json") | |
209 | + public ResponseEntity<?> findByCdSystem(@RequestBody CodeManageVO codeManageVO) throws Exception { | |
210 | + // 메뉴 조회 | |
211 | + CodeManageVO code = codeManageService.findByCdSystem(codeManageVO.getCd()); | |
212 | + | |
213 | + Map<String, Object> result = new HashMap<String, Object>(); | |
214 | + result.put("code", code); | |
215 | + | |
216 | + // 응답 처리 | |
217 | + HttpHeaders headers = new HttpHeaders(); | |
218 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
219 | + ResponseData responseData = new ResponseData(); | |
220 | + responseData.setStatus(HttpStatus.OK); | |
221 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
222 | + responseData.setData(result); | |
223 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
224 | + } | |
225 | + | |
226 | + /** | |
227 | + * @author 박정하 | |
228 | + * @since 2024.05.10 | |
229 | + * @param codeList | |
230 | + * @return | |
231 | + * @throws Exception | |
232 | + * | |
233 | + * 공통 코드 목록 수정 | |
234 | + */ | |
235 | + @PostMapping(value = "/updateListProc.json") | |
236 | + public ResponseEntity<?> updateListProc(@RequestBody List<HierachyVO> codeList) throws Exception { | |
237 | + // 공통 코드 목록 수정 | |
238 | + int result = codeManageService.updateList(codeList); | |
239 | + | |
240 | + // 응답 처리 | |
241 | + HttpHeaders headers = new HttpHeaders(); | |
242 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
243 | + ResponseData responseData = new ResponseData(); | |
244 | + if(result > 0) { | |
245 | + responseData.setStatus(HttpStatus.OK); | |
246 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
247 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
248 | + } else { | |
249 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
250 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
251 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
252 | + } | |
253 | + } | |
254 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/contsType/dao/ContsTypeDAO.java
... | ... | @@ -0,0 +1,75 @@ |
1 | +package com.takensoft.cms.contsType.dao; | |
2 | + | |
3 | +import com.takensoft.cms.contsType.vo.ContsAuthrtVO; | |
4 | +import com.takensoft.cms.contsType.vo.ContsTypeVO; | |
5 | +import com.takensoft.common.Pagination; | |
6 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
7 | + | |
8 | +import java.util.List; | |
9 | +import java.util.Map; | |
10 | + | |
11 | +/** | |
12 | + * @author : takensoft | |
13 | + * @since : 2024.04.17 | |
14 | + * | |
15 | + * 콘텐츠 유형 관리 관련 Mapper | |
16 | + */ | |
17 | +@Mapper("contsTypeDAO") | |
18 | +public interface ContsTypeDAO { | |
19 | + | |
20 | + /** | |
21 | + * @author takensoft | |
22 | + * @since 2024.04.17 | |
23 | + * 콘텐츠 유형 등록 | |
24 | + */ | |
25 | + int save(ContsTypeVO contsTypeVO); | |
26 | + | |
27 | + /** | |
28 | + * @author takensoft | |
29 | + * @since 2024.04.17 | |
30 | + * 콘텐츠 유형 수정 | |
31 | + */ | |
32 | + int update(ContsTypeVO contsTypeVO); | |
33 | + | |
34 | + /** | |
35 | + * @author takensoft | |
36 | + * @since 2024.04.17 | |
37 | + * 콘텐츠 유형 목록 조회 | |
38 | + */ | |
39 | + List<ContsTypeVO> findAll(Pagination pagination); | |
40 | + | |
41 | + /** | |
42 | + * @author takensoft | |
43 | + * @since 2024.04.17 | |
44 | + * 콘텐츠 유형 목록 조회(노출인 목록만) | |
45 | + */ | |
46 | + List<ContsTypeVO> findByContsTypeSys(ContsTypeVO contsTypeVO); | |
47 | + | |
48 | + /** | |
49 | + * @author takensoft | |
50 | + * @since 2024.04.17 | |
51 | + * 콘텐츠 유형 상세 조회 | |
52 | + */ | |
53 | + ContsTypeVO findByContsType(String contsId); | |
54 | + | |
55 | + /** | |
56 | + * @author 박정하 | |
57 | + * @since 2024.04.23 | |
58 | + * 콘텐츠 유형 목록 갯수(관리자 페이지용) | |
59 | + */ | |
60 | + int findAllCnt(Pagination pagination); | |
61 | + | |
62 | + /** | |
63 | + * @author 박정하 | |
64 | + * @since 2024.04.29 | |
65 | + * 콘텐츠 유형 목록 조회 (메뉴 노출 건만) | |
66 | + */ | |
67 | + List<ContsTypeVO> findAllByExpsr(ContsTypeVO contsTypeVO); | |
68 | + | |
69 | + /** | |
70 | + * @author takensoft | |
71 | + * @since 2024.05.02 | |
72 | + * 콘텐츠 조회(권한 포함) | |
73 | + */ | |
74 | + List<ContsAuthrtVO> findByContsAuthrt(); | |
75 | +} |
+++ src/main/java/com/takensoft/cms/contsType/service/ContsTypeService.java
... | ... | @@ -0,0 +1,66 @@ |
1 | +package com.takensoft.cms.contsType.service; | |
2 | + | |
3 | +import com.takensoft.cms.contsType.vo.ContsAuthrtVO; | |
4 | +import com.takensoft.cms.contsType.vo.ContsTypeVO; | |
5 | + | |
6 | +import java.util.HashMap; | |
7 | +import java.util.List; | |
8 | +import java.util.Map; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.04.17 | |
13 | + * | |
14 | + * 콘텐츠 유형 관리 관련 인터페이스 | |
15 | + */ | |
16 | +public interface ContsTypeService { | |
17 | + | |
18 | + /** | |
19 | + * @author takensoft | |
20 | + * @since 2024.04.17 | |
21 | + * 콘텐츠 유형 등록 | |
22 | + */ | |
23 | + public HashMap<String, Object> contsSave(ContsTypeVO contsTypeVO) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author takensoft | |
27 | + * @since 2024.04.17 | |
28 | + * 콘텐츠 유형 수정 | |
29 | + */ | |
30 | + public int contsUpdate(ContsTypeVO contsTypeVO) throws Exception; | |
31 | + | |
32 | + /** | |
33 | + * @author takensoft | |
34 | + * @since 2024.04.17 | |
35 | + * 콘텐츠 유형 목록 조회 | |
36 | + */ | |
37 | + public Map<String, Object> findAll(Map<String, String> params) throws Exception; | |
38 | + | |
39 | + /** | |
40 | + * @author takensoft | |
41 | + * @since 2024.04.17 | |
42 | + * 콘텐츠 유형 목록 조회(노출인 목록만) | |
43 | + */ | |
44 | + public List<ContsTypeVO> findByContsTypeSys(ContsTypeVO contsTypeVO) throws Exception; | |
45 | + | |
46 | + /** | |
47 | + * @author takensoft | |
48 | + * @since 2024.04.17 | |
49 | + * 콘텐츠 유형 상세 조회 | |
50 | + */ | |
51 | + public ContsTypeVO findByContsType(String contsId) throws Exception; | |
52 | + | |
53 | + /** | |
54 | + * @author 박정하 | |
55 | + * @since 2024.04.29 | |
56 | + * 콘텐츠 유형 목록 조회 (메뉴 노출 건만) | |
57 | + */ | |
58 | + public List<ContsTypeVO> findAllByExpsr(ContsTypeVO contsTypeVO) throws Exception; | |
59 | + | |
60 | + /** | |
61 | + * @author takensoft | |
62 | + * @since 2024.05.02 | |
63 | + * 콘텐츠 조회(권한 포함) | |
64 | + */ | |
65 | + public List<ContsAuthrtVO> findByContsAuthrt() throws Exception; | |
66 | +} |
+++ src/main/java/com/takensoft/cms/contsType/service/Impl/ContsTypeServiceImpl.java
... | ... | @@ -0,0 +1,232 @@ |
1 | +package com.takensoft.cms.contsType.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.BbsRouterDAO; | |
4 | +import com.takensoft.cms.contsType.dao.ContsTypeDAO; | |
5 | +import com.takensoft.cms.contsType.service.ContsTypeService; | |
6 | +import com.takensoft.cms.contsType.vo.ContsAuthrtVO; | |
7 | +import com.takensoft.cms.contsType.vo.ContsTypeVO; | |
8 | +import com.takensoft.cms.menu.dao.MenuDAO; | |
9 | +import com.takensoft.cms.menu.service.MenuService; | |
10 | +import com.takensoft.cms.menu.vo.MenuAuthorVO; | |
11 | +import com.takensoft.cms.menu.vo.MenuVO; | |
12 | +import com.takensoft.common.Pagination; | |
13 | +import com.takensoft.common.idgen.service.IdgenService; | |
14 | +import com.takensoft.common.util.JWTUtil; | |
15 | +import lombok.RequiredArgsConstructor; | |
16 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
17 | +import org.springframework.cache.annotation.CacheEvict; | |
18 | +import org.springframework.cache.annotation.Cacheable; | |
19 | +import org.springframework.stereotype.Service; | |
20 | +import org.springframework.transaction.annotation.Transactional; | |
21 | + | |
22 | +import java.util.*; | |
23 | +import java.util.stream.Collectors; | |
24 | + | |
25 | +/** | |
26 | + * @author : takensoft | |
27 | + * @since : 2024.04.17 | |
28 | + * | |
29 | + * 콘텐츠 유형 관리 관련 구현체 | |
30 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
31 | + * ContsTypeService : 콘텐츠 유형 관리 관련 인터페이스 상속 | |
32 | + */ | |
33 | +@Service("contsTypeService") | |
34 | +@RequiredArgsConstructor | |
35 | +public class ContsTypeServiceImpl extends EgovAbstractServiceImpl implements ContsTypeService { | |
36 | + private final ContsTypeDAO contsTypeDAO; | |
37 | + private final BbsRouterDAO bbsRouterDAO; | |
38 | + private final IdgenService contsTypeIdgn; | |
39 | + private final JWTUtil jwtUtil; | |
40 | + private final MenuService menuService; // 메뉴 인터페이스 | |
41 | + private final MenuDAO menuDAO; | |
42 | + | |
43 | + /** | |
44 | + * @author takensoft | |
45 | + * @since 2024.04.17 | |
46 | + * 콘텐츠 유형 등록 | |
47 | + */ | |
48 | + @Override | |
49 | + @Transactional(rollbackFor = Exception.class) | |
50 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
51 | + public HashMap<String, Object> contsSave(ContsTypeVO contsTypeVO) throws Exception { | |
52 | + HashMap<String, Object> result = new HashMap<>(); | |
53 | + | |
54 | + // 콘텐츠 유형 아이디 생성 | |
55 | + String contsId = contsTypeIdgn.getNextStringId(); | |
56 | + contsTypeVO.setContsId(contsId); | |
57 | + | |
58 | + // 등록된 토큰에서 사용자 정보 조회 | |
59 | + contsTypeVO.setRgtr(jwtUtil.getWriter()); | |
60 | + | |
61 | + // 콘텐츠 유형 등록 | |
62 | + int insertResult = contsTypeDAO.save(contsTypeVO); | |
63 | + | |
64 | + // 메뉴 등록 | |
65 | + if (contsTypeVO.getExpsrYn().equals("Y")) { | |
66 | + MenuVO menuVO = new MenuVO(); | |
67 | + menuVO.setUpMenuId("MENU_000000000000018"); // 상위메뉴아이디(콘텐츠 관리 메뉴 아이디) | |
68 | + menuVO.setMenuNm(contsTypeVO.getContsKornNm()); // 메뉴명 | |
69 | + menuVO.setMenuType("conts"); // 메뉴타입 | |
70 | + menuVO.setMenuTypeCtgry(contsId); // 메뉴타입항목(콘텐츠 유형 아이디) | |
71 | + menuVO.setLinkType("0"); // 링크유형(현재창) | |
72 | + menuVO.setDgstfnExmnUseYn("N"); // 만족도조사사용여부(미노출) | |
73 | + menuVO.setMenuExpsrYn("Y"); // 메뉴노출여부(노출) | |
74 | + menuVO.setMenuUser("A"); // 메뉴사용자(관리자) | |
75 | + menuVO.setSysPvsnYn("0"); // 시스템제공여부(시스템등록) | |
76 | + menuService.menuSave(menuVO); | |
77 | + } | |
78 | + | |
79 | + result.put("contsId", contsId); | |
80 | + result.put("result", insertResult); | |
81 | + return result; | |
82 | + } | |
83 | + | |
84 | + /** | |
85 | + * @author takensoft | |
86 | + * @since 2024.04.17 | |
87 | + * 콘텐츠 유형 수정 | |
88 | + */ | |
89 | + @Override | |
90 | + @CacheEvict(value = "routerAuthInfo", allEntries = true) | |
91 | + public int contsUpdate(ContsTypeVO contsTypeVO) throws Exception { | |
92 | + int result = 0; | |
93 | + // 등록된 토큰에서 사용자 정보 조회 | |
94 | + contsTypeVO.setMdfr(jwtUtil.getWriter()); | |
95 | + result += contsTypeDAO.update(contsTypeVO); | |
96 | + | |
97 | + // 메뉴 수정 | |
98 | + menuDAO.updateByContsId(contsTypeVO); | |
99 | + return result; | |
100 | + } | |
101 | + | |
102 | + /** | |
103 | + * @author takensoft | |
104 | + * @since 2024.04.17 | |
105 | + * 콘텐츠 유형 목록 조회 | |
106 | + */ | |
107 | + @Override | |
108 | + public Map<String, Object> findAll(Map<String, String> params) throws Exception { | |
109 | + Map<String, Object> result = new HashMap<>(); | |
110 | + Pagination search = new Pagination(0, params); | |
111 | + int cnt = contsTypeDAO.findAllCnt(search); | |
112 | + Pagination pagination = new Pagination(cnt, params); | |
113 | + List<ContsTypeVO> list = contsTypeDAO.findAll(pagination); | |
114 | + | |
115 | + result.put("list", list); | |
116 | + result.put("pagination", pagination); | |
117 | + return result; | |
118 | + } | |
119 | + | |
120 | + /** | |
121 | + * @author takensoft | |
122 | + * @since 2024.04.17 | |
123 | + * 콘텐츠 유형 목록 조회(노출인 목록만) | |
124 | + */ | |
125 | + @Override | |
126 | + public List<ContsTypeVO> findByContsTypeSys(ContsTypeVO contsTypeVO) throws Exception { | |
127 | + return contsTypeDAO.findByContsTypeSys(contsTypeVO); | |
128 | + } | |
129 | + | |
130 | + /** | |
131 | + * @author takensoft | |
132 | + * @since 2024.04.17 | |
133 | + * 콘텐츠 유형 상세 조회 | |
134 | + */ | |
135 | + @Override | |
136 | + public ContsTypeVO findByContsType(String contsId) throws Exception { | |
137 | + ContsTypeVO contsTypeVO = new ContsTypeVO(); | |
138 | + | |
139 | + if (contsId != null) { | |
140 | + contsTypeVO = contsTypeDAO.findByContsType(contsId); | |
141 | + } | |
142 | + | |
143 | + // 메뉴노출 기본값 | |
144 | + if (contsTypeVO.getExpsrYn() == null) { | |
145 | + contsTypeVO.setExpsrYn("N"); | |
146 | + } | |
147 | + // 사용여부 기본값 | |
148 | + if (contsTypeVO.getUseYn() == null) { | |
149 | + contsTypeVO.setUseYn("Y"); | |
150 | + } | |
151 | + | |
152 | + return contsTypeVO; | |
153 | + } | |
154 | + | |
155 | + /** | |
156 | + * @author 박정하 | |
157 | + * @since 2024.04.29 | |
158 | + * 콘텐츠 유형 목록 조회 (메뉴 노출 건만) | |
159 | + */ | |
160 | + @Override | |
161 | + public List<ContsTypeVO> findAllByExpsr(ContsTypeVO contsTypeVO) throws Exception { | |
162 | + return contsTypeDAO.findAllByExpsr(contsTypeVO); | |
163 | + } | |
164 | + | |
165 | + /** | |
166 | + * @author takensoft | |
167 | + * @since 2024.05.02 | |
168 | + * 콘텐츠 조회(권한 포함) | |
169 | + */ | |
170 | + @Override | |
171 | + @Cacheable(value = "routerAuthInfo", key = "'routerAuth'") | |
172 | + public List<ContsAuthrtVO> findByContsAuthrt() throws Exception { | |
173 | + // 콘텐츠(라우터)정보 조회 | |
174 | + List<ContsAuthrtVO> list = contsTypeDAO.findByContsAuthrt(); | |
175 | + // 권한 공유 | |
176 | + List<ContsAuthrtVO> result = groupAndShareAuth(list); | |
177 | + | |
178 | + // 게시판 라우터 정보 조회 | |
179 | + List<ContsAuthrtVO> bbsList = bbsRouterDAO.findByBbsRouterAuthrt(); | |
180 | + result.addAll(bbsList); | |
181 | + | |
182 | + return result; | |
183 | + } | |
184 | + | |
185 | + /** | |
186 | + * @author toakensoft | |
187 | + * @since 2024.05.08 | |
188 | + * 라우터의 특정경로로 그룹화하여 각 그룹 내에서 권한을 공유 | |
189 | + */ | |
190 | + private List<ContsAuthrtVO> groupAndShareAuth(List<ContsAuthrtVO> routes) { | |
191 | + // 경로의 특정 기준점으로 라우터를 그룹화 | |
192 | + Map<String, List<ContsAuthrtVO>> groupedRoutes = routes.stream() | |
193 | + .collect(Collectors.groupingBy(route -> route.getPageCrs().substring(0, route.getPageCrs().lastIndexOf('/')))); // 마지막 슬래시까지 포함된 경로 추출 | |
194 | + | |
195 | + /* key */ | |
196 | +// Iterator<String> keys = groupedRoutes.keySet().iterator(); | |
197 | +// while(keys.hasNext()) { | |
198 | +// String key = keys.next(); | |
199 | +// System.out.println("key : " + key); | |
200 | +// } | |
201 | + /* key */ | |
202 | + | |
203 | + // 그룹화된 각 경로에 대해 권한 정보 공유 | |
204 | + groupedRoutes.forEach((basePath, routeGroup) -> { | |
205 | + List<MenuAuthorVO> sharedAuth = findMostComprehensiveAuth(routeGroup); // 그룹 내에서 가장 완전한 권한 정보 조회 | |
206 | + // 그룹의 모든 라우트에 권한 정보가 없으면 공유된 권한 정보로 설정 | |
207 | + routeGroup.forEach(route -> { | |
208 | + if(route.getAuthrtList().isEmpty()) { | |
209 | + route.setAuthrtList(sharedAuth); | |
210 | + } | |
211 | + }); | |
212 | + }); | |
213 | + // 각 그룹의 라우터들을 리스트로 반환 | |
214 | + return groupedRoutes.values().stream() | |
215 | + .flatMap(List::stream) | |
216 | + .collect(Collectors.toList()); | |
217 | + } | |
218 | + | |
219 | + /** | |
220 | + * @author toakensoft | |
221 | + * @since 2024.05.08 | |
222 | + * 그룹 내에서 가장 완전한 권한 정보를 가진 라우터를 찾아 해당 권한 리트스 반환 | |
223 | + */ | |
224 | + private List<MenuAuthorVO> findMostComprehensiveAuth(List<ContsAuthrtVO> routeGroup) { | |
225 | + // 권한정보가 있는 첫 번째 라우터를 찾아 권한 정보 반환 | |
226 | + return routeGroup.stream() | |
227 | + .filter(route -> !route.getAuthrtList().isEmpty()) | |
228 | + .findFirst() | |
229 | + .map(ContsAuthrtVO::getAuthrtList) | |
230 | + .orElse(Collections.emptyList()); // 권한 정보가 없으면 빈 리스트 반환 | |
231 | + } | |
232 | +} |
+++ src/main/java/com/takensoft/cms/contsType/vo/ContsAuthrtVO.java
... | ... | @@ -0,0 +1,52 @@ |
1 | +package com.takensoft.cms.contsType.vo; | |
2 | + | |
3 | +import com.takensoft.cms.menu.vo.MenuAuthorVO; | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | +import org.checkerframework.checker.units.qual.A; | |
9 | + | |
10 | +import java.util.ArrayList; | |
11 | +import java.util.List; | |
12 | + | |
13 | +/** | |
14 | + * @author : takensoft | |
15 | + * @since : 2024.04.17 | |
16 | + * | |
17 | + * 콘텐츠 유형과 권한 정보 관련 VO | |
18 | + */ | |
19 | +@Setter | |
20 | +@Getter | |
21 | +@NoArgsConstructor | |
22 | +@AllArgsConstructor | |
23 | +public class ContsAuthrtVO { | |
24 | + /** | |
25 | + * 콘텐츠 아이디 | |
26 | + */ | |
27 | + private String contsId; | |
28 | + /** | |
29 | + * 메뉴 아이디 | |
30 | + */ | |
31 | + private String menuId; | |
32 | + /** | |
33 | + * 콘텐츠 한글명 | |
34 | + */ | |
35 | + private String contsKornNm; | |
36 | + /** | |
37 | + * 콘텐츠 영문명 | |
38 | + */ | |
39 | + private String contsEngNm; | |
40 | + /** | |
41 | + * 페이지 경로 | |
42 | + */ | |
43 | + private String pageCrs; | |
44 | + /** | |
45 | + * 컴포넌트 경로 | |
46 | + */ | |
47 | + private String compnCrs; | |
48 | + /** | |
49 | + * 권한 목록 | |
50 | + */ | |
51 | + private List<MenuAuthorVO> authrtList = new ArrayList<MenuAuthorVO>(); | |
52 | +} |
+++ src/main/java/com/takensoft/cms/contsType/vo/ContsTypeVO.java
... | ... | @@ -0,0 +1,71 @@ |
1 | +package com.takensoft.cms.contsType.vo; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import lombok.Setter; | |
7 | + | |
8 | +/** | |
9 | + * @author : takensoft | |
10 | + * @since : 2024.04.17 | |
11 | + * | |
12 | + * 콘텐츠 유형 관리 관련 VO | |
13 | + */ | |
14 | +@Setter | |
15 | +@Getter | |
16 | +@NoArgsConstructor | |
17 | +@AllArgsConstructor | |
18 | +public class ContsTypeVO { | |
19 | + /** | |
20 | + * 콘텐츠 아이디 | |
21 | + */ | |
22 | + private String contsId; | |
23 | + /** | |
24 | + * 콘텐츠 한글명 | |
25 | + */ | |
26 | + private String contsKornNm; | |
27 | + /** | |
28 | + * 콘텐츠 영문명 | |
29 | + */ | |
30 | + private String contsEngNm; | |
31 | + /** | |
32 | + * 사용자 페이지 경로 | |
33 | + */ | |
34 | + private String pageCrs; | |
35 | + /** | |
36 | + * 관리자 페이지 경로 | |
37 | + */ | |
38 | + private String mngrPageCrs; | |
39 | + /** | |
40 | + * 컴포넌트 경로 | |
41 | + */ | |
42 | + private String compnCrs; | |
43 | + /** | |
44 | + * 노출여부 | |
45 | + */ | |
46 | + private String expsrYn; | |
47 | + /** | |
48 | + * 사용여부 | |
49 | + */ | |
50 | + private String useYn; | |
51 | + /** | |
52 | + * 시스템 제공 여부 | |
53 | + */ | |
54 | + private String sysPvsnYn; | |
55 | + /** | |
56 | + * 등록자 | |
57 | + */ | |
58 | + private String rgtr; | |
59 | + /** | |
60 | + * 등록일 | |
61 | + */ | |
62 | + private String regDt; | |
63 | + /** | |
64 | + * 수정자 | |
65 | + */ | |
66 | + private String mdfr; | |
67 | + /** | |
68 | + * 수정일 | |
69 | + */ | |
70 | + private String mdfcnDt; | |
71 | +} |
+++ src/main/java/com/takensoft/cms/contsType/web/ContsTypeController.java
... | ... | @@ -0,0 +1,190 @@ |
1 | +package com.takensoft.cms.contsType.web; | |
2 | + | |
3 | +import com.takensoft.cms.contsType.service.ContsTypeService; | |
4 | +import com.takensoft.cms.contsType.vo.ContsTypeVO; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import org.springframework.http.HttpHeaders; | |
8 | +import org.springframework.http.HttpStatus; | |
9 | +import org.springframework.http.MediaType; | |
10 | +import org.springframework.http.ResponseEntity; | |
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 java.nio.charset.Charset; | |
17 | +import java.util.*; | |
18 | + | |
19 | +/** | |
20 | + * @author : takensoft | |
21 | + * @since : 2024.04.17 | |
22 | + * | |
23 | + * 콘텐츠 유형 관리 관련 컨트롤러 | |
24 | + */ | |
25 | +@RestController | |
26 | +@RequiredArgsConstructor | |
27 | +@RequestMapping(value = "/admin/contsType") | |
28 | +public class ContsTypeController { | |
29 | + private final ContsTypeService contsTypeService; | |
30 | + | |
31 | + /** | |
32 | + * @author takensoft | |
33 | + * @since 2024.04.17 | |
34 | + * @param contsTypeVO | |
35 | + * @return | |
36 | + * @throws Exception | |
37 | + * | |
38 | + * 콘텐츠 유형 등록 | |
39 | + */ | |
40 | + @PostMapping("/saveProc.json") | |
41 | + public ResponseEntity<?> savePorc(@RequestBody ContsTypeVO contsTypeVO) throws Exception { | |
42 | + // 콘텐츠 유형 등록 | |
43 | + HashMap<String, Object> result = contsTypeService.contsSave(contsTypeVO); | |
44 | + int insertResult = (int) result.get("result"); | |
45 | + | |
46 | + // 응답 처리 | |
47 | + HttpHeaders headers = new HttpHeaders(); | |
48 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
49 | + ResponseData responseData = new ResponseData(); | |
50 | + if(insertResult > 0) { | |
51 | + responseData.setStatus(HttpStatus.OK); | |
52 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
53 | + responseData.setData(result); | |
54 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
55 | + } else { | |
56 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
57 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
58 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
59 | + } | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * @author takensoft | |
64 | + * @since 2024.04.17 | |
65 | + * @param contsTypeVO | |
66 | + * @return | |
67 | + * @throws Exception | |
68 | + * | |
69 | + * 콘텐츠 유형 수정 | |
70 | + */ | |
71 | + @PostMapping("/updateProc.json") | |
72 | + public ResponseEntity<?> updateProc(@RequestBody ContsTypeVO contsTypeVO) throws Exception { | |
73 | + // 콘텐츠 유형 수정 처리 | |
74 | + int result = contsTypeService.contsUpdate(contsTypeVO); | |
75 | + | |
76 | + // 응답 처리 | |
77 | + HttpHeaders headers = new HttpHeaders(); | |
78 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
79 | + ResponseData responseData = new ResponseData(); | |
80 | + if(result > 0) { | |
81 | + responseData.setStatus(HttpStatus.OK); | |
82 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
83 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
84 | + } else { | |
85 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
86 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
87 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
88 | + } | |
89 | + } | |
90 | + | |
91 | + /** | |
92 | + * @author takensoft | |
93 | + * @since 2024.04.17 | |
94 | + * @param params | |
95 | + * @return | |
96 | + * @throws Exception | |
97 | + * | |
98 | + * 콘텐츠 유형 목록 조회 | |
99 | + */ | |
100 | + @PostMapping("/findAll.json") | |
101 | + public ResponseEntity<?> findAll(@RequestBody Map<String, String> params) throws Exception { | |
102 | + // 콘텐츠 유형 목록 조회 | |
103 | + Map<String, Object> result = contsTypeService.findAll(params); | |
104 | + | |
105 | + // 응답 처리 | |
106 | + HttpHeaders headers = new HttpHeaders(); | |
107 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
108 | + ResponseData responseData = new ResponseData(); | |
109 | + responseData.setStatus(HttpStatus.OK); | |
110 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
111 | + responseData.setData(result); | |
112 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
113 | + } | |
114 | + | |
115 | + /** | |
116 | + * @author takensoft | |
117 | + * @since 2024.04.17 | |
118 | + * @param contsTypeVO | |
119 | + * @return | |
120 | + * @throws Exception | |
121 | + * | |
122 | + * 콘텐츠 유형 상세 조회 | |
123 | + */ | |
124 | + @PostMapping("/findByContsType.json") | |
125 | + public ResponseEntity<?> findByContsType(@RequestBody ContsTypeVO contsTypeVO) throws Exception { | |
126 | + ContsTypeVO result = contsTypeService.findByContsType(contsTypeVO.getContsId()); | |
127 | + | |
128 | + // 응답 처리 | |
129 | + HttpHeaders headers = new HttpHeaders(); | |
130 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
131 | + ResponseData responseData = new ResponseData(); | |
132 | + responseData.setStatus(HttpStatus.OK); | |
133 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
134 | + responseData.setData(result); | |
135 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
136 | + } | |
137 | + | |
138 | + /** | |
139 | + * @author takensoft | |
140 | + * @since 2024.04.17 | |
141 | + * @param contsTypeVO | |
142 | + * @return | |
143 | + * @throws Exception | |
144 | + * | |
145 | + * 콘텐츠 유형 삭제 | |
146 | + */ | |
147 | + @PostMapping("/deleteProc.json") | |
148 | + public ResponseEntity<?> deleteProc(@RequestBody ContsTypeVO contsTypeVO) throws Exception { | |
149 | + contsTypeVO.setUseYn("N"); | |
150 | + int result = contsTypeService.contsUpdate(contsTypeVO); | |
151 | + | |
152 | + // 응답 처리 | |
153 | + HttpHeaders headers = new HttpHeaders(); | |
154 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
155 | + ResponseData responseData = new ResponseData(); | |
156 | + if(result > 0) { | |
157 | + responseData.setStatus(HttpStatus.OK); | |
158 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
159 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
160 | + } else { | |
161 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
162 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
163 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
164 | + } | |
165 | + } | |
166 | + | |
167 | + /** | |
168 | + * @author 박정하 | |
169 | + * @since 2024.04.29 | |
170 | + * @param | |
171 | + * @return | |
172 | + * @throws Exception | |
173 | + * | |
174 | + * 콘텐츠 유형 목록 조회 (메뉴 노출 건만) | |
175 | + */ | |
176 | + @PostMapping("/findAllByExpsr.json") | |
177 | + public ResponseEntity<?> findAllByExpsr(@RequestBody ContsTypeVO contsTypeVO) throws Exception { | |
178 | + // 콘텐츠 유형 목록 조회 (메뉴 노출 건만) | |
179 | + List<ContsTypeVO> result = contsTypeService.findAllByExpsr(contsTypeVO); | |
180 | + | |
181 | + // 응답 처리 | |
182 | + HttpHeaders headers = new HttpHeaders(); | |
183 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
184 | + ResponseData responseData = new ResponseData(); | |
185 | + responseData.setStatus(HttpStatus.OK); | |
186 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
187 | + responseData.setData(result); | |
188 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
189 | + } | |
190 | +} |
+++ src/main/java/com/takensoft/cms/contsType/web/SystemContsTypeController.java
... | ... | @@ -0,0 +1,75 @@ |
1 | +package com.takensoft.cms.contsType.web; | |
2 | + | |
3 | +import com.takensoft.cms.contsType.service.ContsTypeService; | |
4 | +import com.takensoft.cms.contsType.vo.ContsAuthrtVO; | |
5 | +import com.takensoft.cms.contsType.vo.ContsTypeVO; | |
6 | +import com.takensoft.common.util.ResponseData; | |
7 | +import lombok.RequiredArgsConstructor; | |
8 | +import lombok.extern.slf4j.Slf4j; | |
9 | +import org.springframework.http.HttpHeaders; | |
10 | +import org.springframework.http.HttpStatus; | |
11 | +import org.springframework.http.MediaType; | |
12 | +import org.springframework.http.ResponseEntity; | |
13 | +import org.springframework.web.bind.annotation.*; | |
14 | + | |
15 | +import java.nio.charset.Charset; | |
16 | +import java.util.List; | |
17 | + | |
18 | +/** | |
19 | + * @author : takensoft | |
20 | + * @since : 2024.04.17 | |
21 | + * | |
22 | + * 콘텐츠 유형 관리 관련 컨트롤러 | |
23 | + */ | |
24 | +@RestController | |
25 | +@RequiredArgsConstructor | |
26 | +@Slf4j | |
27 | +@RequestMapping(value = "/sys/contsType") | |
28 | +public class SystemContsTypeController { | |
29 | + | |
30 | + private final ContsTypeService contsTypeService; | |
31 | + | |
32 | + /** | |
33 | + * @author takensoft | |
34 | + * @since 2024.04.29 | |
35 | + * @param | |
36 | + * @return | |
37 | + * @throws Exception | |
38 | + */ | |
39 | + @PostMapping(value = "/findByContsTypeSys.json") | |
40 | + public ResponseEntity<?> findByContsTypeSys(ContsTypeVO contsTypeVO) throws Exception { | |
41 | + // 콘텐츠 유형 목록 조회 (메뉴 노출 건만) | |
42 | + List<ContsTypeVO> result = contsTypeService.findByContsTypeSys(contsTypeVO); | |
43 | + | |
44 | + // 응답 처리 | |
45 | + HttpHeaders headers = new HttpHeaders(); | |
46 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
47 | + ResponseData responseData = new ResponseData(); | |
48 | + responseData.setStatus(HttpStatus.OK); | |
49 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
50 | + responseData.setData(result); | |
51 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
52 | + } | |
53 | + | |
54 | + /** | |
55 | + * @author takensoft | |
56 | + * @since 2024.04.29 | |
57 | + * @param | |
58 | + * @return | |
59 | + * @throws Exception | |
60 | + */ | |
61 | + @PostMapping(value = "/findByContsAuthrtSys.json") | |
62 | + public ResponseEntity<?> findByContsTypeSys() throws Exception { | |
63 | + // 콘텐츠 유형 목록 조회 (메뉴 노출 건만) | |
64 | + List<ContsAuthrtVO> result = contsTypeService.findByContsAuthrt(); | |
65 | + | |
66 | + // 응답 처리 | |
67 | + HttpHeaders headers = new HttpHeaders(); | |
68 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
69 | + ResponseData responseData = new ResponseData(); | |
70 | + responseData.setStatus(HttpStatus.OK); | |
71 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
72 | + responseData.setData(result); | |
73 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
74 | + } | |
75 | +} |
+++ src/main/java/com/takensoft/cms/dept/dao/DeptDAO.java
... | ... | @@ -0,0 +1,132 @@ |
1 | +package com.takensoft.cms.dept.dao; | |
2 | + | |
3 | +import com.takensoft.cms.dept.vo.DeptAuthrtVO; | |
4 | +import com.takensoft.cms.dept.vo.DeptMbrVO; | |
5 | +import com.takensoft.cms.dept.vo.DeptVO; | |
6 | +import com.takensoft.common.HierachyVO; | |
7 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
8 | + | |
9 | +import java.util.List; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +/** | |
13 | + * @author : takensoft | |
14 | + * @since : 2024.04.24 | |
15 | + * | |
16 | + * 부서 정보 관련 Mapper | |
17 | + */ | |
18 | +@Mapper("deptDAO") | |
19 | +public interface DeptDAO { | |
20 | + /** | |
21 | + * @author takensoft | |
22 | + * @since 2024.04.25 | |
23 | + * 부서 등록 | |
24 | + */ | |
25 | + int save(DeptVO deptVO); | |
26 | + | |
27 | + /** | |
28 | + * @author takensoft | |
29 | + * @since 2024.04.25 | |
30 | + * 부서 권한 등록 | |
31 | + */ | |
32 | + int authrtSave(DeptAuthrtVO deptAuthrtVO); | |
33 | + | |
34 | + /** | |
35 | + * @author takensoft | |
36 | + * @since 2024.04.29 | |
37 | + * 부서 사용자 등록 | |
38 | + */ | |
39 | + int deptMbrSave(DeptMbrVO deptMbrVO); | |
40 | + | |
41 | + /** | |
42 | + * @author takensoft | |
43 | + * @since 2024.04.25 | |
44 | + * 부서 깊이(레벨) 조회 | |
45 | + */ | |
46 | + int findByDeptGrd(String upDeptId); | |
47 | + | |
48 | + /** | |
49 | + * @author takensoft | |
50 | + * @since 2024.04.25 | |
51 | + * 부서 순서 조회 | |
52 | + */ | |
53 | + int findByDeptSn(String upDeptId); | |
54 | + | |
55 | + /************************************** Hierachy 전용 **************************************/ | |
56 | + /** | |
57 | + * @author takensoft | |
58 | + * @since 2024.04.25 | |
59 | + * 최상위 부서 조회 | |
60 | + */ | |
61 | + List<HierachyVO> findByTopNode(); | |
62 | + /** | |
63 | + * @author takensoft | |
64 | + * @since 2024.04.24 | |
65 | + * 하위 부서 조회 | |
66 | + */ | |
67 | + List<HierachyVO> findChildNode(String id); | |
68 | + /************************************** Hierachy 전용 **************************************/ | |
69 | + | |
70 | + /** | |
71 | + * @author takensoft | |
72 | + * @since 2024.04.26 | |
73 | + * 부서 정보 조회 | |
74 | + */ | |
75 | + DeptVO findByDept(String deptId); | |
76 | + | |
77 | + /** | |
78 | + * @author takensoft | |
79 | + * @since 2024.04.26 | |
80 | + * 부서 정보 수정 | |
81 | + */ | |
82 | + int update(DeptVO deptVO); | |
83 | + | |
84 | + /** | |
85 | + * @author takensoft | |
86 | + * @since 2024.04.26 | |
87 | + * 부서 권한 삭제 | |
88 | + */ | |
89 | + int deleteAuth(String deptId); | |
90 | + | |
91 | + /** | |
92 | + * @author takensoft | |
93 | + * @since 2024.04.26 | |
94 | + * 부서 사용자 등록을 위한 사용자 정보 목록 조회 (부서에 등록되지 않은 사용자 목록) | |
95 | + */ | |
96 | + List<DeptMbrVO> findByMber(Map<String, String> params); | |
97 | + | |
98 | + /** | |
99 | + * @author takensoft | |
100 | + * @since 2024.04.26 | |
101 | + * 부서에 등록된 사용자 목록 조회 | |
102 | + */ | |
103 | + List<DeptMbrVO> findByDeptMber(String deptId); | |
104 | + | |
105 | + /** | |
106 | + * @author takensoft | |
107 | + * @since 2024.04.26 | |
108 | + * 상위,하위 부서 삭제 | |
109 | + */ | |
110 | + int deleteDept(String deptId); | |
111 | + | |
112 | + /** | |
113 | + * @author takensoft | |
114 | + * @since 2024.04.26 | |
115 | + * 상위, 하위 부서 삭제에 따른 부서의 사용자 삭제 | |
116 | + */ | |
117 | + int deleteDeptInDeptMbr(String deptId); | |
118 | + | |
119 | + /** | |
120 | + * @author takensoft | |
121 | + * @since 2024.04.26 | |
122 | + * 부서에 등록된 사용자 제거 | |
123 | + */ | |
124 | + int deleteDeptMbr(Map<String, Object> params); | |
125 | + | |
126 | + /** | |
127 | + * @author 박정하 | |
128 | + * @since 2024.05.10 | |
129 | + * 부서 정보 수정 (hierachyVO 사용) | |
130 | + */ | |
131 | + public int deptUpdateByHierachy(DeptVO deptVO) throws Exception; | |
132 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/dept/service/DeptService.java
... | ... | @@ -0,0 +1,94 @@ |
1 | +package com.takensoft.cms.dept.service; | |
2 | + | |
3 | +import com.takensoft.cms.dept.vo.DeptMbrVO; | |
4 | +import com.takensoft.cms.dept.vo.DeptVO; | |
5 | +import com.takensoft.common.HierachyVO; | |
6 | + | |
7 | +import java.util.HashMap; | |
8 | +import java.util.List; | |
9 | +import java.util.Map; | |
10 | + | |
11 | +/** | |
12 | + * @author : takensoft | |
13 | + * @since : 2024.04.09 | |
14 | + * | |
15 | + * 부서 정보 관련 인터페이스 | |
16 | + */ | |
17 | +public interface DeptService { | |
18 | + /** | |
19 | + * @author takensoft | |
20 | + * @since 2024.04.25 | |
21 | + * 부서 등록 | |
22 | + */ | |
23 | + public HashMap<String, Object> deptSave(DeptVO deptVO) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author takensoft | |
27 | + * @since 2024.04.29 | |
28 | + * 부서 사용자 등록 | |
29 | + */ | |
30 | + public int deptMbrSave(DeptMbrVO deptMbrVO) throws Exception; | |
31 | + | |
32 | + /************************************** Hierachy 전용 **************************************/ | |
33 | + /** | |
34 | + * @author takensoft | |
35 | + * @since 2024.04.25 | |
36 | + * 최상위 코드 조회 | |
37 | + */ | |
38 | + public List<HierachyVO> findByTopNode() throws Exception; | |
39 | + /** | |
40 | + * @author takensoft | |
41 | + * @since 2024.04.25 | |
42 | + * 하위 코드 조회 | |
43 | + */ | |
44 | + public List<HierachyVO> findChildNode(String id) throws Exception; | |
45 | + /************************************** Hierachy 전용 **************************************/ | |
46 | + | |
47 | + /** | |
48 | + * @author takensoft | |
49 | + * @since 2024.04.26 | |
50 | + * 부서 정보 조회 | |
51 | + */ | |
52 | + public Map<String, Object> findByDept(HashMap<String, Object> params) throws Exception; | |
53 | + | |
54 | + /** | |
55 | + * @author takensoft | |
56 | + * @since 2024.04.26 | |
57 | + * 부서 정보 수정 | |
58 | + */ | |
59 | + public int deptUpdate(DeptVO deptVO) throws Exception; | |
60 | + | |
61 | + /** | |
62 | + * @author takensoft | |
63 | + * @since 2024.04.26 | |
64 | + * 부서 정보 삭제 | |
65 | + */ | |
66 | + public int deptDelete(DeptVO deptVO) throws Exception; | |
67 | + | |
68 | + /** | |
69 | + * @author takensoft | |
70 | + * @since 2024.04.26 | |
71 | + * 부서 사용자 삭제 | |
72 | + */ | |
73 | + public int deptMbrDelete(List<DeptMbrVO> deptMbrList) throws Exception; | |
74 | + | |
75 | + /** | |
76 | + * @author takensoft | |
77 | + * @since 2024.04.29 | |
78 | + * 부서에 등록되지 않는 사용자 조회 | |
79 | + */ | |
80 | + public Map<String, Object> findByMbr(Map<String, String> params) throws Exception; | |
81 | + | |
82 | + /** | |
83 | + * @author 박정하 | |
84 | + * @since 2024.05.09 | |
85 | + * 부서 목록 수정 | |
86 | + */ | |
87 | + public int updateList(List<HierachyVO> deptList) throws Exception; | |
88 | + /** | |
89 | + * @author 박정하 | |
90 | + * @since 2024.05.10 | |
91 | + * 하위 부서 수정 | |
92 | + */ | |
93 | + public int updateChildNode(List<HierachyVO> childList, DeptVO upDeptVO) throws Exception; | |
94 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/dept/service/Impl/DeptServiceImpl.java
... | ... | @@ -0,0 +1,289 @@ |
1 | +package com.takensoft.cms.dept.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.dept.dao.DeptDAO; | |
4 | +import com.takensoft.cms.dept.service.DeptService; | |
5 | +import com.takensoft.cms.dept.vo.DeptAuthrtVO; | |
6 | +import com.takensoft.cms.dept.vo.DeptMbrVO; | |
7 | +import com.takensoft.cms.dept.vo.DeptVO; | |
8 | +import com.takensoft.common.HierachyVO; | |
9 | +import com.takensoft.common.idgen.service.IdgenService; | |
10 | +import com.takensoft.common.util.JWTUtil; | |
11 | +import com.takensoft.common.util.Secret; | |
12 | +import lombok.RequiredArgsConstructor; | |
13 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
14 | +import org.slf4j.Logger; | |
15 | +import org.slf4j.LoggerFactory; | |
16 | +import org.springframework.stereotype.Service; | |
17 | +import org.springframework.transaction.annotation.Transactional; | |
18 | + | |
19 | +import java.util.HashMap; | |
20 | +import java.util.List; | |
21 | +import java.util.Map; | |
22 | + | |
23 | +/** | |
24 | + * @author : takensoft | |
25 | + * @since : 2024.04.24 | |
26 | + * | |
27 | + * 부서 정보 관련 구현체 | |
28 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
29 | + * DeptService : 부서 정보 인터페이스 상속 | |
30 | + */ | |
31 | +@Service("deptService") | |
32 | +@RequiredArgsConstructor | |
33 | +public class DeptServiceImpl extends EgovAbstractServiceImpl implements DeptService { | |
34 | + | |
35 | + private static final Logger LOGGER = LoggerFactory.getLogger(DeptServiceImpl.class); | |
36 | + private final JWTUtil jwtUtil; | |
37 | + private final DeptDAO deptDAO; | |
38 | + private final IdgenService deptIdgn; | |
39 | + | |
40 | + /** | |
41 | + * @author takensoft | |
42 | + * @since 2024.04.25 | |
43 | + * 부서 등록 | |
44 | + */ | |
45 | + @Override | |
46 | + @Transactional(rollbackFor = Exception.class) | |
47 | + public HashMap<String, Object> deptSave(DeptVO deptVO) throws Exception { | |
48 | + String deptId = deptIdgn.getNextStringId(); // 부서 아이디 생성 | |
49 | + deptVO.setDeptId(deptId); | |
50 | + | |
51 | + // 상위 부서가 존재하는 경우 | |
52 | + if(deptVO.getUpDeptId() != null && !deptVO.getUpDeptId().equals("")) { | |
53 | + // 상위 부서보다 깊이(레벨) + 1 | |
54 | + deptVO.setDeptGrd(deptDAO.findByDeptGrd(deptVO.getUpDeptId()) + 1); | |
55 | + // 동일한 깊이의 부서 순서보다 + 1 | |
56 | + deptVO.setDeptSn(deptDAO.findByDeptSn(deptVO.getUpDeptId()) + 1); | |
57 | + // 상위 부서가 존재 하지 않는 경우 | |
58 | + } else { | |
59 | + deptVO.setDeptGrd(0); | |
60 | + deptVO.setDeptSn(deptDAO.findByDeptSn(null) + 1); | |
61 | + } | |
62 | + deptVO.setRgtr(jwtUtil.getWriter()); // 작성자 정보 등록 | |
63 | + int insertResult = deptDAO.save(deptVO); | |
64 | + // 부서 권한 등록 | |
65 | + if(deptVO.getAuthrtList().size() > 0) { | |
66 | + for(DeptAuthrtVO vo : deptVO.getAuthrtList()) { | |
67 | + vo.setDeptId(deptId); | |
68 | + vo.setRgtr(jwtUtil.getWriter()); | |
69 | + insertResult += deptDAO.authrtSave(vo); | |
70 | + } | |
71 | + } | |
72 | + HashMap<String, Object> result = new HashMap<>(); | |
73 | + result.put("deptId", deptId); | |
74 | + result.put("insertResult", insertResult); // 부서 등록 | |
75 | + return result; | |
76 | + } | |
77 | + | |
78 | + /** | |
79 | + * @author takensoft | |
80 | + * @since 2024.04.29 | |
81 | + * 부서 사용자 등록 | |
82 | + */ | |
83 | + @Override | |
84 | + public int deptMbrSave(DeptMbrVO deptMbrVO) throws Exception { | |
85 | + deptMbrVO.setRgtr(jwtUtil.getWriter()); // 작성자 정보 등록 | |
86 | + return deptDAO.deptMbrSave(deptMbrVO); | |
87 | + } | |
88 | + | |
89 | + /************************************** Hierachy 전용 **************************************/ | |
90 | + /** | |
91 | + * @author takensoft | |
92 | + * @since 2024.04.25 | |
93 | + * 최상위 부서 조회 | |
94 | + */ | |
95 | + @Override | |
96 | + public List<HierachyVO> findByTopNode() throws Exception { | |
97 | + List<HierachyVO> topDeptList = deptDAO.findByTopNode(); | |
98 | + for(HierachyVO vo : topDeptList) { | |
99 | + List<HierachyVO> child = findChildNode(vo.getId()); | |
100 | + vo.setChildList(child); | |
101 | + } | |
102 | + return topDeptList; | |
103 | + } | |
104 | + | |
105 | + /** | |
106 | + * @author takensoft | |
107 | + * @since 2024.04.25 | |
108 | + * 하위 부서 조회 | |
109 | + */ | |
110 | + @Override | |
111 | + public List<HierachyVO> findChildNode(String id) throws Exception { | |
112 | + List<HierachyVO> childList = deptDAO.findChildNode(id); | |
113 | + for(HierachyVO vo : childList) { | |
114 | + List<HierachyVO> child = findChildNode(vo.getId()); | |
115 | + vo.setChildList(child); | |
116 | + } | |
117 | + return childList; | |
118 | + } | |
119 | + /************************************** Hierachy 전용 **************************************/ | |
120 | + | |
121 | + /** | |
122 | + * @author takensoft | |
123 | + * @since 2024.04.26 | |
124 | + * 부서 정보 조회 | |
125 | + */ | |
126 | + @Override | |
127 | + public Map<String, Object> findByDept(HashMap<String, Object> params) throws Exception { | |
128 | + String deptId = params.get("deptId").toString(); // 아이디 추출 | |
129 | + DeptVO dept = deptDAO.findByDept(deptId); // 부서 정보 조회 | |
130 | + List<DeptMbrVO> deptMbr = deptDAO.findByDeptMber(deptId); // 부서에 등록된 사용자 정보 조회 | |
131 | + // 사용자 정보 복호화 | |
132 | + if(deptMbr.size() > 0) { | |
133 | + for(DeptMbrVO vo : deptMbr) { | |
134 | + // 연락처 복호화 | |
135 | + vo.setMblTelno(Secret.decrypt(vo.getMblTelno().toString())); | |
136 | + } | |
137 | + } | |
138 | + Map<String, Object> result = new HashMap<String, Object>(); // 반환 객체 생성 | |
139 | + result.put("dept", dept); // 부서 상세 정보 | |
140 | + result.put("deptMbr", deptMbr); // 부서 사용자 목록 정보 | |
141 | + return result; | |
142 | + } | |
143 | + | |
144 | + /** | |
145 | + * @author takensoft | |
146 | + * @since 2024.04.26 | |
147 | + * 부서 정보 수정 | |
148 | + */ | |
149 | + @Override | |
150 | + @Transactional(rollbackFor = Exception.class) | |
151 | + public int deptUpdate(DeptVO deptVO) throws Exception { | |
152 | + deptVO.setMdfr(jwtUtil.getWriter()); // 토큰에서 사용자 정보 추출 | |
153 | + int result = deptDAO.update(deptVO); // 부서정보 수정 | |
154 | + result += deptDAO.deleteAuth(deptVO.getDeptId()); // 부서 권한 삭제 | |
155 | + // 부서 권한 등록 | |
156 | + if(deptVO.getAuthrtList().size() > 0) { | |
157 | + for(DeptAuthrtVO vo : deptVO.getAuthrtList()) { | |
158 | + vo.setDeptId(deptVO.getDeptId()); | |
159 | + vo.setRgtr(jwtUtil.getWriter()); | |
160 | + result += deptDAO.authrtSave(vo); | |
161 | + } | |
162 | + } | |
163 | + return result; | |
164 | + } | |
165 | + | |
166 | + /** | |
167 | + * @author takensoft | |
168 | + * @since 2024.04.26 | |
169 | + * 부서 정보 삭제 | |
170 | + */ | |
171 | + @Override | |
172 | + @Transactional(rollbackFor = Exception.class) | |
173 | + public int deptDelete(DeptVO deptVO) throws Exception { | |
174 | + int result = deptDAO.deleteDept(deptVO.getDeptId()); | |
175 | + result += deptDAO.deleteDeptInDeptMbr(deptVO.getDeptId()); | |
176 | + return result; | |
177 | + } | |
178 | + | |
179 | + /** | |
180 | + * @author takensoft | |
181 | + * @since 2024.04.26 | |
182 | + * 부서 사용자 삭제 | |
183 | + */ | |
184 | + @Override | |
185 | + @Transactional(rollbackFor = Exception.class) | |
186 | + public int deptMbrDelete(List<DeptMbrVO> deptMbrList) throws Exception { | |
187 | + int result = 0; | |
188 | + if(deptMbrList.size() == 0) return 0; | |
189 | + for(DeptMbrVO vo : deptMbrList) { | |
190 | + Map<String, Object> param = new HashMap<String, Object>(); | |
191 | + param.put("mbrId", vo.getMbrId()); | |
192 | + result += deptDAO.deleteDeptMbr(param); | |
193 | + } | |
194 | + return result; | |
195 | + } | |
196 | + | |
197 | + /** | |
198 | + * @author takensoft | |
199 | + * @since 2024.04.29 | |
200 | + * 부서에 등록되지 않는 사용자 조회 | |
201 | + */ | |
202 | + @Override | |
203 | + public Map<String, Object> findByMbr(Map<String, String> params) throws Exception { | |
204 | + List<DeptMbrVO> mbrList = deptDAO.findByMber(params); // 부서에 등록되지 않는 사용자 조회 | |
205 | + // 사용자 정보 복호화 | |
206 | + if(mbrList.size() > 0) { | |
207 | + for(DeptMbrVO vo : mbrList) { | |
208 | + // 연락처 복호화 | |
209 | + vo.setMblTelno(Secret.decrypt(vo.getMblTelno().toString())); | |
210 | + } | |
211 | + } | |
212 | + List<DeptMbrVO> deptMbr = deptDAO.findByDeptMber(params.get("deptId").toString()); // 부서에 등록된 사용자 정보 조회 | |
213 | + // 사용자 정보 복호화 | |
214 | + if(deptMbr.size() > 0) { | |
215 | + for(DeptMbrVO vo : deptMbr) { | |
216 | + // 연락처 복호화 | |
217 | + vo.setMblTelno(Secret.decrypt(vo.getMblTelno().toString())); | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + Map<String, Object> result = new HashMap<String, Object>(); // 반환 객체 생성 | |
222 | + result.put("mbrList", mbrList); // 부서에 등록되지 않는 사용자 정보 | |
223 | + result.put("deptMbr", deptMbr); // 부서 사용자 목록 정보 | |
224 | + return result; | |
225 | + } | |
226 | + | |
227 | + /** | |
228 | + * @author 박정하 | |
229 | + * @since 2024.05.10 | |
230 | + * 부서 정보 수정 (hierachyVO 사용) | |
231 | + */ | |
232 | + @Override | |
233 | + @Transactional(rollbackFor = Exception.class) | |
234 | + public int updateList(List<HierachyVO> deptList) throws Exception { | |
235 | + int result = 0; | |
236 | + String writer = jwtUtil.getWriter(); | |
237 | + | |
238 | + if(deptList != null && deptList.size() > 0) { | |
239 | + int sn = 1; | |
240 | + for(HierachyVO hierachyVO : deptList) { | |
241 | + // 최상위 노드 수정 | |
242 | + DeptVO vo = new DeptVO(); | |
243 | + vo.setDeptId(hierachyVO.getId()); | |
244 | + vo.setUpDeptId(null); | |
245 | + vo.setDeptGrd(0); | |
246 | + vo.setDeptSn(sn); | |
247 | + vo.setMdfr(writer); | |
248 | + result += deptDAO.deptUpdateByHierachy(vo); | |
249 | + | |
250 | + // 하위 노드 수정 | |
251 | + if (hierachyVO.getChildList() != null && hierachyVO.getChildList().size() > 0) { | |
252 | + result += updateChildNode(hierachyVO.getChildList(), vo); | |
253 | + } | |
254 | + sn++; | |
255 | + } | |
256 | + } | |
257 | + return result; | |
258 | + } | |
259 | + /** | |
260 | + * @author 박정하 | |
261 | + * @since 2024.05.10 | |
262 | + * 하위 부서 수정 | |
263 | + */ | |
264 | + @Override | |
265 | + public int updateChildNode(List<HierachyVO> childList, DeptVO upDeptVO) throws Exception { | |
266 | + int result = 0; | |
267 | + String upDeptId = upDeptVO.getDeptId(); | |
268 | + int grd = upDeptVO.getDeptGrd() + 1; | |
269 | + int sn = 1; | |
270 | + String mdfr = upDeptVO.getMdfr(); | |
271 | + for(HierachyVO hierachyVO : childList) { | |
272 | + // 현재 노드 수정 | |
273 | + DeptVO vo = new DeptVO(); | |
274 | + vo.setDeptId(hierachyVO.getId()); | |
275 | + vo.setUpDeptId(upDeptId); | |
276 | + vo.setDeptGrd(grd); | |
277 | + vo.setDeptSn(sn); | |
278 | + vo.setMdfr(mdfr); | |
279 | + result += deptDAO.deptUpdateByHierachy(vo); | |
280 | + | |
281 | + // 하위 노드 수정 | |
282 | + if (hierachyVO.getChildList() != null && hierachyVO.getChildList().size() > 0) { | |
283 | + result += updateChildNode(hierachyVO.getChildList(), vo); | |
284 | + } | |
285 | + sn++; | |
286 | + } | |
287 | + return result; | |
288 | + } | |
289 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/dept/vo/DeptAuthrtVO.java
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.takensoft.cms.dept.vo; | |
2 | + | |
3 | +import lombok.*; | |
4 | + | |
5 | +/** | |
6 | + * @author : takensoft | |
7 | + * @since : 2024.04.25 | |
8 | + * | |
9 | + * 부서 권한 정보 관련 VO | |
10 | + */ | |
11 | +@Getter | |
12 | +@Setter | |
13 | +@ToString | |
14 | +@Builder | |
15 | +@AllArgsConstructor | |
16 | +@NoArgsConstructor | |
17 | +public class DeptAuthrtVO { | |
18 | + /** | |
19 | + * 부서 아이디 | |
20 | + */ | |
21 | + private String deptId; | |
22 | + /** | |
23 | + * 권한 코드 | |
24 | + */ | |
25 | + private String authrtCd; | |
26 | + /** | |
27 | + * 작성자 | |
28 | + */ | |
29 | + private String rgtr; | |
30 | + /** | |
31 | + * 작성일 | |
32 | + */ | |
33 | + private String regDt; | |
34 | +} |
+++ src/main/java/com/takensoft/cms/dept/vo/DeptMbrVO.java
... | ... | @@ -0,0 +1,55 @@ |
1 | +package com.takensoft.cms.dept.vo; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import lombok.Setter; | |
7 | + | |
8 | +/** | |
9 | + * @author : takensoft | |
10 | + * @since : 2024.04.26 | |
11 | + * | |
12 | + * 부서 사용자 정보 관련 VO | |
13 | + */ | |
14 | +@Setter | |
15 | +@Getter | |
16 | +@NoArgsConstructor | |
17 | +@AllArgsConstructor | |
18 | +public class DeptMbrVO { | |
19 | + /** | |
20 | + * 부서 아이디 | |
21 | + */ | |
22 | + private String deptId; | |
23 | + /** | |
24 | + * 회원 아이디 | |
25 | + */ | |
26 | + private String mbrId; | |
27 | + /** | |
28 | + * 로그인 아이디 | |
29 | + */ | |
30 | + private String lgnId; | |
31 | + /** | |
32 | + * 회원 이름 | |
33 | + */ | |
34 | + private String mbrNm; | |
35 | + /** | |
36 | + * 닉네임 | |
37 | + */ | |
38 | + private String ncnm; | |
39 | + /** | |
40 | + * 이메일 | |
41 | + */ | |
42 | + private String eml; | |
43 | + /** | |
44 | + * 연락처 | |
45 | + */ | |
46 | + private String mblTelno; | |
47 | + /** | |
48 | + * 등록자 | |
49 | + */ | |
50 | + private String rgtr; | |
51 | + /** | |
52 | + * 등록일 | |
53 | + */ | |
54 | + private String regDt; | |
55 | +} |
+++ src/main/java/com/takensoft/cms/dept/vo/DeptVO.java
... | ... | @@ -0,0 +1,76 @@ |
1 | +package com.takensoft.cms.dept.vo; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | + | |
9 | +import java.util.ArrayList; | |
10 | +import java.util.List; | |
11 | + | |
12 | +/** | |
13 | + * @author : takensoft | |
14 | + * @since : 2024.04.24 | |
15 | + * | |
16 | + * 부서 정보 관련 VO | |
17 | + */ | |
18 | +@Setter | |
19 | +@Getter | |
20 | +@NoArgsConstructor | |
21 | +@AllArgsConstructor | |
22 | +public class DeptVO { | |
23 | + /** | |
24 | + * 부서 아이디 | |
25 | + */ | |
26 | + private String deptId; | |
27 | + /** | |
28 | + * 상위 부서 아이디 | |
29 | + */ | |
30 | + private String upDeptId; | |
31 | + /** | |
32 | + * 부서명 | |
33 | + */ | |
34 | + private String deptNm; | |
35 | + /** | |
36 | + * 상위부서명 | |
37 | + */ | |
38 | + private String upDeptNm; | |
39 | + /** | |
40 | + * 부서설명 | |
41 | + */ | |
42 | + private String deptExpln; | |
43 | + /** | |
44 | + * 부서 깊이(레벨) | |
45 | + */ | |
46 | + private int deptGrd; | |
47 | + /** | |
48 | + * 부서 순서 | |
49 | + */ | |
50 | + private int deptSn; | |
51 | + /** | |
52 | + * 사용여부 | |
53 | + */ | |
54 | + private String useYn; | |
55 | + /** | |
56 | + * 작성자 | |
57 | + */ | |
58 | + private String rgtr; | |
59 | + /** | |
60 | + * 작성일 | |
61 | + */ | |
62 | + private String regDt; | |
63 | + /** | |
64 | + * 수정자 | |
65 | + */ | |
66 | + private String mdfr; | |
67 | + /** | |
68 | + * 수정일 | |
69 | + */ | |
70 | + private String mdfcnDt; | |
71 | + /** | |
72 | + * 권한정보 | |
73 | + */ | |
74 | + private List<DeptAuthrtVO> authrtList = new ArrayList<DeptAuthrtVO>(); | |
75 | + | |
76 | +} |
+++ src/main/java/com/takensoft/cms/dept/web/DeptController.java
... | ... | @@ -0,0 +1,297 @@ |
1 | +package com.takensoft.cms.dept.web; | |
2 | + | |
3 | +import com.takensoft.cms.author.service.AuthorService; | |
4 | +import com.takensoft.cms.author.vo.AuthorVO; | |
5 | +import com.takensoft.cms.dept.service.DeptService; | |
6 | +import com.takensoft.cms.dept.vo.DeptMbrVO; | |
7 | +import com.takensoft.cms.dept.vo.DeptVO; | |
8 | +import com.takensoft.common.HierachyVO; | |
9 | +import com.takensoft.common.util.ResponseData; | |
10 | +import lombok.RequiredArgsConstructor; | |
11 | +import lombok.extern.slf4j.Slf4j; | |
12 | +import org.springframework.http.HttpHeaders; | |
13 | +import org.springframework.http.HttpStatus; | |
14 | +import org.springframework.http.MediaType; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | + | |
18 | +import java.nio.charset.Charset; | |
19 | +import java.util.HashMap; | |
20 | +import java.util.List; | |
21 | +import java.util.Map; | |
22 | + | |
23 | +/** | |
24 | + * @author : takensoft | |
25 | + * @since : 2024.04.24 | |
26 | + * | |
27 | + * 부서 정보 관련 컨트롤러 | |
28 | + */ | |
29 | +@RestController | |
30 | +@RequiredArgsConstructor | |
31 | +@Slf4j | |
32 | +@RequestMapping("/admin/dept") | |
33 | +public class DeptController { | |
34 | + | |
35 | + private final DeptService deptService; | |
36 | + private final AuthorService authorService; | |
37 | + | |
38 | + /** | |
39 | + * @author takensoft | |
40 | + * @since 2024.04.25 | |
41 | + * @param deptVO | |
42 | + * @return | |
43 | + * @throws Exception | |
44 | + * | |
45 | + * 부서 등록 | |
46 | + */ | |
47 | + @PostMapping("/saveProc.json") | |
48 | + public ResponseEntity<?> saveProc(@RequestBody DeptVO deptVO) throws Exception { | |
49 | + // 부서 등록 | |
50 | + HashMap<String, Object> result = deptService.deptSave(deptVO); | |
51 | + int insertResult = (int) result.get("insertResult"); | |
52 | + | |
53 | + // 응답 처리 | |
54 | + HttpHeaders headers = new HttpHeaders(); | |
55 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
56 | + ResponseData responseData = new ResponseData(); | |
57 | + | |
58 | + if(insertResult > 0) { | |
59 | + responseData.setStatus(HttpStatus.OK); | |
60 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
61 | + responseData.setData(result); | |
62 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
63 | + } else { | |
64 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
65 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
66 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
67 | + } | |
68 | + } | |
69 | + | |
70 | + /** | |
71 | + * @author takensoft | |
72 | + * @since 2024.04.29 | |
73 | + * @param deptMbrVO | |
74 | + * @return | |
75 | + * @throws Exception | |
76 | + * | |
77 | + * 부서 사용자 등록 | |
78 | + */ | |
79 | + @PostMapping("/deptMbrSaveProc.json") | |
80 | + public ResponseEntity<?> deptMbrSaveProc(@RequestBody DeptMbrVO deptMbrVO) throws Exception { | |
81 | + // 부서 사용자 등록 | |
82 | + int result = deptService.deptMbrSave(deptMbrVO); | |
83 | + | |
84 | + // 응답 처리 | |
85 | + HttpHeaders headers = new HttpHeaders(); | |
86 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
87 | + ResponseData responseData = new ResponseData(); | |
88 | + | |
89 | + if(result > 0) { | |
90 | + responseData.setStatus(HttpStatus.OK); | |
91 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
92 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
93 | + } else { | |
94 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
95 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
96 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
97 | + } | |
98 | + } | |
99 | + | |
100 | + /** | |
101 | + * @author takensoft | |
102 | + * @since 2024.04.25 | |
103 | + * @param | |
104 | + * @return | |
105 | + * @throws Exception | |
106 | + * | |
107 | + * 부서 목록 조회 | |
108 | + */ | |
109 | + @GetMapping(value = "/findAll.json") | |
110 | + public ResponseEntity<?> findAll() throws Exception { | |
111 | + // Tree용 | |
112 | + List<HierachyVO> hierachyList = deptService.findByTopNode(); | |
113 | + // 권한 목록 조회 | |
114 | + List<AuthorVO> authList = authorService.findAllSystem(); | |
115 | + | |
116 | + Map<String, Object> result = new HashMap<String, Object>(); | |
117 | + result.put("hierachyList", hierachyList); | |
118 | + result.put("authList", authList); | |
119 | + result.put("newDept", new DeptVO()); | |
120 | + | |
121 | + // 응답 처리 | |
122 | + HttpHeaders headers = new HttpHeaders(); | |
123 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
124 | + ResponseData responseData = new ResponseData(); | |
125 | + responseData.setStatus(HttpStatus.OK); | |
126 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
127 | + responseData.setData(result); | |
128 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
129 | + } | |
130 | + | |
131 | + /** | |
132 | + * @author takensoft | |
133 | + * @since 2024.04.26 | |
134 | + * @param | |
135 | + * @return | |
136 | + * @throws Exception | |
137 | + * | |
138 | + * 부서정보 상세 조회 | |
139 | + */ | |
140 | + @PostMapping(value = "/findByDept.json") | |
141 | + public ResponseEntity<?> findByDept(@RequestBody HashMap<String, Object> params) throws Exception { | |
142 | + // 부서정보 조회 | |
143 | + Map<String, Object> result = deptService.findByDept(params); | |
144 | + | |
145 | + // 응답 처리 | |
146 | + HttpHeaders headers = new HttpHeaders(); | |
147 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
148 | + ResponseData responseData = new ResponseData(); | |
149 | + responseData.setStatus(HttpStatus.OK); | |
150 | + responseData.setMessage("정상적으로 조회 처리되었습니다."); | |
151 | + responseData.setData(result); | |
152 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
153 | + } | |
154 | + | |
155 | + /** | |
156 | + * @author takensoft | |
157 | + * @since 2024.04.26 | |
158 | + * @param deptVO | |
159 | + * @return | |
160 | + * @throws Exception | |
161 | + * | |
162 | + * 부서 수정 | |
163 | + */ | |
164 | + @PostMapping(value = "/updateProc.json") | |
165 | + public ResponseEntity<?> updateProc(@RequestBody DeptVO deptVO) throws Exception { | |
166 | + // 부서 수정 | |
167 | + int result = deptService.deptUpdate(deptVO); | |
168 | + | |
169 | + // 응답 처리 | |
170 | + HttpHeaders headers = new HttpHeaders(); | |
171 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
172 | + ResponseData responseData = new ResponseData(); | |
173 | + | |
174 | + if(result > 0) { | |
175 | + responseData.setStatus(HttpStatus.OK); | |
176 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
177 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
178 | + } else { | |
179 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
180 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
181 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
182 | + } | |
183 | + } | |
184 | + | |
185 | + /** | |
186 | + * @author takensoft | |
187 | + * @since 2024.04.26 | |
188 | + * @param deptVO | |
189 | + * @return | |
190 | + * @throws Exception | |
191 | + * | |
192 | + * 부서 삭제 | |
193 | + */ | |
194 | + @PostMapping(value = "/deleteProc.json") | |
195 | + public ResponseEntity<?> deleteProc(@RequestBody DeptVO deptVO) throws Exception { | |
196 | + // 부서 수정 | |
197 | + int result = deptService.deptDelete(deptVO); | |
198 | + | |
199 | + // 응답 처리 | |
200 | + HttpHeaders headers = new HttpHeaders(); | |
201 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
202 | + ResponseData responseData = new ResponseData(); | |
203 | + | |
204 | + if(result > 0) { | |
205 | + responseData.setStatus(HttpStatus.OK); | |
206 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
207 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
208 | + } else { | |
209 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
210 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
211 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
212 | + } | |
213 | + } | |
214 | + | |
215 | + /** | |
216 | + * @author takensoft | |
217 | + * @since 2024.04.26 | |
218 | + * @param | |
219 | + * @return | |
220 | + * @throws Exception | |
221 | + * | |
222 | + * 부서 사용자 삭제 | |
223 | + */ | |
224 | + @PostMapping(value = "/deptMbrDelProc.json") | |
225 | + public ResponseEntity<?> deptMbrDelProc(@RequestBody List<DeptMbrVO> deptMbrList) throws Exception { | |
226 | + // 부서 사용자 삭제 | |
227 | + int result = deptService.deptMbrDelete(deptMbrList); | |
228 | + | |
229 | + // 응답 처리 | |
230 | + HttpHeaders headers = new HttpHeaders(); | |
231 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
232 | + ResponseData responseData = new ResponseData(); | |
233 | + | |
234 | + if(result > 0) { | |
235 | + responseData.setStatus(HttpStatus.OK); | |
236 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
237 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
238 | + } else { | |
239 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
240 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
241 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
242 | + } | |
243 | + } | |
244 | + | |
245 | + /** | |
246 | + * @author takensoft | |
247 | + * @since 2024.04.29 | |
248 | + * @param | |
249 | + * @return | |
250 | + * @throws Exception | |
251 | + * | |
252 | + * 부서에 등록되지 않는 사용자 조회 | |
253 | + */ | |
254 | + @PostMapping("/findByMbr.json") | |
255 | + public ResponseEntity<?> findByMbr(@RequestBody Map<String, String> params) throws Exception { | |
256 | + // 사용자 목록 조회 | |
257 | + Map<String, Object> result = deptService.findByMbr(params); | |
258 | + | |
259 | + // 응답 처리 | |
260 | + HttpHeaders headers = new HttpHeaders(); | |
261 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
262 | + ResponseData responseData = new ResponseData(); | |
263 | + responseData.setStatus(HttpStatus.OK); | |
264 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
265 | + responseData.setData(result); | |
266 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
267 | + } | |
268 | + | |
269 | + /** | |
270 | + * @author 박정하 | |
271 | + * @since 2024.05.09 | |
272 | + * @param deptList | |
273 | + * @return | |
274 | + * @throws Exception | |
275 | + * | |
276 | + * 부서 목록 수정 | |
277 | + */ | |
278 | + @PostMapping(value = "/updateListProc.json") | |
279 | + public ResponseEntity<?> updateListProc(@RequestBody List<HierachyVO> deptList) throws Exception { | |
280 | + // 부서 목록 수정 | |
281 | + int result = deptService.updateList(deptList); | |
282 | + | |
283 | + // 응답 처리 | |
284 | + HttpHeaders headers = new HttpHeaders(); | |
285 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
286 | + ResponseData responseData = new ResponseData(); | |
287 | + if(result > 0) { | |
288 | + responseData.setStatus(HttpStatus.OK); | |
289 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
290 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
291 | + } else { | |
292 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
293 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
294 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
295 | + } | |
296 | + } | |
297 | +} |
+++ src/main/java/com/takensoft/cms/main/dao/MainDAO.java
... | ... | @@ -0,0 +1,62 @@ |
1 | +package com.takensoft.cms.main.dao; | |
2 | + | |
3 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
4 | + | |
5 | +import java.util.*; | |
6 | + | |
7 | +/** | |
8 | + * @author : 박정하 | |
9 | + * @since : 2024.05.29 | |
10 | + * | |
11 | + * 메인 관련 Mapper | |
12 | + */ | |
13 | +@Mapper("mainDAO") | |
14 | +public interface MainDAO { | |
15 | + /** | |
16 | + * @author : 박정하 | |
17 | + * @since : 2024.05.28 | |
18 | + * | |
19 | + * 관리자 메인페이지 : 신규회원 가입자 수 | |
20 | + */ | |
21 | + public int selectCntnNewCnt() throws Exception; | |
22 | + | |
23 | + /** | |
24 | + * @author : 박정하 | |
25 | + * @since : 2024.05.28 | |
26 | + * | |
27 | + * 관리자 메인페이지 : 오늘 방문자 수 | |
28 | + */ | |
29 | + public int selectCntnDayCnt() throws Exception; | |
30 | + | |
31 | + /** | |
32 | + * @author : 박정하 | |
33 | + * @since : 2024.05.28 | |
34 | + * | |
35 | + * 관리자 메인페이지 : 이번달 방문자 수 | |
36 | + */ | |
37 | + public int selectCntnMmCnt() throws Exception; | |
38 | + | |
39 | + /** | |
40 | + * @author : 박정하 | |
41 | + * @since : 2024.05.28 | |
42 | + * | |
43 | + * 관리자 메인페이지 : 총 방문자 수 | |
44 | + */ | |
45 | + public int selectCntnTotalCnt() throws Exception; | |
46 | + | |
47 | + /** | |
48 | + * @author : 박정하 | |
49 | + * @since : 2024.05.28 | |
50 | + * | |
51 | + * 관리자 메인페이지 : 방문자 접속 통계 | |
52 | + */ | |
53 | + public List<HashMap<String, Object>> findByMonthCntnStats() throws Exception; | |
54 | + | |
55 | + /** | |
56 | + * @author : 박정하 | |
57 | + * @since : 2024.05.28 | |
58 | + * | |
59 | + * 관리자 메인페이지 : 기업상담신청 알림 | |
60 | + */ | |
61 | + public List<HashMap<String, Object>> findAplyToasts() throws Exception; | |
62 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/main/service/Impl/MainServiceImpl.java
... | ... | @@ -0,0 +1,71 @@ |
1 | +package com.takensoft.cms.main.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.bbs.dao.BbsCnDAO; | |
4 | +import com.takensoft.cms.main.dao.MainDAO; | |
5 | +import com.takensoft.cms.main.service.MainService; | |
6 | +import com.takensoft.cms.popup.dao.PopupDAO; | |
7 | +import lombok.RequiredArgsConstructor; | |
8 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
9 | +import org.springframework.stereotype.Service; | |
10 | + | |
11 | +import java.util.*; | |
12 | + | |
13 | +/** | |
14 | + * @author : 박정하 | |
15 | + * @since : 2024.05.29 | |
16 | + * | |
17 | + * 메인 관련 인터페이스 | |
18 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
19 | + * GovernmentMainService : 메인 관련 인터페이스 상속 | |
20 | + */ | |
21 | +@Service("mainService") | |
22 | +@RequiredArgsConstructor | |
23 | +public class MainServiceImpl extends EgovAbstractServiceImpl implements MainService { | |
24 | + private final MainDAO mainDAO; | |
25 | + private final PopupDAO popupDAO; | |
26 | + private final BbsCnDAO bbsCnDAO; | |
27 | + | |
28 | + /** | |
29 | + * @author takensoft | |
30 | + * @since 2024.05.27 | |
31 | + * | |
32 | + * 관리자 메인페이지 통계정보 조회 [ 신규회원 가입자 수, 오늘 방문자 수, 이번달 방문자 수, 총 방문자 수 ] | |
33 | + */ | |
34 | + @Override | |
35 | + public Map<String, Object> selectAdminMain() throws Exception { | |
36 | + Map<String, Object> result = new HashMap<>(); | |
37 | + | |
38 | + // 팝업 관리 | |
39 | + result.put("popupMng", popupDAO.selectPopupListByNew()); | |
40 | + | |
41 | + // 최신 등록 글 | |
42 | + result.put("bbsCnNew", bbsCnDAO.selectBbsCnListByNew()); | |
43 | + | |
44 | + // 신규회원 가입자 수 | |
45 | + // result.put("cntnNewCnt", mainDAO.selectCntnNewCnt()); | |
46 | + | |
47 | + // 오늘 방문자 수 | |
48 | + result.put("cntnDayCnt", mainDAO.selectCntnDayCnt()); | |
49 | + | |
50 | + // 이번달 방문자 수 | |
51 | + result.put("cntnMmCnt", mainDAO.selectCntnMmCnt()); | |
52 | + | |
53 | + // 총 방문자 수 | |
54 | + result.put("cntnTotalCnt", mainDAO.selectCntnTotalCnt()); | |
55 | + | |
56 | + // 방문자 접속 통계 | |
57 | + result.put("monthCntnStats", mainDAO.findByMonthCntnStats()); | |
58 | + | |
59 | + return result; | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * @author 박정하 | |
64 | + * @since 2024.06.14 | |
65 | + * | |
66 | + * 관리자 메인페이지 기업상담신청 알람 | |
67 | + */ | |
68 | + public List<HashMap<String, Object>> findAplyToasts() throws Exception { | |
69 | + return mainDAO.findAplyToasts(); | |
70 | + } | |
71 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/main/service/MainService.java
... | ... | @@ -0,0 +1,27 @@ |
1 | +package com.takensoft.cms.main.service; | |
2 | + | |
3 | +import java.util.*; | |
4 | + | |
5 | +/** | |
6 | + * @author : 박정하 | |
7 | + * @since : 2024.05.29 | |
8 | + * | |
9 | + * 메인 관련 인터페이스 | |
10 | + */ | |
11 | +public interface MainService { | |
12 | + /** | |
13 | + * @author takensoft | |
14 | + * @since 2024.05.27 | |
15 | + * | |
16 | + * 관리자 메인페이지 통계정보 조회 [ 신규회원 가입자 수, 오늘 방문자 수, 이번달 방문자 수, 총 방문자 수 ] | |
17 | + */ | |
18 | + public Map<String, Object> selectAdminMain() throws Exception; | |
19 | + | |
20 | + /** | |
21 | + * @author 박정하 | |
22 | + * @since 2024.06.14 | |
23 | + * | |
24 | + * 관리자 메인페이지 기업상담신청 알람 | |
25 | + */ | |
26 | + public List<HashMap<String, Object>> findAplyToasts() throws Exception; | |
27 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/main/web/MainController.java
... | ... | @@ -0,0 +1,107 @@ |
1 | +package com.takensoft.cms.main.web; | |
2 | + | |
3 | +import com.takensoft.cms.main.service.MainService; | |
4 | +import com.takensoft.common.util.ResponseData; | |
5 | +import lombok.RequiredArgsConstructor; | |
6 | +import org.springframework.cache.CacheManager; | |
7 | +import org.springframework.http.HttpHeaders; | |
8 | +import org.springframework.http.HttpStatus; | |
9 | +import org.springframework.http.MediaType; | |
10 | +import org.springframework.http.ResponseEntity; | |
11 | +import org.springframework.web.bind.annotation.PostMapping; | |
12 | +import org.springframework.web.bind.annotation.RequestMapping; | |
13 | +import org.springframework.web.bind.annotation.RestController; | |
14 | + | |
15 | +import java.nio.charset.Charset; | |
16 | +import java.util.*; | |
17 | + | |
18 | +/** | |
19 | + * @author : 박정하 | |
20 | + * @since : 2024.05.29 | |
21 | + * | |
22 | + * 메인 관련 컨트롤러 | |
23 | + */ | |
24 | +@RestController | |
25 | +@RequiredArgsConstructor | |
26 | +@RequestMapping(value = "/admin/main") | |
27 | +public class MainController { | |
28 | + private final MainService mainService; | |
29 | + private final CacheManager cacheManager; // 캐시를 관리하기 위한 CacheManager 인스턴스 | |
30 | + | |
31 | + /** | |
32 | + * @author takensoft | |
33 | + * @since 2024.05.27 | |
34 | + * @param | |
35 | + * @return | |
36 | + * @throws Exception | |
37 | + * | |
38 | + * 관리자 메인페이지 통계정보 조회 [ 신규회원 가입자 수, 오늘 방문자 수, 이번달 방문자 수, 총 방문자 수, 방문자 접속 통계 ] | |
39 | + */ | |
40 | + @PostMapping("/adminMainProc.json") | |
41 | + public ResponseEntity<?> adminMainProc() throws Exception { | |
42 | + // 관리자 메인페이지 통계정보 조회 | |
43 | + Map<String, Object> result = mainService.selectAdminMain(); | |
44 | + | |
45 | + // 응답 처리 | |
46 | + HttpHeaders headers = new HttpHeaders(); | |
47 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
48 | + ResponseData responseData = new ResponseData(); | |
49 | + responseData.setStatus(HttpStatus.OK); | |
50 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
51 | + responseData.setData(result); | |
52 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
53 | + } | |
54 | + | |
55 | + /** | |
56 | + * @author takensoft | |
57 | + * @since 2024.05.29 | |
58 | + * @param | |
59 | + * @return | |
60 | + * @throws Exception | |
61 | + * | |
62 | + * 캐시 초기화 | |
63 | + */ | |
64 | + @PostMapping("/cacheReSet.json") | |
65 | + public ResponseEntity<?> serverRestart() throws Exception { | |
66 | + // 응답 처리 | |
67 | + HttpHeaders headers = new HttpHeaders(); | |
68 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
69 | + ResponseData responseData = new ResponseData(); | |
70 | + | |
71 | + try { | |
72 | + for(String nm : cacheManager.getCacheNames()) { | |
73 | + cacheManager.getCache(nm).clear(); | |
74 | + } | |
75 | + responseData.setStatus(HttpStatus.OK); | |
76 | + responseData.setMessage("정상적으로 처리되었습니다."); | |
77 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
78 | + } catch (Exception e) { | |
79 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
80 | + responseData.setMessage("적용에 실패했습니다.\n관리자에게 문의해주시기 바랍니다."); | |
81 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
82 | + } | |
83 | + } | |
84 | + | |
85 | + /** | |
86 | + * @author 박정하 | |
87 | + * @since 2024.06.14 | |
88 | + * @param | |
89 | + * @return | |
90 | + * @throws Exception | |
91 | + * | |
92 | + * 관리자 메인페이지 기업상담신청 알람 | |
93 | + */ | |
94 | + @PostMapping("/findAplyToastsProc.json") | |
95 | + public ResponseEntity<?> findAplyToastsProc() throws Exception { | |
96 | + List<HashMap<String, Object>> result = mainService.findAplyToasts(); | |
97 | + | |
98 | + // 응답 처리 | |
99 | + HttpHeaders headers = new HttpHeaders(); | |
100 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
101 | + ResponseData responseData = new ResponseData(); | |
102 | + responseData.setStatus(HttpStatus.OK); | |
103 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
104 | + responseData.setData(result); | |
105 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
106 | + } | |
107 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/Schedule/RefreshScheduler.java
... | ... | @@ -0,0 +1,34 @@ |
1 | +package com.takensoft.cms.mber.Schedule; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dao.RefreshTokenDAO; | |
4 | +import org.springframework.scheduling.annotation.Scheduled; | |
5 | +import org.springframework.stereotype.Component; | |
6 | +import org.springframework.transaction.annotation.Transactional; | |
7 | + | |
8 | +/** | |
9 | + * @author : takensoft | |
10 | + * @since : 2024.04.01 | |
11 | + * | |
12 | + * RefreshToken 만료 기한이 된 token 제거를 위한 스케쥴러 | |
13 | + */ | |
14 | +@Component | |
15 | +public class RefreshScheduler { | |
16 | + | |
17 | + private final RefreshTokenDAO refreshTokenDAO; | |
18 | + | |
19 | + public RefreshScheduler(RefreshTokenDAO refreshTokenDAO) { | |
20 | + this.refreshTokenDAO = refreshTokenDAO; | |
21 | + } | |
22 | + | |
23 | + /** | |
24 | + * @author takensoft | |
25 | + * @since 2024.04.05 | |
26 | + * refresh token 삭제 스케쥴러 | |
27 | + * 매일 자정에 만료 기한이 지난 refresh token 삭제 | |
28 | + */ | |
29 | + @Scheduled(cron = "0 0 0 * * *") | |
30 | + @Transactional(rollbackFor = Exception.class) | |
31 | + public void cleanExpiredRefreshTokens() { | |
32 | + refreshTokenDAO.cleanExpiredRefreshTokens(); | |
33 | + } | |
34 | +} |
+++ src/main/java/com/takensoft/cms/mber/dao/AdmMbrDAO.java
... | ... | @@ -0,0 +1,92 @@ |
1 | +package com.takensoft.cms.mber.dao; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dto.AdmMbrDTO; | |
4 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
5 | +import com.takensoft.cms.mber.vo.MberAuthorVO; | |
6 | +import com.takensoft.cms.mber.vo.MberVO; | |
7 | +import com.takensoft.common.Pagination; | |
8 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
9 | + | |
10 | +import java.util.HashMap; | |
11 | +import java.util.List; | |
12 | + | |
13 | +/** | |
14 | + * @author : 박정하 | |
15 | + * @since : 2024.06.21 | |
16 | + * | |
17 | + * 회원정보 관련 Mapper | |
18 | + */ | |
19 | +@Mapper("admMbrDAO") | |
20 | +public interface AdmMbrDAO { | |
21 | + /** | |
22 | + * @author : 박정하 | |
23 | + * @since : 2024.06.21 | |
24 | + * | |
25 | + * 회원정보 목록 갯수 | |
26 | + */ | |
27 | + public int mbrListCnt(Pagination pagination) throws Exception; | |
28 | + | |
29 | + /** | |
30 | + * @author : 박정하 | |
31 | + * @since : 2024.06.21 | |
32 | + * | |
33 | + * 회원정보 목록 조회 | |
34 | + */ | |
35 | + public List<AdmMbrDTO> mbrList(Pagination pagination) throws Exception; | |
36 | + | |
37 | + /** | |
38 | + * @author : 박정하 | |
39 | + * @since : 2024.06.21 | |
40 | + * | |
41 | + * 회원정보 상세 조회 | |
42 | + */ | |
43 | + public AdmMbrDTO mbrDetail(String mbrId) throws Exception; | |
44 | + | |
45 | + /** | |
46 | + * @author : 박정하 | |
47 | + * @since : 2024.06.21 | |
48 | + * | |
49 | + * 회원정보 수정 | |
50 | + */ | |
51 | + public int updateMbr(AdmMbrDTO admMbrDTO) throws Exception; | |
52 | + | |
53 | + /** | |
54 | + * @author : 박정하 | |
55 | + * @since : 2024.06.21 | |
56 | + * | |
57 | + * 회원정보 권한 목록 삭제 (mbrId 사용) | |
58 | + */ | |
59 | + public int deleteAuthorListByMbrId(String mbrId) throws Exception; | |
60 | + | |
61 | + /** | |
62 | + * @author : 박정하 | |
63 | + * @since : 2024.06.21 | |
64 | + * | |
65 | + * 회원 권한 목록 삭제 (mbrId 사용) | |
66 | + */ | |
67 | + public int insertAuthor(MberAuthorVO mberAuthorVO) throws Exception; | |
68 | + | |
69 | + /** | |
70 | + * @author : 박정하 | |
71 | + * @since : 2024.06.21 | |
72 | + * | |
73 | + * 회원정보 등록 | |
74 | + */ | |
75 | + public int mbrInsert(JoinDTO joinDTO) throws Exception; | |
76 | + | |
77 | + /** | |
78 | + * @author : 박정하 | |
79 | + * @since : 2024.07.03 | |
80 | + * | |
81 | + * 아이디 찾기 (로그인 아이디) | |
82 | + */ | |
83 | + public String lgnIdSearch(MberVO mbrVO) throws Exception; | |
84 | + | |
85 | + /** | |
86 | + * @author : 박정하 | |
87 | + * @since : 2024.07.03 | |
88 | + * | |
89 | + * 아이디 찾기 (멤버 아이디) | |
90 | + */ | |
91 | + public String mbrIdSearch(AdmMbrDTO admMbrDTO) throws Exception; | |
92 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/dao/LgnHstryDAO.java
... | ... | @@ -0,0 +1,40 @@ |
1 | +package com.takensoft.cms.mber.dao; | |
2 | + | |
3 | +import com.takensoft.cms.mber.vo.LgnHstryVO; | |
4 | +import com.takensoft.cms.popup.vo.PopupVO; | |
5 | +import com.takensoft.common.Pagination; | |
6 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.04.09 | |
13 | + * | |
14 | + * 로그인 이력 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("lgnHstryDAO") | |
17 | +public interface LgnHstryDAO { | |
18 | + /** | |
19 | + * @author takensoft | |
20 | + * @since 2024.04.09 | |
21 | + * 로그인 이력 등록 | |
22 | + */ | |
23 | + int save(LgnHstryVO lgnHstryVO); | |
24 | + | |
25 | + /** | |
26 | + * @author : 박정하 | |
27 | + * @since : 2024.05.13 | |
28 | + * | |
29 | + * 로그인 이력 목록 갯수 | |
30 | + */ | |
31 | + public int selectLgnHstryListCnt(Pagination pagination) throws Exception; | |
32 | + | |
33 | + /** | |
34 | + * @author : 박정하 | |
35 | + * @since : 2024.05.13 | |
36 | + * | |
37 | + * 로그인 이력 목록 조회 | |
38 | + */ | |
39 | + public List<LgnHstryVO> selectLgnHstryList(Pagination pagination) throws Exception; | |
40 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/dao/MberDAO.java
... | ... | @@ -0,0 +1,61 @@ |
1 | +package com.takensoft.cms.mber.dao; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
4 | +import com.takensoft.cms.mber.dto.PasswordDTO; | |
5 | +import com.takensoft.cms.mber.vo.MberAuthorVO; | |
6 | +import com.takensoft.cms.mber.vo.MberVO; | |
7 | +import com.takensoft.common.Pagination; | |
8 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
9 | + | |
10 | +import java.util.*; | |
11 | + | |
12 | +/** | |
13 | + * @author : takensoft | |
14 | + * @since : 2024.04.01 | |
15 | + * | |
16 | + * 회원 정보 관련 Mapper | |
17 | + */ | |
18 | +@Mapper("mberDAO") | |
19 | +public interface MberDAO { | |
20 | + /** | |
21 | + * @author takensoft | |
22 | + * @since 2024.04.03 | |
23 | + * 사용자 정보 조회 [security 용] | |
24 | + */ | |
25 | + MberVO findByMberSecurity(String lgnId); | |
26 | + | |
27 | + /** | |
28 | + * @author takensoft | |
29 | + * @since 2024.04.03 | |
30 | + * 아이디 중복 검사 | |
31 | + */ | |
32 | + boolean findByCheckLoginId(String lgnId); | |
33 | + | |
34 | + /** | |
35 | + * @author takensoft | |
36 | + * @since 2024.04.03 | |
37 | + * 회원가입 | |
38 | + */ | |
39 | + int save(JoinDTO joinDTO); | |
40 | + | |
41 | + /** | |
42 | + * @author takensoft | |
43 | + * @since 2024.04.03 | |
44 | + * 사용자 권한 등록 | |
45 | + */ | |
46 | + int authorSave(MberAuthorVO mberAuthorVO); | |
47 | + | |
48 | + /** | |
49 | + * @author takensoft | |
50 | + * @since 2024.04.15 | |
51 | + * 비밀 번호 변경 | |
52 | + */ | |
53 | + int updatePassword(PasswordDTO passwordDTO); | |
54 | + | |
55 | + /** | |
56 | + * @author takensoft | |
57 | + * @since 2024.04.15 | |
58 | + * 사용자 정보 조회 | |
59 | + */ | |
60 | + MberVO findByMber(String mbrId); | |
61 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/dao/RefreshTokenDAO.java
... | ... | @@ -0,0 +1,42 @@ |
1 | +package com.takensoft.cms.mber.dao; | |
2 | + | |
3 | +import com.takensoft.cms.mber.vo.RefreshVO; | |
4 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
5 | + | |
6 | +/** | |
7 | + * @author : takensoft | |
8 | + * @since : 2024.04.01 | |
9 | + * | |
10 | + * RefreshToken 관련 Mapper | |
11 | + */ | |
12 | +@Mapper("refreshTokenDAO") | |
13 | +public interface RefreshTokenDAO { | |
14 | + | |
15 | + /** | |
16 | + * @author takensoft | |
17 | + * @since 2024.04.04 | |
18 | + * refresh token 등록 | |
19 | + */ | |
20 | + int save(RefreshVO refreshVO); | |
21 | + | |
22 | + /** | |
23 | + * @author takensoft | |
24 | + * @since 2024.04.04 | |
25 | + * refresh token 삭제 | |
26 | + */ | |
27 | + int deleteByRefresh(RefreshVO refreshVO); | |
28 | + | |
29 | + /** | |
30 | + * @author takensoft | |
31 | + * @since 2024.04.04 | |
32 | + * 기한 만료된 refresh token 삭제 [ Schedule 용 ] | |
33 | + */ | |
34 | + int cleanExpiredRefreshTokens(); | |
35 | + | |
36 | + /** | |
37 | + * @author takensoft | |
38 | + * @since 2024.04.17 | |
39 | + * refresh token 등록 유무 확인 | |
40 | + */ | |
41 | + boolean findByCheckRefresh(RefreshVO refreshVO); | |
42 | +} |
+++ src/main/java/com/takensoft/cms/mber/dto/AdmMbrDTO.java
... | ... | @@ -0,0 +1,136 @@ |
1 | +package com.takensoft.cms.mber.dto; | |
2 | + | |
3 | +import com.takensoft.cms.mber.vo.MberAuthorVO; | |
4 | +import lombok.*; | |
5 | + | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : 박정하 | |
11 | + * @since : 2024.06.21 | |
12 | + * | |
13 | + * 회원정보 관련 DTO | |
14 | + */ | |
15 | +@Setter | |
16 | +@Getter | |
17 | +@AllArgsConstructor | |
18 | +@NoArgsConstructor | |
19 | +@Builder | |
20 | +@ToString | |
21 | +public class AdmMbrDTO { | |
22 | + /** | |
23 | + * 회원 아이디 | |
24 | + */ | |
25 | + private String mbrId; | |
26 | + /** | |
27 | + * 로그인 아이디 | |
28 | + */ | |
29 | + private String lgnId; | |
30 | + /** | |
31 | + * 회원 이름 | |
32 | + */ | |
33 | + private String mbrNm; | |
34 | + /** | |
35 | + * 닉네임 | |
36 | + */ | |
37 | + private String ncnm; | |
38 | + /** | |
39 | + * 비밀번호 | |
40 | + */ | |
41 | + private String pswd; | |
42 | + /** | |
43 | + * 휴대폰번호 | |
44 | + */ | |
45 | + private String mblTelno; | |
46 | + /** | |
47 | + * 전화번호 | |
48 | + */ | |
49 | + private String telno; | |
50 | + /** | |
51 | + * 이메일 | |
52 | + */ | |
53 | + private String eml; | |
54 | + /** | |
55 | + * 우편번호 | |
56 | + */ | |
57 | + private String zip; | |
58 | + /** | |
59 | + * 주소 | |
60 | + */ | |
61 | + private String addr; | |
62 | + /** | |
63 | + * 상세주소 | |
64 | + */ | |
65 | + private String daddr; | |
66 | + /** | |
67 | + * 회원상태 | |
68 | + * 0: 탈퇴, 1: 승인, 2: 승인대기, 3: 차단 | |
69 | + */ | |
70 | + private String mbrStts; | |
71 | + /** | |
72 | + * 사용여부 | |
73 | + */ | |
74 | + private String useYn; | |
75 | + /** | |
76 | + * 차단일 | |
77 | + */ | |
78 | + private String cntrlDt; | |
79 | + /** | |
80 | + * 차단사유 | |
81 | + */ | |
82 | + private String cntrlRsn; | |
83 | + /** | |
84 | + * 문자수신여부 | |
85 | + * 0: 거부, 1: 허용 | |
86 | + */ | |
87 | + private String smsRcptnAgreYn; | |
88 | + /** | |
89 | + * 이메일수신여부 | |
90 | + * 0: 거부, 1: 허용 | |
91 | + */ | |
92 | + private String emlRcptnAgreYn; | |
93 | + /** | |
94 | + * 개인정보공개여부 | |
95 | + * 0: 거부, 1: 허용 | |
96 | + */ | |
97 | + private String prvcRlsYn; | |
98 | + /** | |
99 | + * 회원형태 | |
100 | + * S: 시스템, K: 카카오, N: 네이버, G: 구글, F: 페이스북 | |
101 | + */ | |
102 | + private String mbrType; | |
103 | + /** | |
104 | + * 비밀번호 변경일 | |
105 | + */ | |
106 | + private String pswdChgDt; | |
107 | + /** | |
108 | + * 최초등록 아이디 | |
109 | + */ | |
110 | + private String frstRegIp; | |
111 | + /** | |
112 | + * 시스템 제공 여부 -> 시스템에서 제공되는 데이터는 사용자가 제거하지 못하도록 하기 위한 설정값 | |
113 | + * 0: 시스템, 1: 사용자 | |
114 | + */ | |
115 | + private String sysPvsnYn; | |
116 | + /** | |
117 | + * 등록자 | |
118 | + */ | |
119 | + private String rgtr; | |
120 | + /** | |
121 | + * 등록일 | |
122 | + */ | |
123 | + private String regDt; | |
124 | + /** | |
125 | + * 수정자 | |
126 | + */ | |
127 | + private String mdfr; | |
128 | + /** | |
129 | + * 수정일 | |
130 | + */ | |
131 | + private String mdfcnDt; | |
132 | + /** | |
133 | + * 권한 정보 | |
134 | + */ | |
135 | + private List<MberAuthorVO> authorList = new ArrayList<MberAuthorVO>(); | |
136 | +} |
+++ src/main/java/com/takensoft/cms/mber/dto/JoinDTO.java
... | ... | @@ -0,0 +1,145 @@ |
1 | +package com.takensoft.cms.mber.dto; | |
2 | + | |
3 | +import com.takensoft.cms.mber.vo.MberAuthorVO; | |
4 | +import lombok.*; | |
5 | + | |
6 | +import javax.validation.constraints.Email; | |
7 | +import javax.validation.constraints.NotBlank; | |
8 | +import javax.validation.constraints.Size; | |
9 | +import java.util.ArrayList; | |
10 | +import java.util.List; | |
11 | + | |
12 | +/** | |
13 | + * @author : takensoft | |
14 | + * @since : 2024.04.01 | |
15 | + * | |
16 | + * 회원 가입 관련 DTO | |
17 | + */ | |
18 | +@Setter | |
19 | +@Getter | |
20 | +@AllArgsConstructor | |
21 | +@NoArgsConstructor | |
22 | +@Builder | |
23 | +@ToString | |
24 | +public class JoinDTO { | |
25 | + /** | |
26 | + * 회원 아이디 | |
27 | + */ | |
28 | + private String mbrId; | |
29 | + /** | |
30 | + * 로그인 아이디 | |
31 | + */ | |
32 | + @NotBlank(message = "로그인 아이디는 필수 입력 값입니다.") | |
33 | + @Size(min = 5, max = 50) | |
34 | + private String lgnId; | |
35 | + /** | |
36 | + * 회원 이름 | |
37 | + */ | |
38 | + @NotBlank(message = "이름은 필수 입력 값입니다.") | |
39 | + @Size(min = 2, max = 50) | |
40 | + private String mbrNm; | |
41 | + /** | |
42 | + * 닉네임 | |
43 | + */ | |
44 | + private String ncnm; | |
45 | + /** | |
46 | + * 비밀번호 | |
47 | + */ | |
48 | + @NotBlank(message = "비밀번호는 필수 입력 값입니다.") | |
49 | + private String pswd; | |
50 | + /** | |
51 | + * 휴대폰번호 | |
52 | + */ | |
53 | + private String mblTelno; | |
54 | + /** | |
55 | + * 전화번호 | |
56 | + */ | |
57 | + private String telno; | |
58 | + /** | |
59 | + * 이메일 | |
60 | + */ | |
61 | + @Email(message = "이메일 형식에 맞지 않습니다.") | |
62 | + private String eml; | |
63 | + /** | |
64 | + * 우편번호 | |
65 | + */ | |
66 | + private String zip; | |
67 | + /** | |
68 | + * 주소 | |
69 | + */ | |
70 | + private String addr; | |
71 | + /** | |
72 | + * 상세주소 | |
73 | + */ | |
74 | + private String daddr; | |
75 | + /** | |
76 | + * 회원상태 | |
77 | + * 0: 탈퇴, 1: 승인, 2: 승인대기, 3: 차단 | |
78 | + */ | |
79 | + private String mbrStts; | |
80 | + /** | |
81 | + * 사용여부 | |
82 | + */ | |
83 | + private String useYn; | |
84 | + /** | |
85 | + * 차단일 | |
86 | + */ | |
87 | + private String cntrlDt; | |
88 | + /** | |
89 | + * 차단사유 | |
90 | + */ | |
91 | + private String cntrlRsn; | |
92 | + /** | |
93 | + * 문자수신여부 | |
94 | + * 0: 거부, 1: 허용 | |
95 | + */ | |
96 | + private String smsRcptnAgreYn; | |
97 | + /** | |
98 | + * 이메일수신여부 | |
99 | + * 0: 거부, 1: 허용 | |
100 | + */ | |
101 | + private String emlRcptnAgreYn; | |
102 | + /** | |
103 | + * 개인정보공개여부 | |
104 | + * 0: 거부, 1: 허용 | |
105 | + */ | |
106 | + private String prvcRlsYn; | |
107 | + /** | |
108 | + * 회원형태 | |
109 | + * S: 시스템, K: 카카오, N: 네이버, G: 구글, F: 페이스북 | |
110 | + */ | |
111 | + private String mbrType; | |
112 | + /** | |
113 | + * 비밀번호 변경일 | |
114 | + */ | |
115 | + private String pswdChgDt; | |
116 | + /** | |
117 | + * 최초등록 아이디 | |
118 | + */ | |
119 | + private String frstRegIp; | |
120 | + /** | |
121 | + * 시스템 제공 여부 -> 시스템에서 제공되는 데이터는 사용자가 제거하지 못하도록 하기 위한 설정값 | |
122 | + * 0: 시스템, 1: 사용자 | |
123 | + */ | |
124 | + private String sysPvsnYn; | |
125 | + /** | |
126 | + * 등록자 | |
127 | + */ | |
128 | + private String rgtr; | |
129 | + /** | |
130 | + * 등록일 | |
131 | + */ | |
132 | + private String regDt; | |
133 | + /** | |
134 | + * 수정자 | |
135 | + */ | |
136 | + private String mdfr; | |
137 | + /** | |
138 | + * 수정일 | |
139 | + */ | |
140 | + private String mdfcnDt; | |
141 | + /** | |
142 | + * 권한 정보 | |
143 | + */ | |
144 | + private List<MberAuthorVO> authorList = new ArrayList<MberAuthorVO>(); | |
145 | +} |
+++ src/main/java/com/takensoft/cms/mber/dto/LoginDTO.java
... | ... | @@ -0,0 +1,35 @@ |
1 | +package com.takensoft.cms.mber.dto; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Builder; | |
5 | +import lombok.Data; | |
6 | +import lombok.NoArgsConstructor; | |
7 | + | |
8 | +import javax.validation.constraints.NotNull; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.04.01 | |
13 | + * | |
14 | + * 로그인 관련 DTO | |
15 | + */ | |
16 | +@Data | |
17 | +@AllArgsConstructor | |
18 | +@NoArgsConstructor | |
19 | +@Builder | |
20 | +public class LoginDTO { | |
21 | + /** | |
22 | + * 로그인 아이디 | |
23 | + */ | |
24 | + @NotNull | |
25 | + private String lgnId; | |
26 | + /** | |
27 | + * 비밀번호 | |
28 | + */ | |
29 | + @NotNull | |
30 | + private String pswd; | |
31 | + /** | |
32 | + * refreshToken 정보 | |
33 | + */ | |
34 | + private String refreshToken; | |
35 | +} |
+++ src/main/java/com/takensoft/cms/mber/dto/PasswordDTO.java
... | ... | @@ -0,0 +1,37 @@ |
1 | +package com.takensoft.cms.mber.dto; | |
2 | + | |
3 | + | |
4 | +import lombok.*; | |
5 | + | |
6 | +import javax.validation.constraints.NotBlank; | |
7 | + | |
8 | +/** | |
9 | + * @author : takensoft | |
10 | + * @since : 2024.04.01 | |
11 | + * | |
12 | + * 비밀 번호 변경 | |
13 | + */ | |
14 | +@Setter | |
15 | +@Getter | |
16 | +@AllArgsConstructor | |
17 | +@NoArgsConstructor | |
18 | +@Builder | |
19 | +@ToString | |
20 | +public class PasswordDTO { | |
21 | + /** | |
22 | + * 회원 아이디 | |
23 | + */ | |
24 | + private String mbrId; | |
25 | + | |
26 | + /** | |
27 | + * 비밀번호[현재 비밀번호] | |
28 | + */ | |
29 | + @NotBlank(message = "비밀번호는 필수 입력 값입니다.") | |
30 | + private String pswd; | |
31 | + | |
32 | + /** | |
33 | + * 비밀번호[변경될 비밀번호] | |
34 | + */ | |
35 | + @NotBlank(message = "변경할 비밀번호는 필수 입력 값입니다.") | |
36 | + private String newPswd; | |
37 | +} |
+++ src/main/java/com/takensoft/cms/mber/service/AdmMbrService.java
... | ... | @@ -0,0 +1,64 @@ |
1 | +package com.takensoft.cms.mber.service; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dto.AdmMbrDTO; | |
4 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
5 | +import com.takensoft.cms.mber.vo.MberVO; | |
6 | + | |
7 | +import javax.servlet.http.HttpServletRequest; | |
8 | +import java.util.HashMap; | |
9 | + | |
10 | +/** | |
11 | + * @author : 박정하 | |
12 | + * @since : 2024.06.21 | |
13 | + * | |
14 | + * 회원정보 관련 인터페이스 | |
15 | + */ | |
16 | +public interface AdmMbrService { | |
17 | + /** | |
18 | + * @author : 박정하 | |
19 | + * @since : 2024.06.21 | |
20 | + * | |
21 | + * 회원정보 목록 조회 | |
22 | + */ | |
23 | + public HashMap<String, Object> mbrList(HashMap<String, String> params) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author : 박정하 | |
27 | + * @since : 2024.06.21 | |
28 | + * | |
29 | + * 회원정보 상세 조회 | |
30 | + */ | |
31 | + public AdmMbrDTO mbrDetail(String mbrId) throws Exception; | |
32 | + | |
33 | + /** | |
34 | + * @author : 박정하 | |
35 | + * @since : 2024.06.21 | |
36 | + * | |
37 | + * 회원정보 수정 | |
38 | + */ | |
39 | + public int updateMbr(AdmMbrDTO admMbrDTO) throws Exception; | |
40 | + | |
41 | + /** | |
42 | + * @author : 박정하 | |
43 | + * @since : 2024.06.21 | |
44 | + * | |
45 | + * 회원정보 등록 | |
46 | + */ | |
47 | + public HashMap<String, Object> mbrInsert(HttpServletRequest req, JoinDTO joinDTO) throws Exception; | |
48 | + | |
49 | + /** | |
50 | + * @author : 박정하 | |
51 | + * @since : 2024.07.03 | |
52 | + * | |
53 | + * 아이디 찾기 (로그인 아이디) | |
54 | + */ | |
55 | + public String lgnIdSearch(MberVO mbrVO) throws Exception; | |
56 | + | |
57 | + /** | |
58 | + * @author : 박정하 | |
59 | + * @since : 2024.07.03 | |
60 | + * | |
61 | + * 아이디 찾기 (멤버 아이디) | |
62 | + */ | |
63 | + public int mbrIdSearch(String resetPswd, AdmMbrDTO admMbrDTO) throws Exception; | |
64 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/service/Impl/AdmMbrServiceImpl.java
... | ... | @@ -0,0 +1,235 @@ |
1 | +package com.takensoft.cms.mber.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dao.AdmMbrDAO; | |
4 | +import com.takensoft.cms.mber.dto.AdmMbrDTO; | |
5 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
6 | +import com.takensoft.cms.mber.dto.PasswordDTO; | |
7 | +import com.takensoft.cms.mber.service.AdmMbrService; | |
8 | +import com.takensoft.cms.mber.service.MberService; | |
9 | +import com.takensoft.cms.mber.vo.MberAuthorVO; | |
10 | +import com.takensoft.cms.mber.vo.MberVO; | |
11 | +import com.takensoft.common.Pagination; | |
12 | +import com.takensoft.common.idgen.service.IdgenService; | |
13 | +import com.takensoft.common.util.CommonUtils; | |
14 | +import com.takensoft.common.util.JWTUtil; | |
15 | +import com.takensoft.common.util.Secret; | |
16 | +import lombok.RequiredArgsConstructor; | |
17 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
18 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
19 | +import org.springframework.stereotype.Service; | |
20 | +import org.springframework.transaction.annotation.Transactional; | |
21 | + | |
22 | +import javax.servlet.http.HttpServletRequest; | |
23 | +import java.util.HashMap; | |
24 | +import java.util.List; | |
25 | + | |
26 | +/** | |
27 | + * @author : 박정하 | |
28 | + * @since : 2024.06.21 | |
29 | + * | |
30 | + * 회원정보 관련 구현체 | |
31 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
32 | + * AdmMbrService : 회원정보 인터페이스 상속 | |
33 | + */ | |
34 | +@Service("admMbrService") | |
35 | +@RequiredArgsConstructor | |
36 | +public class AdmMbrServiceImpl extends EgovAbstractServiceImpl implements AdmMbrService { | |
37 | + private final JWTUtil jwtUtil; | |
38 | + private final IdgenService mberIdgn; | |
39 | + private final CommonUtils commonUtils; | |
40 | + private final BCryptPasswordEncoder bCryptPasswordEncoder; | |
41 | + private final AdmMbrDAO admMbrDAO; | |
42 | + private final MberService mbrService; | |
43 | + | |
44 | + /** | |
45 | + * @author : 박정하 | |
46 | + * @since : 2024.06.21 | |
47 | + * | |
48 | + * 회원정보 목록 조회 | |
49 | + */ | |
50 | + @Override | |
51 | + public HashMap<String, Object> mbrList(HashMap<String, String> params) throws Exception { | |
52 | + Pagination search = new Pagination(0, params); | |
53 | + int cnt = admMbrDAO.mbrListCnt(search); | |
54 | + | |
55 | + Pagination pagination = new Pagination(cnt, params); | |
56 | + List<AdmMbrDTO> list = admMbrDAO.mbrList(pagination); | |
57 | + | |
58 | + // 휴대폰번호 복호화 | |
59 | + for (AdmMbrDTO admMbrDTO : list) { | |
60 | + if (admMbrDTO.getMblTelno() != null && !admMbrDTO.getMblTelno().equals("")) { | |
61 | + admMbrDTO.setMblTelno(Secret.decrypt(admMbrDTO.getMblTelno().toString())); | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + HashMap<String, Object> result = new HashMap<>(); | |
66 | + result.put("list", list); | |
67 | + result.put("pagination", pagination); | |
68 | + return result; | |
69 | + | |
70 | + } | |
71 | + | |
72 | + /** | |
73 | + * @author : 박정하 | |
74 | + * @since : 2024.06.21 | |
75 | + * | |
76 | + * 회원정보 상세 조회 | |
77 | + */ | |
78 | + @Override | |
79 | + public AdmMbrDTO mbrDetail(String mbrId) throws Exception { | |
80 | + AdmMbrDTO admMbrDTO = new AdmMbrDTO(); | |
81 | + | |
82 | + // mbrId가 있는 경우 | |
83 | + if (mbrId != null) { | |
84 | + admMbrDTO = admMbrDAO.mbrDetail(mbrId); | |
85 | + | |
86 | + // 휴대폰번호 복호화 | |
87 | + if (admMbrDTO.getMblTelno() != null && !admMbrDTO.getMblTelno().equals("")) { | |
88 | + admMbrDTO.setMblTelno(Secret.decrypt(admMbrDTO.getMblTelno())); | |
89 | + } | |
90 | + | |
91 | + // 전화번호 복호화 | |
92 | + if (admMbrDTO.getTelno() != null && !admMbrDTO.getTelno().equals("")) { | |
93 | + admMbrDTO.setTelno(Secret.decrypt(admMbrDTO.getTelno())); | |
94 | + } | |
95 | + } | |
96 | + // mbrId가 없는 경우 | |
97 | + else { | |
98 | + admMbrDTO.setUseYn("Y"); | |
99 | + admMbrDTO.setMbrStts("1"); | |
100 | + admMbrDTO.setSmsRcptnAgreYn("Y"); | |
101 | + admMbrDTO.setEmlRcptnAgreYn("Y"); | |
102 | + } | |
103 | + | |
104 | + return admMbrDTO; | |
105 | + } | |
106 | + | |
107 | + /** | |
108 | + * @author : 박정하 | |
109 | + * @since : 2024.06.21 | |
110 | + * | |
111 | + * 회원정보 수정 | |
112 | + */ | |
113 | + @Override | |
114 | + @Transactional(rollbackFor = Exception.class) | |
115 | + public int updateMbr(AdmMbrDTO admMbrDTO) throws Exception { | |
116 | + // 비밀번호 변경 | |
117 | + if (admMbrDTO.getPswd() != null && !admMbrDTO.getPswd().equals("")) { | |
118 | + PasswordDTO passwordDTO = new PasswordDTO(); | |
119 | + passwordDTO.setMbrId(admMbrDTO.getMbrId()); | |
120 | + passwordDTO.setNewPswd(admMbrDTO.getPswd()); | |
121 | + mbrService.updatePassword(passwordDTO); | |
122 | + } | |
123 | + | |
124 | + // 연락처 암호화 | |
125 | + if(admMbrDTO.getMblTelno() != null && !admMbrDTO.getMblTelno().equals("")){ | |
126 | + admMbrDTO.setMblTelno(Secret.encrypt(admMbrDTO.getMblTelno())); | |
127 | + } | |
128 | + if(admMbrDTO.getTelno() != null && !admMbrDTO.getTelno().equals("")) { | |
129 | + admMbrDTO.setTelno(Secret.encrypt(admMbrDTO.getTelno())); | |
130 | + } | |
131 | + | |
132 | + // 수정자 조회 및 등록 | |
133 | + String writer = jwtUtil.getWriter(); | |
134 | + admMbrDTO.setMdfr(writer); | |
135 | + | |
136 | + // 회원정보 수정 | |
137 | + int result = admMbrDAO.updateMbr(admMbrDTO); | |
138 | + | |
139 | + // 권한 수정 | |
140 | + result += admMbrDAO.deleteAuthorListByMbrId(admMbrDTO.getMbrId()); // 회원 권한 전체 삭제 | |
141 | + if (admMbrDTO.getUseYn().equals("Y")) { | |
142 | + if(admMbrDTO.getAuthorList() != null && admMbrDTO.getAuthorList().size() > 0) { | |
143 | + for(MberAuthorVO mberAuthorVO : admMbrDTO.getAuthorList()) { | |
144 | + mberAuthorVO.setMbrId(admMbrDTO.getMbrId()); | |
145 | + mberAuthorVO.setRgtr(writer); | |
146 | + result += admMbrDAO.insertAuthor(mberAuthorVO); | |
147 | + } | |
148 | + } | |
149 | + } | |
150 | + | |
151 | + return result; | |
152 | + } | |
153 | + | |
154 | + /** | |
155 | + * @author : 박정하 | |
156 | + * @since : 2024.06.21 | |
157 | + * | |
158 | + * 회원정보 등록 | |
159 | + */ | |
160 | + @Override | |
161 | + @Transactional(rollbackFor = Exception.class) | |
162 | + public HashMap<String, Object> mbrInsert(HttpServletRequest req, JoinDTO joinDTO) throws Exception { | |
163 | + // 회원 아이디 생성 | |
164 | + String mbrId = mberIdgn.getNextStringId(); | |
165 | + joinDTO.setMbrId(mbrId); | |
166 | + | |
167 | + // 비밀번호 암호화 | |
168 | + joinDTO.setPswd(bCryptPasswordEncoder.encode(joinDTO.getPswd())); | |
169 | + | |
170 | + // 연락처 암호화 | |
171 | + if(joinDTO.getMblTelno() != null && !joinDTO.getMblTelno().equals("")) { | |
172 | + joinDTO.setMblTelno(Secret.encrypt(joinDTO.getMblTelno())); | |
173 | + } | |
174 | + if(joinDTO.getTelno() != null && !joinDTO.getTelno().equals("")) { | |
175 | + joinDTO.setTelno(Secret.encrypt(joinDTO.getTelno())); | |
176 | + } | |
177 | + | |
178 | + // 아이피 등록 | |
179 | + String ip = commonUtils.getIp(req); | |
180 | + joinDTO.setFrstRegIp(ip); | |
181 | + | |
182 | + // 작성자 등록 | |
183 | + String writer = jwtUtil.getWriter(); | |
184 | + if(writer != null && !writer.equals("")) { | |
185 | + joinDTO.setRgtr(writer); | |
186 | + } | |
187 | + | |
188 | + // 회원정보 등록 | |
189 | + int insertResult = admMbrDAO.mbrInsert(joinDTO); | |
190 | + | |
191 | + // 권한 등록 | |
192 | + if(joinDTO.getAuthorList().size() > 0) { | |
193 | + for(MberAuthorVO mberAuthorVO : joinDTO.getAuthorList()) { | |
194 | + mberAuthorVO.setMbrId(joinDTO.getMbrId()); | |
195 | + mberAuthorVO.setRgtr(writer); | |
196 | + insertResult += admMbrDAO.insertAuthor(mberAuthorVO); | |
197 | + } | |
198 | + } | |
199 | + | |
200 | + HashMap<String, Object> result = new HashMap<>(); | |
201 | + result.put("mbrId", mbrId); | |
202 | + result.put("insertResult", insertResult); | |
203 | + return result; | |
204 | + } | |
205 | + | |
206 | + /** | |
207 | + * @author : 박정하 | |
208 | + * @since : 2024.07.03 | |
209 | + * | |
210 | + * 아이디 찾기 (로그인 아이디) | |
211 | + */ | |
212 | + public String lgnIdSearch(MberVO mbrVO) throws Exception { | |
213 | + return admMbrDAO.lgnIdSearch(mbrVO); | |
214 | + } | |
215 | + | |
216 | + /** | |
217 | + * @author : 박정하 | |
218 | + * @since : 2024.07.03 | |
219 | + * | |
220 | + * 아이디 찾기 (멤버 아이디) | |
221 | + */ | |
222 | + public int mbrIdSearch(String resetPswd, AdmMbrDTO admMbrDTO) throws Exception { | |
223 | + String mbrId = admMbrDAO.mbrIdSearch(admMbrDTO); | |
224 | + | |
225 | + PasswordDTO passwordDTO = new PasswordDTO(); | |
226 | + passwordDTO.setMbrId(mbrId); | |
227 | + passwordDTO.setPswd(admMbrDTO.getPswd()); | |
228 | + passwordDTO.setNewPswd(resetPswd); | |
229 | + | |
230 | + // 비밀번호 변경 | |
231 | + int result = mbrService.updatePassword(passwordDTO); | |
232 | + | |
233 | + return result; | |
234 | + } | |
235 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/service/Impl/LgnHstryServiceImpl.java
... | ... | @@ -0,0 +1,66 @@ |
1 | +package com.takensoft.cms.mber.service.Impl; | |
2 | + | |
3 | + | |
4 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
5 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
6 | +import com.takensoft.cms.mber.dao.LgnHstryDAO; | |
7 | +import com.takensoft.cms.mber.service.LgnHstryService; | |
8 | +import com.takensoft.cms.mber.vo.LgnHstryVO; | |
9 | +import com.takensoft.cms.popup.vo.PopupVO; | |
10 | +import com.takensoft.common.Pagination; | |
11 | +import com.takensoft.common.util.JWTUtil; | |
12 | +import lombok.RequiredArgsConstructor; | |
13 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
14 | +import org.slf4j.Logger; | |
15 | +import org.slf4j.LoggerFactory; | |
16 | +import org.springframework.stereotype.Service; | |
17 | + | |
18 | +import java.util.HashMap; | |
19 | +import java.util.List; | |
20 | + | |
21 | +/** | |
22 | + * @author : takensoft | |
23 | + * @since : 2024.04.09 | |
24 | + * | |
25 | + * 로그인 이력 정보 관련 구현체 | |
26 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
27 | + * LgnHstryService : 로그인 이력 정보 인터페이스 상속 | |
28 | + */ | |
29 | +@Service("lgnHstryService") | |
30 | +@RequiredArgsConstructor | |
31 | +public class LgnHstryServiceImpl extends EgovAbstractServiceImpl implements LgnHstryService { | |
32 | + private final LgnHstryDAO lgnHstryDAO; | |
33 | + private final CodeManageService codeManageService; | |
34 | + | |
35 | + /** | |
36 | + * @author takensoft | |
37 | + * @since 2024.04.09 | |
38 | + * 로그인 이력 등록 | |
39 | + */ | |
40 | + @Override | |
41 | + public int LgnHstrySave(LgnHstryVO lgnHstryVO) throws Exception { | |
42 | + return lgnHstryDAO.save(lgnHstryVO); | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * @author : 박정하 | |
47 | + * @since : 2024.05.13 | |
48 | + * | |
49 | + * 로그인 이력 목록 조회 | |
50 | + */ | |
51 | + @Override | |
52 | + public HashMap<String, Object> lgnHstryList(HashMap<String, String> params) throws Exception { | |
53 | + Pagination search = new Pagination(0, params); | |
54 | + int cnt = lgnHstryDAO.selectLgnHstryListCnt(search); | |
55 | + | |
56 | + Pagination pagination = new Pagination(cnt, params); | |
57 | + List<LgnHstryVO> list = lgnHstryDAO.selectLgnHstryList(pagination); | |
58 | + List<CodeManageVO> codeList = codeManageService.findByChildCdCache("lgnHstry"); // 검색 조건 | |
59 | + | |
60 | + HashMap<String, Object> result = new HashMap<>(); | |
61 | + result.put("list", list); | |
62 | + result.put("pagination", pagination); | |
63 | + result.put("codeList", codeList); | |
64 | + return result; | |
65 | + } | |
66 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/service/Impl/MberServiceImpl.java
... | ... | @@ -0,0 +1,170 @@ |
1 | +package com.takensoft.cms.mber.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dao.MberDAO; | |
4 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
5 | +import com.takensoft.cms.mber.dto.PasswordDTO; | |
6 | +import com.takensoft.cms.mber.service.MberService; | |
7 | +import com.takensoft.cms.mber.vo.MberAuthorVO; | |
8 | +import com.takensoft.cms.mber.vo.MberVO; | |
9 | +import com.takensoft.common.idgen.service.IdgenService; | |
10 | +import com.takensoft.common.util.CommonUtils; | |
11 | +import com.takensoft.common.util.JWTUtil; | |
12 | +import com.takensoft.common.util.Secret; | |
13 | +import lombok.RequiredArgsConstructor; | |
14 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
15 | +import org.springframework.security.core.userdetails.UserDetails; | |
16 | +import org.springframework.security.core.userdetails.UserDetailsService; | |
17 | +import org.springframework.security.core.userdetails.UsernameNotFoundException; | |
18 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
19 | +import org.springframework.stereotype.Service; | |
20 | +import org.springframework.transaction.annotation.Transactional; | |
21 | + | |
22 | +import javax.servlet.http.HttpServletRequest; | |
23 | +import java.util.HashMap; | |
24 | + | |
25 | +/** | |
26 | + * @author : takensoft | |
27 | + * @since : 2024.04.01 | |
28 | + * | |
29 | + * 회원 정보 관련 구현체 | |
30 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
31 | + * UserDetailsService : security 사용을 위해 상속 | |
32 | + * MberService : 회원정보 인터페이스 상속 | |
33 | + */ | |
34 | +@Service("mberService") | |
35 | +@RequiredArgsConstructor | |
36 | +public class MberServiceImpl extends EgovAbstractServiceImpl implements UserDetailsService, MberService { | |
37 | + private final MberDAO mberDAO; | |
38 | + private final IdgenService mberIdgn; | |
39 | + private final BCryptPasswordEncoder bCryptPasswordEncoder; | |
40 | + private final JWTUtil jwtUtil; | |
41 | + private final CommonUtils commonUtils; | |
42 | + | |
43 | + /** | |
44 | + * @author takensoft | |
45 | + * @since 2024.04.03 | |
46 | + * | |
47 | + * security 상속 시 Override 하는 메소드 | |
48 | + */ | |
49 | + @Override | |
50 | + @Transactional(readOnly = true) | |
51 | + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | |
52 | + return mberDAO.findByMberSecurity(username); | |
53 | + } | |
54 | + | |
55 | + /** | |
56 | + * @author takensoft | |
57 | + * @since 2024.04.03 | |
58 | + * | |
59 | + * 아이디 중복 검사 | |
60 | + */ | |
61 | + @Override | |
62 | + public boolean findByCheckLoginId(String lgnId) throws Exception { | |
63 | + return mberDAO.findByCheckLoginId(lgnId); | |
64 | + } | |
65 | + | |
66 | + /** | |
67 | + * @author takensoft | |
68 | + * @since 2024.04.03 | |
69 | + * 회원가입 | |
70 | + */ | |
71 | + @Override | |
72 | + @Transactional(rollbackFor = Exception.class) | |
73 | + public HashMap<String, Object> userJoin(HttpServletRequest req, JoinDTO joinDTO) throws Exception { | |
74 | + // 회원 아이디 생성 | |
75 | + String mbrId = mberIdgn.getNextStringId(); | |
76 | + joinDTO.setMbrId(mbrId); | |
77 | + | |
78 | + // 비밀번호 암호화 | |
79 | + joinDTO.setPswd(bCryptPasswordEncoder.encode(joinDTO.getPswd())); | |
80 | + | |
81 | + // 연락처 암호화 | |
82 | + if(joinDTO.getMblTelno() != null && !joinDTO.getMblTelno().equals("")) { | |
83 | + joinDTO.setMblTelno(Secret.encrypt(joinDTO.getMblTelno())); | |
84 | + } | |
85 | + if(joinDTO.getTelno() != null && !joinDTO.getTelno().equals("")) { | |
86 | + joinDTO.setTelno(Secret.encrypt(joinDTO.getTelno())); | |
87 | + } | |
88 | + | |
89 | + // 아이피 조회 및 등록 | |
90 | + joinDTO.setFrstRegIp(commonUtils.getIp(req)); | |
91 | + | |
92 | + // 작성자 조회 및 등록 | |
93 | + if(jwtUtil.getWriter() != null && !jwtUtil.getWriter().equals("")) { | |
94 | + joinDTO.setRgtr(jwtUtil.getWriter()); | |
95 | + } | |
96 | + | |
97 | + // 회원정보 등록 | |
98 | + HashMap<String, Object> result = new HashMap<>(); | |
99 | + int saveResult = mberDAO.save(joinDTO); | |
100 | + result.put("mbrId", mbrId); | |
101 | + | |
102 | + // 권한 등록 | |
103 | + int authorResult = 0; | |
104 | + if(joinDTO.getAuthorList().size() > 0) { | |
105 | + for(MberAuthorVO vo : joinDTO.getAuthorList()) { | |
106 | + vo.setMbrId(joinDTO.getMbrId()); | |
107 | + // 작성자 조회 및 등록 | |
108 | + if(jwtUtil.getWriter() != null && !jwtUtil.getWriter().equals("")) { | |
109 | + vo.setRgtr(jwtUtil.getWriter()); | |
110 | + } | |
111 | + authorResult += mberDAO.authorSave(vo); | |
112 | + } | |
113 | + } | |
114 | + result.put("result", saveResult + authorResult); | |
115 | + | |
116 | + return result; | |
117 | + } | |
118 | + | |
119 | + /** | |
120 | + * @author takensoft | |
121 | + * @since 2024.04.15 | |
122 | + * 비밀번호 비교 | |
123 | + */ | |
124 | + @Override | |
125 | + public boolean passwordCheck(PasswordDTO passwordDTO) throws Exception { | |
126 | + // 회원 정보 호출 | |
127 | + MberVO mbr = mberDAO.findByMber(jwtUtil.getWriter()); | |
128 | + // 비밀번호 비교 후 성공 시 비밀번호 수정 후 true 반환 | |
129 | + if(bCryptPasswordEncoder.matches(passwordDTO.getPswd(), mbr.getPassword())) { | |
130 | + passwordDTO.setNewPswd(bCryptPasswordEncoder.encode(passwordDTO.getNewPswd())); | |
131 | + passwordDTO.setMbrId(mbr.getMbrId()); | |
132 | + mberDAO.updatePassword(passwordDTO); | |
133 | + return true; | |
134 | + // 기존 비밀번호와 입력한 비밀번호가 서로 다를 경우 false 반환 | |
135 | + } else { | |
136 | + return false; | |
137 | + } | |
138 | + } | |
139 | + | |
140 | + /** | |
141 | + * @author 박정하 | |
142 | + * @since 2024.04.23 | |
143 | + * 회원정보 상세 조회 | |
144 | + */ | |
145 | + @Override | |
146 | + public MberVO findByMbr(HashMap<String, Object> params) throws Exception { | |
147 | + String mbrId = params.get("mbrId").toString(); | |
148 | + MberVO mberVO = mberDAO.findByMber(mbrId); | |
149 | + // 휴대폰번호 복호화 | |
150 | + if (mberVO.getMblTelno() != null && !mberVO.getMblTelno().equals("")) { | |
151 | + mberVO.setMblTelno(Secret.decrypt(mberVO.getMblTelno().toString())); | |
152 | + } | |
153 | + // 전화번호 복호화 | |
154 | + if (mberVO.getTelno() != null && !mberVO.getTelno().equals("")) { | |
155 | + mberVO.setTelno(Secret.decrypt(mberVO.getTelno().toString())); | |
156 | + } | |
157 | + return mberVO; | |
158 | + } | |
159 | + | |
160 | + /** | |
161 | + * @author takensoft | |
162 | + * @since 2024.04.24 | |
163 | + * 비밀번호 수정 | |
164 | + */ | |
165 | + @Override | |
166 | + public int updatePassword(PasswordDTO passwordDTO) throws Exception { | |
167 | + passwordDTO.setNewPswd(bCryptPasswordEncoder.encode(passwordDTO.getNewPswd())); | |
168 | + return mberDAO.updatePassword(passwordDTO); | |
169 | + } | |
170 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/service/Impl/RefreshTokenServiceImpl.java
... | ... | @@ -0,0 +1,197 @@ |
1 | +package com.takensoft.cms.mber.service.Impl; | |
2 | + | |
3 | +import com.fasterxml.jackson.datatype.jsr310.ser.YearSerializer; | |
4 | +import com.takensoft.cms.mber.dao.RefreshTokenDAO; | |
5 | +import com.takensoft.cms.mber.service.RefreshTokenService; | |
6 | +import com.takensoft.cms.mber.vo.MberAuthorVO; | |
7 | +import com.takensoft.cms.mber.vo.MberVO; | |
8 | +import com.takensoft.cms.mber.vo.RefreshVO; | |
9 | +import com.takensoft.common.util.CommonUtils; | |
10 | +import com.takensoft.common.util.JWTUtil; | |
11 | +import io.jsonwebtoken.ExpiredJwtException; | |
12 | +import lombok.RequiredArgsConstructor; | |
13 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
14 | +import org.slf4j.Logger; | |
15 | +import org.slf4j.LoggerFactory; | |
16 | +import org.springframework.beans.factory.annotation.Value; | |
17 | +import org.springframework.stereotype.Service; | |
18 | +import org.springframework.transaction.annotation.Transactional; | |
19 | + | |
20 | +import javax.servlet.http.Cookie; | |
21 | +import javax.servlet.http.HttpServletRequest; | |
22 | +import javax.servlet.http.HttpServletResponse; | |
23 | +import java.util.Date; | |
24 | +import java.util.HashMap; | |
25 | +import java.util.List; | |
26 | +import java.util.Map; | |
27 | + | |
28 | +/** | |
29 | + * @author : takensoft | |
30 | + * @since : 2024.04.01 | |
31 | + * | |
32 | + * RefreshToken 정보 관련 구현체 | |
33 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
34 | + * RefreshTokenService : RefreshToken 인터페이스 상속 | |
35 | + */ | |
36 | +@Service("refreshTokenService") | |
37 | +@RequiredArgsConstructor | |
38 | +public class RefreshTokenServiceImpl extends EgovAbstractServiceImpl implements RefreshTokenService { | |
39 | + | |
40 | + private static final Logger LOGGER = LoggerFactory.getLogger(RefreshTokenServiceImpl.class); | |
41 | + private final RefreshTokenDAO refreshTokenDAO; | |
42 | + private final JWTUtil jwtUtil; | |
43 | + private final CommonUtils commonUtils; | |
44 | + | |
45 | + @Value("${jwt.accessTime}") | |
46 | + private long JWT_ACCESSTIME; // access 토큰 유지 시간 | |
47 | + @Value("${jwt.refreshTime}") | |
48 | + private long JWT_REFRESHTIME; // refresh 토큰 유지 시간 | |
49 | + @Value("${cookie.time}") | |
50 | + private int COOKIE_TIME; // 쿠키 유지 시간 | |
51 | + | |
52 | + /** | |
53 | + * @author takensoft | |
54 | + * @since 2024.04.04 | |
55 | + * refresh token 검증 | |
56 | + */ | |
57 | + private Map<String, Object> refreshTokenCheck(HttpServletRequest req) { | |
58 | + Map<String, Object> result = new HashMap <String, Object>(); | |
59 | + // header 방식 | |
60 | +// String refreshToken = req.getHeader("refresh"); | |
61 | + // 쿠키 방식 | |
62 | + String refreshToken = null; | |
63 | + Cookie[] cookies = req.getCookies(); | |
64 | + for (Cookie cookie : cookies) { | |
65 | + if (cookie.getName().equals("refresh")) refreshToken = cookie.getValue(); | |
66 | + } | |
67 | + if(refreshToken == null) { | |
68 | + result.put("result", 0); | |
69 | + return result; | |
70 | + } | |
71 | + try { | |
72 | + jwtUtil.isExpired(refreshToken); | |
73 | + } catch (ExpiredJwtException e) { | |
74 | + result.put("result", 0); | |
75 | + return result; | |
76 | + } | |
77 | + String category = jwtUtil.getCategory(refreshToken); | |
78 | + if(!category.equals("refresh")) { | |
79 | + result.put("result", 0); | |
80 | + return result; | |
81 | + } | |
82 | + result.put("result", 1); | |
83 | + result.put("refreshToken", refreshToken); | |
84 | + | |
85 | + return result; | |
86 | + } | |
87 | + | |
88 | + /** | |
89 | + * @author takensoft | |
90 | + * @since 2024.04.04 | |
91 | + * refresh token 등록 | |
92 | + */ | |
93 | + @Override | |
94 | + public int saveRefreshToken(HttpServletRequest req, HttpServletResponse res, RefreshVO refresh, long expiredMs) throws Exception { | |
95 | + // 만료 시간 | |
96 | + refresh.setExpryDt(new Date(System.currentTimeMillis() + expiredMs)); | |
97 | + // 사용중인 아이피 | |
98 | + refresh.setUseIp(commonUtils.getIp(req)); | |
99 | + return refreshTokenDAO.save(refresh); | |
100 | + } | |
101 | + | |
102 | + /** | |
103 | + * @author takensoft | |
104 | + * @since 2024.04.04 | |
105 | + * refresh token 삭제 프로세스 (로그아웃) | |
106 | + */ | |
107 | + @Override | |
108 | + public int deleteByRefresh(HttpServletRequest req, HttpServletResponse res) throws Exception { | |
109 | + // refresh token 검증 | |
110 | + int result = (int) refreshTokenCheck(req).get("result"); | |
111 | + if(result == 0) return result; | |
112 | + | |
113 | + //Refresh 토큰 Cookie 값 0 | |
114 | +// res.addCookie(jwtUtil.createCookie("refresh",null, 0)); | |
115 | + | |
116 | + RefreshVO refreshVO = new RefreshVO(); | |
117 | + refreshVO.setMbrId(jwtUtil.getMbrId(refreshTokenCheck(req).get("refreshToken").toString())); | |
118 | + | |
119 | + return delete(req, refreshVO); | |
120 | + } | |
121 | + | |
122 | + /** | |
123 | + * @author takensoft | |
124 | + * @since 2024.04.04 | |
125 | + * 토큰 재발급 | |
126 | + */ | |
127 | + @Override | |
128 | + @Transactional(rollbackFor = Exception.class) | |
129 | + public int tokenReissueProc(HttpServletRequest req, HttpServletResponse res) throws Exception { | |
130 | + // refresh token 검증 | |
131 | + int result = (int) refreshTokenCheck(req).get("result"); | |
132 | + if(result == 0) return result; | |
133 | + | |
134 | + String refreshToken = refreshTokenCheck(req).get("refreshToken").toString(); | |
135 | + | |
136 | + Date expired = jwtUtil.getExpired(refreshToken); | |
137 | + | |
138 | + // 만료시간과 현재 시간의 차이 계산 | |
139 | + long timeDffrnc = (expired.getTime() - new Date().getTime()) / (1000 * 60 * 60); | |
140 | + | |
141 | + MberVO mber = new MberVO(); | |
142 | + List<MberAuthorVO> roles = jwtUtil.getRoles(refreshToken); | |
143 | + mber.setLgnId(jwtUtil.getLgnId(refreshToken)); | |
144 | + mber.setMbrId(jwtUtil.getMbrId(refreshToken)); | |
145 | + mber.setMbrNm(jwtUtil.getMbrNm(refreshToken)); | |
146 | + mber.setAuthorList(roles); | |
147 | + // 신규 AccessToken 발행 | |
148 | + String newAccessToken = jwtUtil.createJwt("Authorization", mber.getMbrId(), mber.getLgnId(), mber.getMbrNm(), (List) mber.getAuthorities(), JWT_ACCESSTIME); | |
149 | + | |
150 | + // 남은 시간이 3시간 미만으로 남았을 경우 RefreshToken 재발급 | |
151 | + if(timeDffrnc < 3) { | |
152 | + RefreshVO refresh = new RefreshVO(); | |
153 | + refresh.setMbrId(mber.getMbrId()); | |
154 | + | |
155 | + // 기존 RefreshToken 삭제 | |
156 | + result += delete(req, refresh); | |
157 | + | |
158 | + // 신규 RefreshToken 발행 | |
159 | + String newRefreshToken = jwtUtil.createJwt("refresh", mber.getMbrId(), mber.getLgnId(), mber.getMbrNm(), (List) mber.getAuthorities(), JWT_REFRESHTIME); | |
160 | + refresh.setToken(newRefreshToken); | |
161 | + result += saveRefreshToken(req, res,refresh, JWT_REFRESHTIME); | |
162 | + | |
163 | + // 응답설정 RefreshToken | |
164 | +// res.setHeader("refresh", newRefreshToken); | |
165 | + // 쿠키 방식 | |
166 | + res.addCookie(jwtUtil.createCookie("refresh",newRefreshToken, COOKIE_TIME)); | |
167 | + } | |
168 | + // 응답설정 AccessToken | |
169 | + res.setHeader("Authorization", newAccessToken); | |
170 | + | |
171 | + return result; | |
172 | + } | |
173 | + | |
174 | + /** | |
175 | + * @author takensoft | |
176 | + * @since 2024.04.04 | |
177 | + * 토큰 삭제 | |
178 | + */ | |
179 | + @Override | |
180 | + public int delete(HttpServletRequest req, RefreshVO refreshVO) throws Exception { | |
181 | + refreshVO.setUseIp(commonUtils.getIp(req)); | |
182 | + return refreshTokenDAO.deleteByRefresh(refreshVO); | |
183 | + } | |
184 | + | |
185 | + /** | |
186 | + * @author takensoft | |
187 | + * @since 2024.04.17 | |
188 | + * refresh token 등록 유무 확인 | |
189 | + */ | |
190 | + @Override | |
191 | + public boolean findByCheckRefresh(HttpServletRequest req, RefreshVO refreshVO) throws Exception { | |
192 | + // 사용중인 아이피 | |
193 | + refreshVO.setUseIp(commonUtils.getIp(req)); | |
194 | + return refreshTokenDAO.findByCheckRefresh(refreshVO); | |
195 | + } | |
196 | + | |
197 | +} |
+++ src/main/java/com/takensoft/cms/mber/service/LgnHstryService.java
... | ... | @@ -0,0 +1,28 @@ |
1 | +package com.takensoft.cms.mber.service; | |
2 | + | |
3 | +import com.takensoft.cms.mber.vo.LgnHstryVO; | |
4 | + | |
5 | +import java.util.HashMap; | |
6 | + | |
7 | +/** | |
8 | + * @author : takensoft | |
9 | + * @since : 2024.04.09 | |
10 | + * | |
11 | + * 로그인 이력 정보 관련 인터페이스 | |
12 | + */ | |
13 | +public interface LgnHstryService { | |
14 | + /** | |
15 | + * @author takensoft | |
16 | + * @since 2024.04.09 | |
17 | + * 로그인 이력 등록 | |
18 | + */ | |
19 | + public int LgnHstrySave(LgnHstryVO lgnHstryVO) throws Exception; | |
20 | + | |
21 | + /** | |
22 | + * @author : 박정하 | |
23 | + * @since : 2024.05.13 | |
24 | + * | |
25 | + * 로그인 이력 목록 조회 | |
26 | + */ | |
27 | + public HashMap<String, Object> lgnHstryList(HashMap<String, String> params) throws Exception; | |
28 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/service/MberService.java
... | ... | @@ -0,0 +1,52 @@ |
1 | +package com.takensoft.cms.mber.service; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
4 | +import com.takensoft.cms.mber.dto.PasswordDTO; | |
5 | +import com.takensoft.cms.mber.vo.MberVO; | |
6 | + | |
7 | +import javax.servlet.http.HttpServletRequest; | |
8 | +import java.util.*; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.04.01 | |
13 | + * | |
14 | + * 회원 정보 관련 인터페이스 | |
15 | + */ | |
16 | +public interface MberService { | |
17 | + /** | |
18 | + * @author takensoft | |
19 | + * @since 2024.04.03 | |
20 | + * | |
21 | + * 아이디 중복 검사 | |
22 | + */ | |
23 | + public boolean findByCheckLoginId(String lgnId) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author takensoft | |
27 | + * @since 2024.04.03 | |
28 | + * 회원가입 | |
29 | + */ | |
30 | + public HashMap<String, Object> userJoin(HttpServletRequest req, JoinDTO joinDTO) throws Exception; | |
31 | + | |
32 | + /** | |
33 | + * @author takensoft | |
34 | + * @since 2024.04.15 | |
35 | + * 비밀번호 비교 | |
36 | + */ | |
37 | + public boolean passwordCheck(PasswordDTO passwordDTO) throws Exception; | |
38 | + | |
39 | + /** | |
40 | + * @author 박정하 | |
41 | + * @since 2024.04.23 | |
42 | + * 회원정보 상세 조회 | |
43 | + */ | |
44 | + public MberVO findByMbr(HashMap<String, Object> params) throws Exception; | |
45 | + | |
46 | + /** | |
47 | + * @author takensoft | |
48 | + * @since 2024.04.24 | |
49 | + * 비밀번호 수정 | |
50 | + */ | |
51 | + public int updatePassword(PasswordDTO passwordDTO) throws Exception; | |
52 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/service/RefreshTokenService.java
... | ... | @@ -0,0 +1,50 @@ |
1 | +package com.takensoft.cms.mber.service; | |
2 | + | |
3 | +import com.takensoft.cms.mber.vo.RefreshVO; | |
4 | + | |
5 | +import javax.servlet.http.HttpServletRequest; | |
6 | +import javax.servlet.http.HttpServletResponse; | |
7 | + | |
8 | +/** | |
9 | + * @author : takensoft | |
10 | + * @since : 2024.04.01 | |
11 | + * | |
12 | + * RefreshToken 정보 관련 인터페이스 | |
13 | + */ | |
14 | +public interface RefreshTokenService { | |
15 | + | |
16 | + /** | |
17 | + * @author takensoft | |
18 | + * @since 2024.04.04 | |
19 | + * refresh token 등록 | |
20 | + */ | |
21 | + public int saveRefreshToken(HttpServletRequest req, HttpServletResponse res, RefreshVO refresh, long expiredMs) throws Exception; | |
22 | + | |
23 | + /** | |
24 | + * @author takensoft | |
25 | + * @since 2024.04.04 | |
26 | + * refresh token 삭제 프로세스 | |
27 | + */ | |
28 | + public int deleteByRefresh(HttpServletRequest req, HttpServletResponse res) throws Exception; | |
29 | + | |
30 | + /** | |
31 | + * @author takensoft | |
32 | + * @since 2024.04.04 | |
33 | + * 토큰 재발급 | |
34 | + */ | |
35 | + public int tokenReissueProc(HttpServletRequest req, HttpServletResponse res) throws Exception; | |
36 | + | |
37 | + /** | |
38 | + * @author takensoft | |
39 | + * @since 2024.04.04 | |
40 | + * 토큰 삭제 | |
41 | + */ | |
42 | + public int delete(HttpServletRequest req, RefreshVO refreshVO) throws Exception; | |
43 | + | |
44 | + /** | |
45 | + * @author takensoft | |
46 | + * @since 2024.04.17 | |
47 | + * refresh token 등록 유무 확인 | |
48 | + */ | |
49 | + public boolean findByCheckRefresh(HttpServletRequest req, RefreshVO refreshVO) throws Exception; | |
50 | +} |
+++ src/main/java/com/takensoft/cms/mber/vo/LgnHstryVO.java
... | ... | @@ -0,0 +1,47 @@ |
1 | +package com.takensoft.cms.mber.vo; | |
2 | + | |
3 | +import lombok.*; | |
4 | + | |
5 | +/** | |
6 | + * @author : takensoft | |
7 | + * @since : 2024.04.01 | |
8 | + * | |
9 | + * 로그인 이력 정보 관련 VO | |
10 | + */ | |
11 | +@Getter | |
12 | +@Setter | |
13 | +@ToString | |
14 | +@Builder | |
15 | +@AllArgsConstructor | |
16 | +@NoArgsConstructor | |
17 | +public class LgnHstryVO { | |
18 | + | |
19 | + /** | |
20 | + * 로그인 아이디 | |
21 | + */ | |
22 | + private String lgnId; | |
23 | + /** | |
24 | + * 로그인 유형 | |
25 | + */ | |
26 | + private String lgnType; | |
27 | + /** | |
28 | + * 접속일 | |
29 | + */ | |
30 | + private String cntnDt; | |
31 | + /** | |
32 | + * 접속 아이피 | |
33 | + */ | |
34 | + private String cntnIp; | |
35 | + /** | |
36 | + * 접속 운영체제 | |
37 | + */ | |
38 | + private String cntnOperSys; | |
39 | + /** | |
40 | + * 디바이스명 | |
41 | + */ | |
42 | + private String deviceNm; | |
43 | + /** | |
44 | + * 브라우저명 | |
45 | + */ | |
46 | + private String brwsrNm; | |
47 | +} |
+++ src/main/java/com/takensoft/cms/mber/vo/MberAuthorVO.java
... | ... | @@ -0,0 +1,38 @@ |
1 | +package com.takensoft.cms.mber.vo; | |
2 | + | |
3 | +import lombok.*; | |
4 | + | |
5 | +/** | |
6 | + * @author : takensoft | |
7 | + * @since : 2024.04.01 | |
8 | + * | |
9 | + * 회원 권한 정보 관련 VO | |
10 | + */ | |
11 | +@Getter | |
12 | +@Setter | |
13 | +@ToString | |
14 | +@Builder | |
15 | +@AllArgsConstructor | |
16 | +@NoArgsConstructor | |
17 | +public class MberAuthorVO { | |
18 | + /** | |
19 | + * 회원 아이디 | |
20 | + */ | |
21 | + private String mbrId; | |
22 | + /** | |
23 | + * 권한명 | |
24 | + */ | |
25 | + private String authrtNm; | |
26 | + /** | |
27 | + * 권한 코드 | |
28 | + */ | |
29 | + private String authrtCd; | |
30 | + /** | |
31 | + * 등록자 | |
32 | + */ | |
33 | + private String rgtr; | |
34 | + /** | |
35 | + * 등록일 | |
36 | + */ | |
37 | + private String regDt; | |
38 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/vo/MberVO.java
... | ... | @@ -0,0 +1,190 @@ |
1 | +package com.takensoft.cms.mber.vo; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | +import org.springframework.security.core.GrantedAuthority; | |
9 | +import org.springframework.security.core.authority.SimpleGrantedAuthority; | |
10 | +import org.springframework.security.core.userdetails.UserDetails; | |
11 | + | |
12 | +import java.io.Serializable; | |
13 | +import java.util.ArrayList; | |
14 | +import java.util.Collection; | |
15 | +import java.util.List; | |
16 | +import java.util.stream.Collectors; | |
17 | + | |
18 | +/** | |
19 | + * @author : takensoft | |
20 | + * @since : 2024.04.01 | |
21 | + * | |
22 | + * 회원 정보 관련 VO | |
23 | + * UserDetails : security 사용을 위해 상속 | |
24 | + * Serializable : 직렬화를 위해 상속 | |
25 | + */ | |
26 | +@Setter | |
27 | +@Getter | |
28 | +@NoArgsConstructor | |
29 | +@AllArgsConstructor | |
30 | +public class MberVO implements UserDetails, Serializable { | |
31 | + | |
32 | + private static final long serialVersionUID = 1L; | |
33 | + | |
34 | + /** | |
35 | + * 회원 아이디 | |
36 | + */ | |
37 | + private String mbrId; | |
38 | + /** | |
39 | + * 로그인 아이디 | |
40 | + */ | |
41 | + private String lgnId; | |
42 | + /** | |
43 | + * 회원 이름 | |
44 | + */ | |
45 | + private String mbrNm; | |
46 | + /** | |
47 | + * 닉네임 | |
48 | + */ | |
49 | + private String ncnm; | |
50 | + /** | |
51 | + * 비밀번호 | |
52 | + */ | |
53 | + private String pswd; | |
54 | + /** | |
55 | + * 휴대폰번호 | |
56 | + */ | |
57 | + private String mblTelno; | |
58 | + /** | |
59 | + * 전화번호 | |
60 | + */ | |
61 | + private String telno; | |
62 | + /** | |
63 | + * 이메일 | |
64 | + */ | |
65 | + private String eml; | |
66 | + /** | |
67 | + * 우편번호 | |
68 | + */ | |
69 | + private String zip; | |
70 | + /** | |
71 | + * 주소 | |
72 | + */ | |
73 | + private String addr; | |
74 | + /** | |
75 | + * 상세주소 | |
76 | + */ | |
77 | + private String daddr; | |
78 | + /** | |
79 | + * 회원상태 | |
80 | + * 0: 탈퇴, 1: 승인, 2: 승인대기, 3: 차단 | |
81 | + */ | |
82 | + private String mbrStts; | |
83 | + /** | |
84 | + * 사용여부 | |
85 | + */ | |
86 | + private boolean useYn; | |
87 | + /** | |
88 | + * 차단일 | |
89 | + */ | |
90 | + private String cntrlDt; | |
91 | + /** | |
92 | + * 차단사유 | |
93 | + */ | |
94 | + private String cntrlRsn; | |
95 | + /** | |
96 | + * 문자수신여부 | |
97 | + * 0: 거부, 1: 허용 | |
98 | + */ | |
99 | + private String smsRcptnAgreYn; | |
100 | + /** | |
101 | + * 이메일수신여부 | |
102 | + * 0: 거부, 1: 허용 | |
103 | + */ | |
104 | + private String emlRcptnAgreYn; | |
105 | + /** | |
106 | + * 개인정보공개여부 | |
107 | + * 0: 거부, 1: 허용 | |
108 | + */ | |
109 | + private String prvcRlsYn; | |
110 | + /** | |
111 | + * 회원형태 | |
112 | + * S: 시스템, K: 카카오, N: 네이버, G: 구글, F: 페이스북 | |
113 | + */ | |
114 | + private String mbrType; | |
115 | + /** | |
116 | + * 비밀번호 변경일 | |
117 | + */ | |
118 | + private String pswdChgDt; | |
119 | + /** | |
120 | + * 최초등록 아이디 | |
121 | + */ | |
122 | + private String frstRegIp; | |
123 | + /** | |
124 | + * 시스템 제공 여부 -> 시스템에서 제공되는 데이터는 사용자가 제거하지 못하도록 하기 위한 설정값 | |
125 | + * 0: 시스템, 1: 사용자 | |
126 | + */ | |
127 | + private String sysPvsnYn; | |
128 | + /** | |
129 | + * 등록자 | |
130 | + */ | |
131 | + private String rgtr; | |
132 | + /** | |
133 | + * 등록일 | |
134 | + */ | |
135 | + private String regDt; | |
136 | + /** | |
137 | + * 수정자 | |
138 | + */ | |
139 | + private String mdfr; | |
140 | + /** | |
141 | + * 수정일 | |
142 | + */ | |
143 | + private String mdfcnDt; | |
144 | + /** | |
145 | + * 권한 정보 | |
146 | + */ | |
147 | + @JsonIgnore | |
148 | + private List<MberAuthorVO> authorList = new ArrayList<MberAuthorVO>(); | |
149 | + | |
150 | + @Override | |
151 | + public Collection<? extends GrantedAuthority> getAuthorities() { | |
152 | + if(this.authorList.size() > 0) { | |
153 | + return this.authorList.stream().map(auth -> new SimpleGrantedAuthority( | |
154 | + auth.getAuthrtCd() | |
155 | + )).collect(Collectors.toList()); | |
156 | + } else { | |
157 | + return null; | |
158 | + } | |
159 | + } | |
160 | + | |
161 | + @Override | |
162 | + public String getPassword() { | |
163 | + return this.pswd; | |
164 | + } | |
165 | + | |
166 | + @Override | |
167 | + public String getUsername() { | |
168 | + return this.lgnId; | |
169 | + } | |
170 | + | |
171 | + @Override | |
172 | + public boolean isAccountNonExpired() { | |
173 | + return this.useYn; | |
174 | + } | |
175 | + | |
176 | + @Override | |
177 | + public boolean isAccountNonLocked() { | |
178 | + return this.useYn; | |
179 | + } | |
180 | + | |
181 | + @Override | |
182 | + public boolean isCredentialsNonExpired() { | |
183 | + return this.useYn; | |
184 | + } | |
185 | + | |
186 | + @Override | |
187 | + public boolean isEnabled() { | |
188 | + return this.useYn; | |
189 | + } | |
190 | +} |
+++ src/main/java/com/takensoft/cms/mber/vo/RefreshVO.java
... | ... | @@ -0,0 +1,37 @@ |
1 | +package com.takensoft.cms.mber.vo; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import lombok.Setter; | |
7 | + | |
8 | +import java.util.Date; | |
9 | + | |
10 | +/** | |
11 | + * @author : takensoft | |
12 | + * @since : 2024.04.01 | |
13 | + * | |
14 | + * RefreshToken 정보 관련 VO | |
15 | + */ | |
16 | +@Setter | |
17 | +@Getter | |
18 | +@NoArgsConstructor | |
19 | +@AllArgsConstructor | |
20 | +public class RefreshVO { | |
21 | + /** | |
22 | + * 회원 아이디 | |
23 | + */ | |
24 | + private String mbrId; | |
25 | + /** | |
26 | + * 토큰 | |
27 | + */ | |
28 | + private String token; | |
29 | + /** | |
30 | + * 만료기간 expry_dt expryYmd | |
31 | + */ | |
32 | + private Date expryDt; | |
33 | + /** | |
34 | + * 사용중인 아이피 | |
35 | + */ | |
36 | + private String useIp; | |
37 | +} |
+++ src/main/java/com/takensoft/cms/mber/web/AdmMbrController.java
... | ... | @@ -0,0 +1,277 @@ |
1 | +package com.takensoft.cms.mber.web; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dto.AdmMbrDTO; | |
4 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
5 | +import com.takensoft.cms.mber.dto.PasswordDTO; | |
6 | +import com.takensoft.cms.mber.service.AdmMbrService; | |
7 | +import com.takensoft.cms.mber.service.MberService; | |
8 | +import com.takensoft.cms.mber.vo.MberVO; | |
9 | +import com.takensoft.common.exception.IdDuplicationException; | |
10 | +import com.takensoft.common.util.ResponseData; | |
11 | +import lombok.RequiredArgsConstructor; | |
12 | +import org.springframework.http.HttpHeaders; | |
13 | +import org.springframework.http.HttpStatus; | |
14 | +import org.springframework.http.MediaType; | |
15 | +import org.springframework.http.ResponseEntity; | |
16 | +import org.springframework.web.bind.annotation.PostMapping; | |
17 | +import org.springframework.web.bind.annotation.RequestBody; | |
18 | +import org.springframework.web.bind.annotation.RequestMapping; | |
19 | +import org.springframework.web.bind.annotation.RestController; | |
20 | +import org.springframework.beans.factory.annotation.Value; | |
21 | + | |
22 | +import javax.servlet.http.HttpServletRequest; | |
23 | +import javax.validation.Valid; | |
24 | +import java.nio.charset.Charset; | |
25 | +import java.util.*; | |
26 | + | |
27 | +/** | |
28 | + * @author : 박정하 | |
29 | + * @since : 2024.06.21 | |
30 | + * | |
31 | + * 회원정보 관련 컨트롤러 | |
32 | + */ | |
33 | +@RestController | |
34 | +@RequiredArgsConstructor | |
35 | +@RequestMapping(value = "/mbr") | |
36 | +public class AdmMbrController { | |
37 | + private final AdmMbrService admMbrService; | |
38 | + private final MberService mbrService; | |
39 | + | |
40 | + /** | |
41 | + * @author 박정하 | |
42 | + * @since 2024.06.21 | |
43 | + * @param params | |
44 | + * @return | |
45 | + * @throws Exception | |
46 | + * | |
47 | + * 회원정보 목록 조회 | |
48 | + */ | |
49 | + @PostMapping(value = "/listProc.json") | |
50 | + public ResponseEntity<?> listProc(@RequestBody HashMap<String, String> params) throws Exception { | |
51 | + HashMap<String, Object> result = admMbrService.mbrList(params); | |
52 | + | |
53 | + // 응답 처리 | |
54 | + HttpHeaders headers = new HttpHeaders(); | |
55 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
56 | + ResponseData responseData = new ResponseData(); | |
57 | + responseData.setStatus(HttpStatus.OK); | |
58 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
59 | + responseData.setData(result); | |
60 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
61 | + } | |
62 | + | |
63 | + /** | |
64 | + * @author 박정하 | |
65 | + * @since 2024.06.21 | |
66 | + * @param resetPswd, admMbrDTO | |
67 | + * @return | |
68 | + * @throws Exception | |
69 | + * | |
70 | + * 회원정보 비밀번호 초기화 | |
71 | + */ | |
72 | + @PostMapping(value = "/pswdResetProc.json") | |
73 | + public ResponseEntity<?> pswdResetProc(@Value("${password.reset}") String resetPswd, @RequestBody AdmMbrDTO admMbrDTO) throws Exception { | |
74 | + PasswordDTO passwordDTO = new PasswordDTO(); | |
75 | + passwordDTO.setMbrId(admMbrDTO.getMbrId()); | |
76 | + passwordDTO.setPswd(admMbrDTO.getPswd()); | |
77 | + passwordDTO.setNewPswd(resetPswd); | |
78 | + | |
79 | + // 비밀번호 변경 | |
80 | + int result = mbrService.updatePassword(passwordDTO); | |
81 | + | |
82 | + // 응답 처리 | |
83 | + HttpHeaders headers = new HttpHeaders(); | |
84 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
85 | + ResponseData responseData = new ResponseData(); | |
86 | + if(result > 0) { | |
87 | + responseData.setStatus(HttpStatus.OK); | |
88 | + responseData.setMessage("정상적으로 초기화 처리되었습니다."); | |
89 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
90 | + } else { | |
91 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
92 | + responseData.setMessage("초기화에 실패하였습니다.\n담당자에게 문의하세요."); | |
93 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
94 | + } | |
95 | + } | |
96 | + | |
97 | + /** | |
98 | + * @author 박정하 | |
99 | + * @since 2024.06.21 | |
100 | + * @param admMbrDTO | |
101 | + * @return | |
102 | + * @throws Exception | |
103 | + * | |
104 | + * 회원정보 상세 조회 | |
105 | + */ | |
106 | + @PostMapping(value = "/detailProc.json") | |
107 | + public ResponseEntity<?> detailProc(@RequestBody AdmMbrDTO admMbrDTO) throws Exception { | |
108 | + // 상세 조회 | |
109 | + AdmMbrDTO result = admMbrService.mbrDetail(admMbrDTO.getMbrId()); | |
110 | + | |
111 | + // 응답 처리 | |
112 | + HttpHeaders headers = new HttpHeaders(); | |
113 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
114 | + ResponseData responseData = new ResponseData(); | |
115 | + responseData.setStatus(HttpStatus.OK); | |
116 | + responseData.setMessage("정상적으로 회원정보 상세 조회가 처리되었습니다."); | |
117 | + responseData.setData(result); | |
118 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
119 | + } | |
120 | + | |
121 | + /** | |
122 | + * @author 박정하 | |
123 | + * @since 2024.06.21 | |
124 | + * @param admMbrDTO | |
125 | + * @return | |
126 | + * @throws Exception | |
127 | + * | |
128 | + * 회원정보 수정 | |
129 | + */ | |
130 | + @PostMapping(value = "/updateProc.json") | |
131 | + public ResponseEntity<?> updateProc(@RequestBody AdmMbrDTO admMbrDTO) throws Exception { | |
132 | + int result = admMbrService.updateMbr(admMbrDTO); | |
133 | + | |
134 | + // 응답 처리 | |
135 | + HttpHeaders headers = new HttpHeaders(); | |
136 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
137 | + ResponseData responseData = new ResponseData(); | |
138 | + if(result > 0) { | |
139 | + responseData.setStatus(HttpStatus.OK); | |
140 | + responseData.setMessage("정상적으로 수정되었습니다."); | |
141 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
142 | + } else { | |
143 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
144 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
145 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
146 | + } | |
147 | + } | |
148 | + | |
149 | + /** | |
150 | + * @author 박정하 | |
151 | + * @since 2024.06.21 | |
152 | + * @param admMbrDTO | |
153 | + * @return | |
154 | + * @throws Exception | |
155 | + * | |
156 | + * 회원정보 삭제 | |
157 | + */ | |
158 | + @PostMapping(value = "/deleteProc.json") | |
159 | + public ResponseEntity<?> deleteProc(@RequestBody AdmMbrDTO admMbrDTO) throws Exception { | |
160 | + admMbrDTO.setUseYn("N"); // 회원정보 삭제 | |
161 | + int result = admMbrService.updateMbr(admMbrDTO); | |
162 | + | |
163 | + // 응답 처리 | |
164 | + HttpHeaders headers = new HttpHeaders(); | |
165 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
166 | + ResponseData responseData = new ResponseData(); | |
167 | + if(result > 0) { | |
168 | + responseData.setStatus(HttpStatus.OK); | |
169 | + responseData.setMessage("정상적으로 삭제되었습니다."); | |
170 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
171 | + } else { | |
172 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
173 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
174 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
175 | + } | |
176 | + } | |
177 | + | |
178 | + /** | |
179 | + * @author 박정하 | |
180 | + * @since 2024.06.21 | |
181 | + * @param req, joinDTO | |
182 | + * @return | |
183 | + * @throws Exception | |
184 | + * | |
185 | + * 회원정보 등록 | |
186 | + */ | |
187 | + @PostMapping(value = "/joinProc.json") | |
188 | + public ResponseEntity<?> joinProc(HttpServletRequest req, @RequestBody @Valid JoinDTO joinDTO) throws Exception { | |
189 | + // 응답 처리 | |
190 | + HttpHeaders headers = new HttpHeaders(); | |
191 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
192 | + ResponseData responseData = new ResponseData(); | |
193 | + | |
194 | + // 아이디 중복 검사 | |
195 | + boolean isExistence = mbrService.findByCheckLoginId(joinDTO.getLgnId()); | |
196 | + if(isExistence) { | |
197 | +// throw new IdDuplicationException("이미 존재하는 아이디입니다."); | |
198 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
199 | + responseData.setMessage("이미 존재하는 아이디입니다."); | |
200 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
201 | + } | |
202 | + | |
203 | + // 회원 가입 진행 | |
204 | + HashMap<String, Object> result = admMbrService.mbrInsert(req, joinDTO); | |
205 | + int insertResult = (int) result.get("insertResult"); | |
206 | + | |
207 | + if(insertResult > 0) { | |
208 | + responseData.setStatus(HttpStatus.OK); | |
209 | + responseData.setMessage("정상적으로 회원가입 처리되었습니다."); | |
210 | + responseData.setData(result); | |
211 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
212 | + } else { | |
213 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
214 | + responseData.setMessage("회원가입에 실패하였습니다.\n담당자에게 문의하세요."); | |
215 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
216 | + } | |
217 | + } | |
218 | + | |
219 | + /** | |
220 | + * @author 박정하 | |
221 | + * @since 2024.07.03 | |
222 | + * @param mbrVO | |
223 | + * @return | |
224 | + * @throws Exception | |
225 | + * | |
226 | + * 아이디 찾기 | |
227 | + */ | |
228 | + @PostMapping(value = "/searchIdProc.json") | |
229 | + public ResponseEntity<?> searchIdProc(@RequestBody MberVO mbrVO) throws Exception { | |
230 | + String result = admMbrService.lgnIdSearch(mbrVO); | |
231 | + | |
232 | + // 응답 처리 | |
233 | + HttpHeaders headers = new HttpHeaders(); | |
234 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
235 | + ResponseData responseData = new ResponseData(); | |
236 | + if(result != null) { | |
237 | + responseData.setStatus(HttpStatus.OK); | |
238 | + responseData.setMessage("정상적으로 조회 처리되었습니다."); | |
239 | + responseData.setData(result); | |
240 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
241 | + } else { | |
242 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
243 | + responseData.setMessage("입력하신 정보와 일치하는 회원이 존재하지 않습니다.\n다시 시도하세요."); | |
244 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
245 | + } | |
246 | + } | |
247 | + | |
248 | + | |
249 | + /** | |
250 | + * @author 박정하 | |
251 | + * @since 2024.07.03 | |
252 | + * @param admMbrDTO | |
253 | + * @return | |
254 | + * @throws Exception | |
255 | + * | |
256 | + * 비밀번호 초기화 | |
257 | + */ | |
258 | + @PostMapping(value = "/resetPswdProc.json") | |
259 | + public ResponseEntity<?> resetPswdProc(@Value("${password.reset}") String resetPswd, @RequestBody AdmMbrDTO admMbrDTO) throws Exception { | |
260 | + int result = admMbrService.mbrIdSearch(resetPswd, admMbrDTO); | |
261 | + | |
262 | + // 응답 처리 | |
263 | + HttpHeaders headers = new HttpHeaders(); | |
264 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
265 | + ResponseData responseData = new ResponseData(); | |
266 | + if(result > 0) { | |
267 | + responseData.setStatus(HttpStatus.OK); | |
268 | + responseData.setMessage("정상적으로 조회 처리되었습니다."); | |
269 | + responseData.setData(result); | |
270 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
271 | + } else { | |
272 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
273 | + responseData.setMessage("입력하신 정보와 일치하는 회원이 존재하지 않습니다.\n다시 시도하세요."); | |
274 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
275 | + } | |
276 | + } | |
277 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/web/LgnHstryController.java
... | ... | @@ -0,0 +1,52 @@ |
1 | +package com.takensoft.cms.mber.web; | |
2 | + | |
3 | +import com.takensoft.cms.mber.service.LgnHstryService; | |
4 | +import com.takensoft.common.util.ResponseData; | |
5 | +import lombok.RequiredArgsConstructor; | |
6 | +import org.springframework.http.HttpHeaders; | |
7 | +import org.springframework.http.HttpStatus; | |
8 | +import org.springframework.http.MediaType; | |
9 | +import org.springframework.http.ResponseEntity; | |
10 | +import org.springframework.web.bind.annotation.PostMapping; | |
11 | +import org.springframework.web.bind.annotation.RequestBody; | |
12 | +import org.springframework.web.bind.annotation.RequestMapping; | |
13 | +import org.springframework.web.bind.annotation.RestController; | |
14 | + | |
15 | +import java.nio.charset.Charset; | |
16 | +import java.util.HashMap; | |
17 | + | |
18 | +/** | |
19 | + * @author : 박정하 | |
20 | + * @since : 2024.05.24 | |
21 | + * | |
22 | + * 로그인 이력 관련 컨트롤러 | |
23 | + */ | |
24 | +@RestController | |
25 | +@RequiredArgsConstructor | |
26 | +@RequestMapping(value = "/admin/lgnHstry") | |
27 | +public class LgnHstryController { | |
28 | + private final LgnHstryService lgnHstryService; | |
29 | + | |
30 | + /** | |
31 | + * @author 박정하 | |
32 | + * @since 2024.05.13 | |
33 | + * @param params | |
34 | + * @return | |
35 | + * @throws Exception | |
36 | + * | |
37 | + * 로그인 이력 목록 조회 | |
38 | + */ | |
39 | + @PostMapping("/listProc.json") | |
40 | + public ResponseEntity<?> listProc(@RequestBody HashMap<String, String> params) throws Exception { | |
41 | + HashMap<String, Object> result = lgnHstryService.lgnHstryList(params); | |
42 | + | |
43 | + // 응답 처리 | |
44 | + HttpHeaders headers = new HttpHeaders(); | |
45 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
46 | + ResponseData responseData = new ResponseData(); | |
47 | + responseData.setStatus(HttpStatus.OK); | |
48 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
49 | + responseData.setData(result); | |
50 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
51 | + } | |
52 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/web/MberController.java
... | ... | @@ -0,0 +1,87 @@ |
1 | +package com.takensoft.cms.mber.web; | |
2 | + | |
3 | +import com.takensoft.cms.mber.dto.JoinDTO; | |
4 | +import com.takensoft.cms.mber.dto.PasswordDTO; | |
5 | +import com.takensoft.cms.mber.service.MberService; | |
6 | +import com.takensoft.cms.mber.vo.MberVO; | |
7 | +import com.takensoft.common.exception.IdDuplicationException; | |
8 | +import com.takensoft.common.util.ResponseData; | |
9 | +import lombok.RequiredArgsConstructor; | |
10 | +import lombok.extern.slf4j.Slf4j; | |
11 | +import org.springframework.http.HttpHeaders; | |
12 | +import org.springframework.http.HttpStatus; | |
13 | +import org.springframework.http.MediaType; | |
14 | +import org.springframework.http.ResponseEntity; | |
15 | +import org.springframework.web.bind.annotation.*; | |
16 | + | |
17 | +import javax.servlet.http.HttpServletRequest; | |
18 | +import javax.validation.Valid; | |
19 | +import java.nio.charset.Charset; | |
20 | +import java.util.HashMap; | |
21 | + | |
22 | +/** | |
23 | + * @author : takensoft | |
24 | + * @since : 2024.04.01 | |
25 | + * | |
26 | + * 회원 정보 관련 컨트롤러 | |
27 | + */ | |
28 | +@RestController | |
29 | +@RequiredArgsConstructor | |
30 | +@Slf4j | |
31 | +@RequestMapping(value = "/mbr") | |
32 | +public class MberController { | |
33 | + private final MberService mberService; | |
34 | + | |
35 | + /** | |
36 | + * @author takensoft | |
37 | + * @since 2024.04.16 | |
38 | + * @param | |
39 | + * @return | |
40 | + * @throws Exception | |
41 | + * | |
42 | + * 회원정보 상세 조회 | |
43 | + */ | |
44 | + @PostMapping(value = "/findByMbr.json") | |
45 | + public ResponseEntity<?> findByMbr(@RequestBody HashMap<String, Object> params) throws Exception { | |
46 | + // 상세 조회 | |
47 | + MberVO result = mberService.findByMbr(params); | |
48 | + | |
49 | + // 응답 처리 | |
50 | + HttpHeaders headers = new HttpHeaders(); | |
51 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
52 | + ResponseData responseData = new ResponseData(); | |
53 | + responseData.setStatus(HttpStatus.OK); | |
54 | + responseData.setMessage("정상적으로 회원정보 상세 조회가 처리되었습니다."); | |
55 | + responseData.setData(result); | |
56 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
57 | + } | |
58 | + | |
59 | + /** | |
60 | + * @author takensoft | |
61 | + * @since 2024.04.15 | |
62 | + * @param passwordDTO | |
63 | + * @return | |
64 | + * @throws Exception | |
65 | + * | |
66 | + * 비밀번호 변경 | |
67 | + */ | |
68 | + @PostMapping(value = "/updatePassword.json") | |
69 | + public ResponseEntity<?> joinProc(@RequestBody @Valid PasswordDTO passwordDTO) throws Exception { | |
70 | + // 비밀 번호 비교 | |
71 | + boolean isExistence = mberService.passwordCheck(passwordDTO); | |
72 | + | |
73 | + // 응답 처리 | |
74 | + HttpHeaders headers = new HttpHeaders(); | |
75 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
76 | + ResponseData responseData = new ResponseData(); | |
77 | + if(isExistence) { | |
78 | + responseData.setStatus(HttpStatus.OK); | |
79 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
80 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
81 | + } else { | |
82 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
83 | + responseData.setMessage("비밀번호를 확인하세요."); | |
84 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
85 | + } | |
86 | + } | |
87 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/mber/web/RefreshTokenController.java
... | ... | @@ -0,0 +1,89 @@ |
1 | +package com.takensoft.cms.mber.web; | |
2 | + | |
3 | + | |
4 | +import com.takensoft.cms.mber.service.RefreshTokenService; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import lombok.extern.slf4j.Slf4j; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.HttpStatus; | |
10 | +import org.springframework.http.MediaType; | |
11 | +import org.springframework.http.ResponseEntity; | |
12 | +import org.springframework.web.bind.annotation.PostMapping; | |
13 | +import org.springframework.web.bind.annotation.RestController; | |
14 | + | |
15 | +import javax.servlet.http.Cookie; | |
16 | +import javax.servlet.http.HttpServletRequest; | |
17 | +import javax.servlet.http.HttpServletResponse; | |
18 | +import java.nio.charset.Charset; | |
19 | + | |
20 | +/** | |
21 | + * @author : takensoft | |
22 | + * @since : 2024.04.01 | |
23 | + * | |
24 | + * RefreshToken 정보 관련 컨트롤러 | |
25 | + */ | |
26 | +@RestController | |
27 | +@RequiredArgsConstructor | |
28 | +@Slf4j | |
29 | +public class RefreshTokenController { | |
30 | + | |
31 | + private final RefreshTokenService refreshTokenService; | |
32 | + | |
33 | + /** | |
34 | + * @author takensoft | |
35 | + * @since 2024.04.04 | |
36 | + * @return | |
37 | + * @throws Exception | |
38 | + * 로그아웃 | |
39 | + */ | |
40 | + @PostMapping(value = "/mbr/logout.json") | |
41 | + public ResponseEntity<?> logout(HttpServletRequest req, HttpServletResponse res) throws Exception { | |
42 | + int result = refreshTokenService.deleteByRefresh(req, res); | |
43 | + // 응답 처리 | |
44 | + HttpHeaders headers = new HttpHeaders(); | |
45 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
46 | + ResponseData responseData = new ResponseData(); | |
47 | + if(result > 0) { | |
48 | + Cookie cookie = new Cookie("refresh", null); | |
49 | + cookie.setMaxAge(0); // 생명주기 | |
50 | + //cookie.setSecure(true); // https 통신을 할 경우 true로 사용 | |
51 | + cookie.setPath("/"); // 쿠키 적용 범위 | |
52 | + cookie.setHttpOnly(true); | |
53 | + res.addCookie(cookie); | |
54 | + responseData.setStatus(HttpStatus.OK); | |
55 | + responseData.setMessage("정상적으로 로그아웃 처리되었습니다."); | |
56 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
57 | + } else { | |
58 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
59 | + responseData.setMessage("로그아웃에 실패하였습니다.\n담당자에게 문의하세요."); | |
60 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
61 | + } | |
62 | + } | |
63 | + | |
64 | + /** | |
65 | + * @author takensoft | |
66 | + * @since 2024.04.04 | |
67 | + * @return | |
68 | + * @throws Exception | |
69 | + * 토큰 재발급 | |
70 | + */ | |
71 | + @PostMapping("/refresh/tokenReissue.json") | |
72 | + public ResponseEntity<?> tokenReissue(HttpServletRequest req, HttpServletResponse res) throws Exception { | |
73 | + int result = refreshTokenService.tokenReissueProc(req, res); | |
74 | + | |
75 | + // 응답 처리 | |
76 | + HttpHeaders headers = new HttpHeaders(); | |
77 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
78 | + ResponseData responseData = new ResponseData(); | |
79 | + if(result > 0) { | |
80 | + responseData.setStatus(HttpStatus.OK); | |
81 | + responseData.setMessage("정상적으로 발급 처리되었습니다."); | |
82 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
83 | + } else { | |
84 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
85 | + responseData.setMessage("로그인을 다시해주시기 바랍니다."); | |
86 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
87 | + } | |
88 | + } | |
89 | +} |
+++ src/main/java/com/takensoft/cms/popup/Schedule/PopupScheduler.java
... | ... | @@ -0,0 +1,33 @@ |
1 | +package com.takensoft.cms.popup.Schedule; | |
2 | + | |
3 | +import com.takensoft.cms.popup.dao.PopupDAO; | |
4 | +import org.springframework.scheduling.annotation.Scheduled; | |
5 | +import org.springframework.stereotype.Component; | |
6 | +import org.springframework.transaction.annotation.Transactional; | |
7 | + | |
8 | +/** | |
9 | + * @author : 박정하 | |
10 | + * @since : 2024.05.23 | |
11 | + * | |
12 | + * 팝업 종료일이 된 팝업 제거를 위한 스케쥴러 | |
13 | + */ | |
14 | +@Component | |
15 | +public class PopupScheduler { | |
16 | + private final PopupDAO popupDAO; | |
17 | + | |
18 | + public PopupScheduler(PopupDAO popupDAO) { | |
19 | + this.popupDAO = popupDAO; | |
20 | + } | |
21 | + | |
22 | + /** | |
23 | + * @author : 박정하 | |
24 | + * @since : 2024.05.23 | |
25 | + * | |
26 | + * 매일 자정에 종료일이 지난 팝업 삭제 | |
27 | + */ | |
28 | + @Scheduled(cron = "0 0 0 * * *") | |
29 | + @Transactional(rollbackFor = Exception.class) | |
30 | + public void cleanExpiredPopups() throws Exception { | |
31 | + popupDAO.cleanExpiredPopups(); | |
32 | + } | |
33 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/popup/dao/PopupDAO.java
... | ... | @@ -0,0 +1,80 @@ |
1 | +package com.takensoft.cms.popup.dao; | |
2 | + | |
3 | +import com.takensoft.cms.popup.vo.PopupVO; | |
4 | +import com.takensoft.common.Pagination; | |
5 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
6 | + | |
7 | +import java.util.*; | |
8 | + | |
9 | +/** | |
10 | + * @author : 박정하 | |
11 | + * @since : 2024.05.13 | |
12 | + * | |
13 | + * 팝업 관련 Mapper | |
14 | + */ | |
15 | +@Mapper("popupDAO") | |
16 | +public interface PopupDAO { | |
17 | + /** | |
18 | + * @author : 박정하 | |
19 | + * @since : 2024.05.13 | |
20 | + * | |
21 | + * 팝업 등록 | |
22 | + */ | |
23 | + public int insertPopup(PopupVO popupVO) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author : 박정하 | |
27 | + * @since : 2024.05.13 | |
28 | + * | |
29 | + * 팝업 목록 갯수 | |
30 | + */ | |
31 | + public int selectPopupListCnt(Pagination pagination) throws Exception; | |
32 | + | |
33 | + /** | |
34 | + * @author : 박정하 | |
35 | + * @since : 2024.05.13 | |
36 | + * | |
37 | + * 팝업 목록 조회 | |
38 | + */ | |
39 | + public List<PopupVO> selectPopupList(Pagination pagination) throws Exception; | |
40 | + | |
41 | + /** | |
42 | + * @author : 박정하 | |
43 | + * @since : 2024.05.13 | |
44 | + * | |
45 | + * 팝업 목록 상세 | |
46 | + */ | |
47 | + public PopupVO selectPopupDetail(PopupVO popupVO) throws Exception; | |
48 | + | |
49 | + /** | |
50 | + * @author : 박정하 | |
51 | + * @since : 2024.05.13 | |
52 | + * | |
53 | + * 팝업 수정 | |
54 | + */ | |
55 | + public int updatePopup(PopupVO popupVO) throws Exception; | |
56 | + | |
57 | + /** | |
58 | + * @author : 박정하 | |
59 | + * @since : 2024.05.22 | |
60 | + * | |
61 | + * 팝업 목록 조회 (팝업창 띄우는 용도) | |
62 | + */ | |
63 | + public List<PopupVO> selectPopupListByPage(String pageType) throws Exception; | |
64 | + | |
65 | + /** | |
66 | + * @author : 박정하 | |
67 | + * @since : 2024.05.23 | |
68 | + * | |
69 | + * 매일 자정에 종료일이 지난 팝업 삭제 | |
70 | + */ | |
71 | + public int cleanExpiredPopups() throws Exception; | |
72 | + | |
73 | + /** | |
74 | + * @author : 박정하 | |
75 | + * @since : 2024.05.28 | |
76 | + * | |
77 | + * 팝업 최신 목록 조회 (최신글 5건 출력) | |
78 | + */ | |
79 | + public List<PopupVO> selectPopupListByNew() throws Exception; | |
80 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/popup/service/Impl/PopupServiceImpl.java
... | ... | @@ -0,0 +1,242 @@ |
1 | +package com.takensoft.cms.popup.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
4 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
5 | +import com.takensoft.cms.popup.dao.PopupDAO; | |
6 | +import com.takensoft.cms.popup.service.PopupService; | |
7 | +import com.takensoft.cms.popup.vo.PopupVO; | |
8 | +import com.takensoft.common.Pagination; | |
9 | +import com.takensoft.common.file.service.FileMngService; | |
10 | +import com.takensoft.common.file.vo.FileMngVO; | |
11 | +import com.takensoft.common.idgen.service.IdgenService; | |
12 | +import com.takensoft.common.util.JWTUtil; | |
13 | +import lombok.RequiredArgsConstructor; | |
14 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
15 | +import org.springframework.stereotype.Service; | |
16 | +import org.springframework.transaction.annotation.Transactional; | |
17 | +import org.springframework.web.multipart.MultipartFile; | |
18 | + | |
19 | +import java.io.IOException; | |
20 | +import java.util.*; | |
21 | + | |
22 | +/** | |
23 | + * @author : 박정하 | |
24 | + * @since : 2024.05.13 | |
25 | + * | |
26 | + * 팝업 관련 구현체 | |
27 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
28 | + * PopupService : 팝업 관련 인터페이스 상속 | |
29 | + */ | |
30 | +@Service("popupService") | |
31 | +@RequiredArgsConstructor | |
32 | +public class PopupServiceImpl extends EgovAbstractServiceImpl implements PopupService { | |
33 | + private final JWTUtil jwtUtil; | |
34 | + private final PopupDAO popupDAO; | |
35 | + private final IdgenService popupIdgn; | |
36 | + private final FileMngService fileMngService; | |
37 | + private final CodeManageService codeManageService; | |
38 | + | |
39 | + /** | |
40 | + * @author : 박정하 | |
41 | + * @since : 2024.05.13 | |
42 | + * | |
43 | + * 팝업 등록 | |
44 | + */ | |
45 | + @Override | |
46 | + @Transactional(rollbackFor = Exception.class) | |
47 | + public HashMap<String, Object> popupInsert(PopupVO popupVO, List<MultipartFile> multipartFileList) throws Exception { | |
48 | + // 투자상담 아이디 생성 | |
49 | + String popupId = popupIdgn.getNextStringId(); | |
50 | + popupVO.setPopupId(popupId); | |
51 | + | |
52 | + // 등록자 삽입 | |
53 | + String writer = jwtUtil.getWriter(); | |
54 | + popupVO.setRgtr(writer); | |
55 | + | |
56 | + HashMap<String, Object> result = new HashMap<>(); | |
57 | + | |
58 | + // 첨부파일 유무 | |
59 | + if (multipartFileList != null && !multipartFileList.isEmpty()) { | |
60 | + FileMngVO fileMngVO = new FileMngVO(); | |
61 | + | |
62 | + // 파일매니저 등록 | |
63 | + HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); | |
64 | + result.put("multipartFileMngResult", fileMng); | |
65 | + | |
66 | + // 파일매니저 아이디 삽입 | |
67 | + popupVO.setFileMngId(fileMng.get("fileMngId").toString()); | |
68 | + } | |
69 | + | |
70 | + // 팝업 등록 | |
71 | + int insertResult = popupDAO.insertPopup(popupVO); | |
72 | + | |
73 | + result.put("insertResult", insertResult); | |
74 | + result.put("popupId", popupVO.getPopupId()); | |
75 | + | |
76 | + return result; | |
77 | + } | |
78 | + | |
79 | + /** | |
80 | + * @author : 박정하 | |
81 | + * @since : 2024.05.13 | |
82 | + * | |
83 | + * 팝업 목록 조회 | |
84 | + */ | |
85 | + @Override | |
86 | + public HashMap<String, Object> popupList(HashMap<String, String> params) throws Exception { | |
87 | + Pagination search = new Pagination(0, params); | |
88 | + int cnt = popupDAO.selectPopupListCnt(search); | |
89 | + | |
90 | + Pagination pagination = new Pagination(cnt, params); | |
91 | + List<PopupVO> list = popupDAO.selectPopupList(pagination); | |
92 | + | |
93 | + HashMap<String, Object> result = new HashMap<>(); | |
94 | + result.put("list", list); | |
95 | + result.put("pagination", pagination); | |
96 | + return result; | |
97 | + } | |
98 | + | |
99 | + /** | |
100 | + * @author : 박정하 | |
101 | + * @since : 2024.05.13 | |
102 | + * | |
103 | + * 팝업 상세 조회 | |
104 | + */ | |
105 | + @Override | |
106 | + public HashMap<String, Object> popupDetail(PopupVO popupVO) throws Exception { | |
107 | + PopupVO newPopupVO = new PopupVO(); | |
108 | + if (popupVO.getPopupId() != null) { | |
109 | + newPopupVO = popupDAO.selectPopupDetail(popupVO); | |
110 | + } | |
111 | + | |
112 | + // 팝업크기 설정 | |
113 | + if (newPopupVO.getWdthLen() != 0 && newPopupVO.getVrtcLen() != 0) { | |
114 | + if (newPopupVO.getWdthLen() == 300 && newPopupVO.getVrtcLen() == 300) { | |
115 | + newPopupVO.setPopupSizeType("fixed"); | |
116 | + newPopupVO.setPopupSize("PS1"); | |
117 | + } else if (newPopupVO.getWdthLen() == 500 && newPopupVO.getVrtcLen() == 700) { | |
118 | + newPopupVO.setPopupSizeType("fixed"); | |
119 | + newPopupVO.setPopupSize("PS2"); | |
120 | + } else if (newPopupVO.getWdthLen() == 700 && newPopupVO.getVrtcLen() == 1000) { | |
121 | + newPopupVO.setPopupSizeType("fixed"); | |
122 | + newPopupVO.setPopupSize("PS3"); | |
123 | + } else if (newPopupVO.getWdthLen() == 1200 && newPopupVO.getVrtcLen() == 850) { | |
124 | + newPopupVO.setPopupSizeType("fixed"); | |
125 | + newPopupVO.setPopupSize("PS4"); | |
126 | + } else { | |
127 | + newPopupVO.setPopupSizeType("custom"); | |
128 | + } | |
129 | + } else { | |
130 | + newPopupVO.setPopupSizeType("fixed"); | |
131 | + newPopupVO.setPopupSize("PS1"); | |
132 | + } | |
133 | + | |
134 | + // 업로드 형식 설정 | |
135 | + if (newPopupVO.getPopupType() == null) { | |
136 | + newPopupVO.setPopupType("image"); | |
137 | + } | |
138 | + | |
139 | + // 팝업 노출 페이지 | |
140 | + if (newPopupVO.getPageType() == null) { | |
141 | + newPopupVO.setPageType(""); | |
142 | + } | |
143 | + | |
144 | + // 팝업 사용 유무 | |
145 | + if (newPopupVO.getPopupUseYn() == null) { | |
146 | + newPopupVO.setPopupUseYn("Y"); | |
147 | + } | |
148 | + | |
149 | + // 사용 유무 | |
150 | + if (newPopupVO.getUseYn() == null) { | |
151 | + newPopupVO.setUseYn("Y"); | |
152 | + } | |
153 | + | |
154 | + List<CodeManageVO> codeList = codeManageService.findByChildCdCache("pageType"); // 검색 조건 | |
155 | + | |
156 | + HashMap<String, Object> result = new HashMap<>(); | |
157 | + result.put("popupVO", newPopupVO); | |
158 | + result.put("codeList", codeList); | |
159 | + | |
160 | + return result; | |
161 | + } | |
162 | + | |
163 | + /** | |
164 | + * @author : 박정하 | |
165 | + * @since : 2024.05.14 | |
166 | + * | |
167 | + * 팝업 수정 | |
168 | + */ | |
169 | + @Override | |
170 | + @Transactional(rollbackFor = Exception.class) | |
171 | + public int popupUpdate(PopupVO popupVO, List<MultipartFile> multipartFileList) throws Exception { | |
172 | + // 수정자 삽입 | |
173 | + String writer = jwtUtil.getWriter(); | |
174 | + popupVO.setMdfr(writer); | |
175 | + | |
176 | + // 파일 수정 | |
177 | + int fileUpdateResult = 0; | |
178 | + FileMngVO fileMngVO = new FileMngVO(); | |
179 | + if (popupVO.getFileMngId() != null) { | |
180 | + List<HashMap<String, Object>> deleteFileList = new ArrayList<>(); | |
181 | + if (popupVO.getDeleteFileList() != null && popupVO.getDeleteFileList().size() > 0) { | |
182 | + deleteFileList = popupVO.getDeleteFileList(); | |
183 | + } | |
184 | + | |
185 | + // 파일매니저 수정 | |
186 | + fileMngVO.setFileMngId(popupVO.getFileMngId()); | |
187 | + fileUpdateResult += fileMngService.fileMngUpadate(fileMngVO, deleteFileList, multipartFileList); | |
188 | + } else { | |
189 | + // 파일매니저 등록 | |
190 | + if(multipartFileList != null && multipartFileList.size() > 0) { | |
191 | + HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); | |
192 | + fileUpdateResult += (int) fileMng.get("fileMngResult"); | |
193 | + popupVO.setFileMngId(fileMng.get("fileMngId").toString()); | |
194 | + } | |
195 | + } | |
196 | + | |
197 | + // 팝업 수정 | |
198 | + int updateResult = popupDAO.updatePopup(popupVO); | |
199 | + | |
200 | + return updateResult + fileUpdateResult; | |
201 | + } | |
202 | + | |
203 | + /** | |
204 | + * @author : 박정하 | |
205 | + * @since : 2024.05.14 | |
206 | + * | |
207 | + * 팝업 삭제 | |
208 | + */ | |
209 | + @Override | |
210 | + @Transactional(rollbackFor = Exception.class) | |
211 | + public int popupDelete(PopupVO popupVO) throws Exception { | |
212 | + // 수정자 삽입 | |
213 | + String writer = jwtUtil.getWriter(); | |
214 | + popupVO.setMdfr(writer); | |
215 | + | |
216 | + // 파일매니저 삭제 | |
217 | + int fileDeleteResult = 0; | |
218 | + if (popupVO.getFileMngId() != null && popupVO.getFileMngId().equals("")) { | |
219 | + HashMap<String, Object> hashMap = new HashMap<>(); | |
220 | + hashMap.put("fileMngId", popupVO.getFileMngId()); | |
221 | + fileDeleteResult = fileMngService.fileMngDelete(hashMap); | |
222 | + } | |
223 | + | |
224 | + // 팝업 삭제 | |
225 | + popupVO.setUseYn("N"); | |
226 | + popupVO.setFileMngId(null); | |
227 | + int deleteResult = popupDAO.updatePopup(popupVO); | |
228 | + | |
229 | + return deleteResult + fileDeleteResult; | |
230 | + } | |
231 | + | |
232 | + /** | |
233 | + * @author : 박정하 | |
234 | + * @since : 2024.05.22 | |
235 | + * | |
236 | + * 팝업 목록 조회 (팝업창 띄우는 용도) | |
237 | + */ | |
238 | + @Override | |
239 | + public List<PopupVO> popupListByPage(String pageType) throws Exception { | |
240 | + return popupDAO.selectPopupListByPage(pageType); | |
241 | + } | |
242 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/popup/service/PopupService.java
... | ... | @@ -0,0 +1,62 @@ |
1 | +package com.takensoft.cms.popup.service; | |
2 | + | |
3 | +import com.takensoft.cms.popup.vo.PopupVO; | |
4 | +import org.springframework.web.multipart.MultipartFile; | |
5 | + | |
6 | +import java.util.*; | |
7 | + | |
8 | +/** | |
9 | + * @author : 박정하 | |
10 | + * @since : 2024.05.13 | |
11 | + * | |
12 | + * 팝업 관련 인터페이스 | |
13 | + */ | |
14 | +public interface PopupService { | |
15 | + /** | |
16 | + * @author : 박정하 | |
17 | + * @since : 2024.05.13 | |
18 | + * | |
19 | + * 팝업 등록 | |
20 | + */ | |
21 | + public HashMap<String, Object> popupInsert(PopupVO popupVO, List<MultipartFile> multipartFileList) throws Exception; | |
22 | + | |
23 | + /** | |
24 | + * @author : 박정하 | |
25 | + * @since : 2024.05.13 | |
26 | + * | |
27 | + * 팝업 목록 조회 | |
28 | + */ | |
29 | + public HashMap<String, Object> popupList(HashMap<String, String> params) throws Exception; | |
30 | + | |
31 | + /** | |
32 | + * @author : 박정하 | |
33 | + * @since : 2024.05.13 | |
34 | + * | |
35 | + * 팝업 상세 조회 | |
36 | + */ | |
37 | + public HashMap<String, Object> popupDetail(PopupVO popupVO) throws Exception; | |
38 | + | |
39 | + /** | |
40 | + * @author : 박정하 | |
41 | + * @since : 2024.05.14 | |
42 | + * | |
43 | + * 팝업 수정 | |
44 | + */ | |
45 | + public int popupUpdate(PopupVO popupVO, List<MultipartFile> multipartFileList) throws Exception; | |
46 | + | |
47 | + /** | |
48 | + * @author : 박정하 | |
49 | + * @since : 2024.05.14 | |
50 | + * | |
51 | + * 팝업 삭제 | |
52 | + */ | |
53 | + public int popupDelete(PopupVO popupVO) throws Exception; | |
54 | + | |
55 | + /** | |
56 | + * @author : 박정하 | |
57 | + * @since : 2024.05.13 | |
58 | + * | |
59 | + * 팝업 목록 조회 (팝업창 띄우는 용도) | |
60 | + */ | |
61 | + public List<PopupVO> popupListByPage(String pageType) throws Exception; | |
62 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/popup/vo/PopupVO.java
... | ... | @@ -0,0 +1,61 @@ |
1 | +package com.takensoft.cms.popup.vo; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +import java.util.HashMap; | |
6 | +import java.util.List; | |
7 | + | |
8 | +/** | |
9 | + * @author : 박정하 | |
10 | + * @since : 2024.05.13 | |
11 | + * | |
12 | + * 팝업 관련 VO | |
13 | + */ | |
14 | +@Data | |
15 | +public class PopupVO { | |
16 | + // 팝업아이디 | |
17 | + private String popupId; | |
18 | + // 팝업제목 | |
19 | + private String popupTtl; | |
20 | + // 시작일 | |
21 | + private String bgngDt; | |
22 | + // 종료일 | |
23 | + private String endDt; | |
24 | + // 가로길이 | |
25 | + private int wdthLen; | |
26 | + // 세로길이 | |
27 | + private int vrtcLen; | |
28 | + // 팝업유형 | |
29 | + private String popupType; | |
30 | + // 팝업사용여부 | |
31 | + private String popupUseYn; | |
32 | + // 동영상URL | |
33 | + private String vdoUrl; | |
34 | + // 링크 URL | |
35 | + private String linkUrl; | |
36 | + // 파일 관리 아이디 | |
37 | + private String fileMngId; | |
38 | + // 순서 | |
39 | + private int sn; | |
40 | + // 페이지 타입(팝업노출페이지) | |
41 | + private String pageType; | |
42 | + // 사용여부 | |
43 | + private String useYn; | |
44 | + // 등록자 | |
45 | + private String rgtr; | |
46 | + // 등록일 | |
47 | + private String regDt; | |
48 | + // 수정자 | |
49 | + private String mdfr; | |
50 | + // 수정일 | |
51 | + private String mdfcnDt; | |
52 | + | |
53 | + // 팝업사이즈타입 | |
54 | + private String popupSizeType; | |
55 | + // 팝업사이즈 | |
56 | + private String popupSize; | |
57 | + // 등록자명 | |
58 | + private String mbrNm; | |
59 | + // 삭제 파일 목록 | |
60 | + private List<HashMap<String, Object>> deleteFileList; | |
61 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/popup/web/PopupController.java
... | ... | @@ -0,0 +1,192 @@ |
1 | +package com.takensoft.cms.popup.web; | |
2 | + | |
3 | +import com.takensoft.cms.popup.service.PopupService; | |
4 | +import com.takensoft.cms.popup.vo.PopupVO; | |
5 | +import com.takensoft.common.file.service.FileService; | |
6 | +import com.takensoft.common.util.ResponseData; | |
7 | +import lombok.RequiredArgsConstructor; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.HttpStatus; | |
10 | +import org.springframework.http.MediaType; | |
11 | +import org.springframework.http.ResponseEntity; | |
12 | +import org.springframework.web.bind.annotation.*; | |
13 | +import org.springframework.web.multipart.MultipartFile; | |
14 | + | |
15 | +import java.nio.charset.Charset; | |
16 | +import java.util.*; | |
17 | + | |
18 | +/** | |
19 | + * @author : 박정하 | |
20 | + * @since : 2024.05.13 | |
21 | + * | |
22 | + * 팝업 관련 컨트롤러 | |
23 | + */ | |
24 | +@RestController | |
25 | +@RequiredArgsConstructor | |
26 | +@RequestMapping(value = "/admin/popup") | |
27 | +public class PopupController { | |
28 | + private final PopupService popupService; | |
29 | + private final FileService fileService; | |
30 | + | |
31 | + /** | |
32 | + * @author 박정하 | |
33 | + * @since 2024.05.13 | |
34 | + * @param popupVO | |
35 | + * @return | |
36 | + * @throws Exception | |
37 | + * | |
38 | + * 팝업 등록 | |
39 | + */ | |
40 | + @PostMapping("/insertProc.file") | |
41 | + public ResponseEntity<?> insertProc(@RequestPart PopupVO popupVO, List<MultipartFile> multipartFileList) throws Exception { | |
42 | + HashMap<String, Object> result = popupService.popupInsert(popupVO, multipartFileList); | |
43 | + int insertResult = (int) result.get("insertResult"); | |
44 | + | |
45 | + // 응답 처리 | |
46 | + HttpHeaders headers = new HttpHeaders(); | |
47 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
48 | + ResponseData responseData = new ResponseData(); | |
49 | + if(insertResult > 0) { | |
50 | + responseData.setStatus(HttpStatus.OK); | |
51 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
52 | + responseData.setData(result); | |
53 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
54 | + } else { | |
55 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
56 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
57 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
58 | + } | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * @author 박정하 | |
63 | + * @since 2024.05.13 | |
64 | + * @param params | |
65 | + * @return | |
66 | + * @throws Exception | |
67 | + * | |
68 | + * 팝업 목록 조회 | |
69 | + */ | |
70 | + @PostMapping("/listProc.json") | |
71 | + public ResponseEntity<?> listProc(@RequestBody HashMap<String, String> params) throws Exception { | |
72 | + HashMap<String, Object> result = popupService.popupList(params); | |
73 | + | |
74 | + // 응답 처리 | |
75 | + HttpHeaders headers = new HttpHeaders(); | |
76 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
77 | + ResponseData responseData = new ResponseData(); | |
78 | + responseData.setStatus(HttpStatus.OK); | |
79 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
80 | + responseData.setData(result); | |
81 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
82 | + } | |
83 | + | |
84 | + /** | |
85 | + * @author 박정하 | |
86 | + * @since 2024.05.13 | |
87 | + * @param popupVO | |
88 | + * @return | |
89 | + * @throws Exception | |
90 | + * | |
91 | + * 팝업 상세 조회 | |
92 | + */ | |
93 | + @PostMapping("/detailProc.json") | |
94 | + public ResponseEntity<?> detailProc(@RequestBody PopupVO popupVO) throws Exception { | |
95 | + HashMap<String, Object> result = popupService.popupDetail(popupVO); | |
96 | + PopupVO popup = (PopupVO) result.get("popupVO"); | |
97 | + | |
98 | + List<HashMap<String, Object>> fileList = new ArrayList<>(); | |
99 | + if (popup.getFileMngId() != null) { | |
100 | + fileList = fileService.fileSelectList(popup.getFileMngId()); | |
101 | + } | |
102 | + result.put("fileList", fileList); | |
103 | + | |
104 | + // 응답 처리 | |
105 | + HttpHeaders headers = new HttpHeaders(); | |
106 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
107 | + ResponseData responseData = new ResponseData(); | |
108 | + responseData.setStatus(HttpStatus.OK); | |
109 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
110 | + responseData.setData(result); | |
111 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
112 | + } | |
113 | + | |
114 | + /** | |
115 | + * @author 박정하 | |
116 | + * @since 2024.05.14 | |
117 | + * @param popupVO | |
118 | + * @return | |
119 | + * @throws Exception | |
120 | + * | |
121 | + * 팝업 수정 | |
122 | + */ | |
123 | + @PostMapping("/updateProc.file") | |
124 | + public ResponseEntity<?> updateProc(@RequestPart PopupVO popupVO, @RequestParam(required = false) List<MultipartFile> multipartFileList) throws Exception { | |
125 | + int result = popupService.popupUpdate(popupVO, multipartFileList); | |
126 | + | |
127 | + // 응답 처리 | |
128 | + HttpHeaders headers = new HttpHeaders(); | |
129 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
130 | + ResponseData responseData = new ResponseData(); | |
131 | + if(result > 0) { | |
132 | + responseData.setStatus(HttpStatus.OK); | |
133 | + responseData.setMessage("정상적으로 수정 처리되었습니다."); | |
134 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
135 | + } else { | |
136 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
137 | + responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); | |
138 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
139 | + } | |
140 | + } | |
141 | + | |
142 | + /** | |
143 | + * @author 박정하 | |
144 | + * @since 2024.05.14 | |
145 | + * @param popupVO | |
146 | + * @return | |
147 | + * @throws Exception | |
148 | + * | |
149 | + * 팝업 삭제 | |
150 | + */ | |
151 | + @PostMapping("/deleteProc.json") | |
152 | + public ResponseEntity<?> deleteProc(@RequestBody PopupVO popupVO) throws Exception { | |
153 | + int result = popupService.popupDelete(popupVO); | |
154 | + | |
155 | + // 응답 처리 | |
156 | + HttpHeaders headers = new HttpHeaders(); | |
157 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
158 | + ResponseData responseData = new ResponseData(); | |
159 | + if(result > 0) { | |
160 | + responseData.setStatus(HttpStatus.OK); | |
161 | + responseData.setMessage("정상적으로 삭제 처리되었습니다."); | |
162 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
163 | + } else { | |
164 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
165 | + responseData.setMessage("삭제에 실패하였습니다.\n담당자에게 문의하세요."); | |
166 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
167 | + } | |
168 | + } | |
169 | + | |
170 | + /** | |
171 | + * @author 박정하 | |
172 | + * @since 2024.05.22 | |
173 | + * @param popupVO | |
174 | + * @return | |
175 | + * @throws Exception | |
176 | + * | |
177 | + * 팝업 목록 조회 (팝업창 띄우는 용도) | |
178 | + */ | |
179 | + @PostMapping("/listByPageProc.json") | |
180 | + public ResponseEntity<?> listByPageProc(@RequestBody PopupVO popupVO) throws Exception { | |
181 | + List<PopupVO> result = popupService.popupListByPage(popupVO.getPageType()); | |
182 | + | |
183 | + // 응답 처리 | |
184 | + HttpHeaders headers = new HttpHeaders(); | |
185 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
186 | + ResponseData responseData = new ResponseData(); | |
187 | + responseData.setStatus(HttpStatus.OK); | |
188 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
189 | + responseData.setData(result); | |
190 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
191 | + } | |
192 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/popup/web/SysPopupController.java
... | ... | @@ -0,0 +1,87 @@ |
1 | +package com.takensoft.cms.popup.web; | |
2 | + | |
3 | +import com.takensoft.cms.popup.service.PopupService; | |
4 | +import com.takensoft.cms.popup.vo.PopupVO; | |
5 | +import com.takensoft.common.file.service.FileService; | |
6 | +import com.takensoft.common.util.ResponseData; | |
7 | +import lombok.RequiredArgsConstructor; | |
8 | +import org.springframework.http.HttpHeaders; | |
9 | +import org.springframework.http.HttpStatus; | |
10 | +import org.springframework.http.MediaType; | |
11 | +import org.springframework.http.ResponseEntity; | |
12 | +import org.springframework.web.bind.annotation.PostMapping; | |
13 | +import org.springframework.web.bind.annotation.RequestBody; | |
14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
15 | +import org.springframework.web.bind.annotation.RestController; | |
16 | + | |
17 | +import java.nio.charset.Charset; | |
18 | +import java.util.ArrayList; | |
19 | +import java.util.HashMap; | |
20 | +import java.util.List; | |
21 | + | |
22 | +/** | |
23 | + * @author : 박정하 | |
24 | + * @since : 2024.05.27 | |
25 | + * | |
26 | + * 팝업 관련 컨트롤러 | |
27 | + */ | |
28 | +@RestController | |
29 | +@RequiredArgsConstructor | |
30 | +@RequestMapping(value = "/sys/popup") | |
31 | +public class SysPopupController { | |
32 | + private final PopupService popupService; | |
33 | + private final FileService fileService; | |
34 | + | |
35 | + /** | |
36 | + * @author 박정하 | |
37 | + * @since 2024.05.22 | |
38 | + * @param popupVO | |
39 | + * @return | |
40 | + * @throws Exception | |
41 | + * | |
42 | + * 팝업 목록 조회 (팝업창 띄우는 용도) | |
43 | + */ | |
44 | + @PostMapping("/listByPageProc.json") | |
45 | + public ResponseEntity<?> listByPageProc(@RequestBody PopupVO popupVO) throws Exception { | |
46 | + List<PopupVO> result = popupService.popupListByPage(popupVO.getPageType()); | |
47 | + | |
48 | + // 응답 처리 | |
49 | + HttpHeaders headers = new HttpHeaders(); | |
50 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
51 | + ResponseData responseData = new ResponseData(); | |
52 | + responseData.setStatus(HttpStatus.OK); | |
53 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
54 | + responseData.setData(result); | |
55 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
56 | + } | |
57 | + | |
58 | + /** | |
59 | + * @author 박정하 | |
60 | + * @since 2024.05.13 | |
61 | + * @param popupVO | |
62 | + * @return | |
63 | + * @throws Exception | |
64 | + * | |
65 | + * 팝업 상세 조회 | |
66 | + */ | |
67 | + @PostMapping("/detailProc.json") | |
68 | + public ResponseEntity<?> detailProc(@RequestBody PopupVO popupVO) throws Exception { | |
69 | + HashMap<String, Object> result = popupService.popupDetail(popupVO); | |
70 | + PopupVO popup = (PopupVO) result.get("popupVO"); | |
71 | + | |
72 | + List<HashMap<String, Object>> fileList = new ArrayList<>(); | |
73 | + if (popup.getFileMngId() != null) { | |
74 | + fileList = fileService.fileSelectList(popup.getFileMngId()); | |
75 | + } | |
76 | + result.put("fileList", fileList); | |
77 | + | |
78 | + // 응답 처리 | |
79 | + HttpHeaders headers = new HttpHeaders(); | |
80 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
81 | + ResponseData responseData = new ResponseData(); | |
82 | + responseData.setStatus(HttpStatus.OK); | |
83 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
84 | + responseData.setData(result); | |
85 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
86 | + } | |
87 | +} |
+++ src/main/java/com/takensoft/cms/prvcInqHstry/dao/PrvcInqHstryDAO.java
... | ... | @@ -0,0 +1,49 @@ |
1 | +package com.takensoft.cms.prvcInqHstry.dao; | |
2 | + | |
3 | +import com.takensoft.cms.popup.vo.PopupVO; | |
4 | +import com.takensoft.cms.prvcInqHstry.vo.PrvcInqHstryVO; | |
5 | +import com.takensoft.common.Pagination; | |
6 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @author : 박정하 | |
12 | + * @since : 2024.05.22 | |
13 | + * | |
14 | + * 개인정보 조회 이력 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("prvcInqHstryDAO") | |
17 | +public interface PrvcInqHstryDAO { | |
18 | + /** | |
19 | + * @author : 박정하 | |
20 | + * @since : 2024.05.22 | |
21 | + * | |
22 | + * 개인정보 조회 이력 등록 | |
23 | + */ | |
24 | + public int insertPrvcInqHstry(PrvcInqHstryVO prvcInqHstryVO) throws Exception; | |
25 | + | |
26 | + /** | |
27 | + * @author : 박정하 | |
28 | + * @since : 2024.05.27 | |
29 | + * | |
30 | + * 개인정보 조회 이력 목록 갯수 | |
31 | + */ | |
32 | + public int selectPrvcInqHstryListCnt(Pagination pagination) throws Exception; | |
33 | + | |
34 | + /** | |
35 | + * @author : 박정하 | |
36 | + * @since : 2024.05.27 | |
37 | + * | |
38 | + * 개인정보 조회 이력 목록 조회 | |
39 | + */ | |
40 | + public List<PrvcInqHstryVO> selectPrvcInqHstryList(Pagination pagination) throws Exception; | |
41 | + | |
42 | + /** | |
43 | + * @author : 박정하 | |
44 | + * @since : 2024.05.27 | |
45 | + * | |
46 | + * 개인정보 조회 이력 상세 조회 | |
47 | + */ | |
48 | + public PrvcInqHstryVO selectPrvcInqHstryDetail(int inqHstryId) throws Exception; | |
49 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/prvcInqHstry/service/Impl/PrvcInqHstryServiceImpl.java
... | ... | @@ -0,0 +1,86 @@ |
1 | +package com.takensoft.cms.prvcInqHstry.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.codeManage.service.CodeManageService; | |
4 | +import com.takensoft.cms.codeManage.vo.CodeManageVO; | |
5 | +import com.takensoft.cms.popup.vo.PopupVO; | |
6 | +import com.takensoft.cms.prvcInqHstry.dao.PrvcInqHstryDAO; | |
7 | +import com.takensoft.cms.prvcInqHstry.service.PrvcInqHstryService; | |
8 | +import com.takensoft.cms.prvcInqHstry.vo.PrvcInqHstryVO; | |
9 | +import com.takensoft.common.Pagination; | |
10 | +import com.takensoft.common.util.CommonUtils; | |
11 | +import com.takensoft.common.util.JWTUtil; | |
12 | +import lombok.RequiredArgsConstructor; | |
13 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
14 | +import org.springframework.stereotype.Service; | |
15 | + | |
16 | +import javax.servlet.http.HttpServletRequest; | |
17 | +import java.util.HashMap; | |
18 | +import java.util.List; | |
19 | + | |
20 | +/** | |
21 | + * @author : 박정하 | |
22 | + * @since : 2024.05.22 | |
23 | + * | |
24 | + * 개인정보 조회 이력 관련 구현체 | |
25 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
26 | + * PrvcInqHstryService : 팝업 관련 인터페이스 상속 | |
27 | + */ | |
28 | +@Service("prvcInqHstryService") | |
29 | +@RequiredArgsConstructor | |
30 | +public class PrvcInqHstryServiceImpl extends EgovAbstractServiceImpl implements PrvcInqHstryService { | |
31 | + private final JWTUtil jwtUtil; | |
32 | + private final CommonUtils commonUtils; | |
33 | + private final PrvcInqHstryDAO prvcInqHstryDAO; | |
34 | + private final CodeManageService codeManageService; | |
35 | + | |
36 | + /** | |
37 | + * @author : 박정하 | |
38 | + * @since : 2024.05.22 | |
39 | + * | |
40 | + * 개인정보 조회 이력 등록 | |
41 | + */ | |
42 | + public int prvcInqHstryInsert(HttpServletRequest request, PrvcInqHstryVO prvcInqHstryVO) throws Exception { | |
43 | + // 조회 아이피 삽입 | |
44 | + String ipAdd = commonUtils.getIp(request); | |
45 | + prvcInqHstryVO.setInqIp(ipAdd); | |
46 | + | |
47 | + // 조회자 삽입 | |
48 | + String writer = jwtUtil.getWriter(); | |
49 | + prvcInqHstryVO.setRdr(writer); | |
50 | + | |
51 | + return prvcInqHstryDAO.insertPrvcInqHstry(prvcInqHstryVO); | |
52 | + } | |
53 | + | |
54 | + /** | |
55 | + * @author : 박정하 | |
56 | + * @since : 2024.05.27 | |
57 | + * | |
58 | + * 개인정보 조회 이력 목록 조회 | |
59 | + */ | |
60 | + @Override | |
61 | + public HashMap<String, Object> prvcInqHstryList(HashMap<String, String> params) throws Exception { | |
62 | + Pagination search = new Pagination(0, params); | |
63 | + int cnt = prvcInqHstryDAO.selectPrvcInqHstryListCnt(search); | |
64 | + | |
65 | + Pagination pagination = new Pagination(cnt, params); | |
66 | + List<PrvcInqHstryVO> list = prvcInqHstryDAO.selectPrvcInqHstryList(pagination); | |
67 | + List<CodeManageVO> codeList = codeManageService.findByChildCdCache("prvcInqHstry"); // 검색 조건 | |
68 | + | |
69 | + HashMap<String, Object> result = new HashMap<>(); | |
70 | + result.put("list", list); | |
71 | + result.put("pagination", pagination); | |
72 | + result.put("codeList", codeList); | |
73 | + return result; | |
74 | + } | |
75 | + | |
76 | + /** | |
77 | + * @author : 박정하 | |
78 | + * @since : 2024.05.27 | |
79 | + * | |
80 | + * 개인정보 조회 이력 상세 조회 | |
81 | + */ | |
82 | + @Override | |
83 | + public PrvcInqHstryVO prvcInqHstryDetail(int inqHstryId) throws Exception { | |
84 | + return prvcInqHstryDAO.selectPrvcInqHstryDetail(inqHstryId); | |
85 | + } | |
86 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/prvcInqHstry/service/PrvcInqHstryService.java
... | ... | @@ -0,0 +1,38 @@ |
1 | +package com.takensoft.cms.prvcInqHstry.service; | |
2 | + | |
3 | +import com.takensoft.cms.prvcInqHstry.vo.PrvcInqHstryVO; | |
4 | + | |
5 | +import javax.servlet.http.HttpServletRequest; | |
6 | +import java.util.HashMap; | |
7 | + | |
8 | +/** | |
9 | + * @author : 박정하 | |
10 | + * @since : 2024.05.22 | |
11 | + * | |
12 | + * 개인정보 조회 이력 관련 인터페이스 | |
13 | + */ | |
14 | +public interface PrvcInqHstryService { | |
15 | + /** | |
16 | + * @author : 박정하 | |
17 | + * @since : 2024.05.22 | |
18 | + * | |
19 | + * 개인정보 조회 이력 등록 | |
20 | + */ | |
21 | + public int prvcInqHstryInsert(HttpServletRequest request, PrvcInqHstryVO prvcInqHstryVO) throws Exception; | |
22 | + | |
23 | + /** | |
24 | + * @author : 박정하 | |
25 | + * @since : 2024.05.27 | |
26 | + * | |
27 | + * 개인정보 조회 이력 목록 조회 | |
28 | + */ | |
29 | + public HashMap<String, Object> prvcInqHstryList(HashMap<String, String> params) throws Exception; | |
30 | + | |
31 | + /** | |
32 | + * @author : 박정하 | |
33 | + * @since : 2024.05.27 | |
34 | + * | |
35 | + * 개인정보 조회 이력 상세 조회 | |
36 | + */ | |
37 | + public PrvcInqHstryVO prvcInqHstryDetail(int inqHstryId) throws Exception; | |
38 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/prvcInqHstry/vo/PrvcInqHstryVO.java
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.takensoft.cms.prvcInqHstry.vo; | |
2 | + | |
3 | +import lombok.Data; | |
4 | + | |
5 | +/** | |
6 | + * @author : 박정하 | |
7 | + * @since : 2024.05.22 | |
8 | + * | |
9 | + * 개인정보 조회 이력 관련 VO | |
10 | + */ | |
11 | +@Data | |
12 | +public class PrvcInqHstryVO { | |
13 | + // 조회 이력 아이디 | |
14 | + private int inqHstryId; | |
15 | + // 조회 대상자 아이디 | |
16 | + private String inqTrprId; | |
17 | + // 조회 사유 | |
18 | + private String inqRsn; | |
19 | + // 조회 아이피 | |
20 | + private String inqIp; | |
21 | + // 조회자 | |
22 | + private String rdr; | |
23 | + // 조회일 | |
24 | + private String inqDt; | |
25 | + // 조회자 이름 | |
26 | + private String mbrNm; | |
27 | + // 조회 대상자 로그인 아이디 | |
28 | + private String lgnId; | |
29 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/prvcInqHstry/web/PrvcInqHstryController.java
... | ... | @@ -0,0 +1,102 @@ |
1 | +package com.takensoft.cms.prvcInqHstry.web; | |
2 | + | |
3 | +import com.takensoft.cms.prvcInqHstry.service.PrvcInqHstryService; | |
4 | +import com.takensoft.cms.prvcInqHstry.vo.PrvcInqHstryVO; | |
5 | +import com.takensoft.common.util.ResponseData; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import org.springframework.http.HttpHeaders; | |
8 | +import org.springframework.http.HttpStatus; | |
9 | +import org.springframework.http.MediaType; | |
10 | +import org.springframework.http.ResponseEntity; | |
11 | +import org.springframework.web.bind.annotation.*; | |
12 | + | |
13 | +import javax.servlet.http.HttpServletRequest; | |
14 | +import java.nio.charset.Charset; | |
15 | +import java.util.*; | |
16 | + | |
17 | +/** | |
18 | + * @author : 박정하 | |
19 | + * @since : 2024.05.22 | |
20 | + * | |
21 | + * 개인정보 조회 이력 관련 컨트롤러 | |
22 | + */ | |
23 | +@RestController | |
24 | +@RequiredArgsConstructor | |
25 | +@RequestMapping(value = "/admin/prvcInqHstry") | |
26 | +public class PrvcInqHstryController { | |
27 | + private final PrvcInqHstryService prvcInqHstryService; | |
28 | + | |
29 | + /** | |
30 | + * @author 박정하 | |
31 | + * @since 2024.05.22 | |
32 | + * @param prvcInqHstryVO | |
33 | + * @return | |
34 | + * @throws Exception | |
35 | + * | |
36 | + * 개인정보 조회 이력 등록 | |
37 | + */ | |
38 | + @PostMapping("/insertProc.json") | |
39 | + public ResponseEntity<?> insertProc(HttpServletRequest request, @RequestBody PrvcInqHstryVO prvcInqHstryVO) throws Exception { | |
40 | + int result = prvcInqHstryService.prvcInqHstryInsert(request, prvcInqHstryVO); | |
41 | + | |
42 | + // 응답 처리 | |
43 | + HttpHeaders headers = new HttpHeaders(); | |
44 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
45 | + ResponseData responseData = new ResponseData(); | |
46 | + if(result > 0) { | |
47 | + responseData.setStatus(HttpStatus.OK); | |
48 | + responseData.setMessage("정상적으로 등록 처리되었습니다."); | |
49 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
50 | + } else { | |
51 | + responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); | |
52 | + responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); | |
53 | + return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); | |
54 | + } | |
55 | + } | |
56 | + | |
57 | + /** | |
58 | + * @author 박정하 | |
59 | + * @since 2024.05.27 | |
60 | + * @param params | |
61 | + * @return | |
62 | + * @throws Exception | |
63 | + * | |
64 | + * 개인정보 조회 이력 목록 조회 | |
65 | + */ | |
66 | + @PostMapping("/listProc.json") | |
67 | + public ResponseEntity<?> listProc(@RequestBody HashMap<String, String> params) throws Exception { | |
68 | + HashMap<String, Object> result = prvcInqHstryService.prvcInqHstryList(params); | |
69 | + | |
70 | + // 응답 처리 | |
71 | + HttpHeaders headers = new HttpHeaders(); | |
72 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
73 | + ResponseData responseData = new ResponseData(); | |
74 | + responseData.setStatus(HttpStatus.OK); | |
75 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
76 | + responseData.setData(result); | |
77 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
78 | + } | |
79 | + | |
80 | + /** | |
81 | + * @author 박정하 | |
82 | + * @since 2024.05.27 | |
83 | + * @param prvcInqHstryVO | |
84 | + * @return | |
85 | + * @throws Exception | |
86 | + * | |
87 | + * 개인정보 조회 이력 상세 조회 | |
88 | + */ | |
89 | + @PostMapping("/detailProc.json") | |
90 | + public ResponseEntity<?> listProc(@RequestBody PrvcInqHstryVO prvcInqHstryVO) throws Exception { | |
91 | + PrvcInqHstryVO result = prvcInqHstryService.prvcInqHstryDetail(prvcInqHstryVO.getInqHstryId()); | |
92 | + | |
93 | + // 응답 처리 | |
94 | + HttpHeaders headers = new HttpHeaders(); | |
95 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
96 | + ResponseData responseData = new ResponseData(); | |
97 | + responseData.setStatus(HttpStatus.OK); | |
98 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
99 | + responseData.setData(result); | |
100 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
101 | + } | |
102 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/search/dao/SearchDAO.java
... | ... | @@ -0,0 +1,92 @@ |
1 | +package com.takensoft.cms.search.dao; | |
2 | + | |
3 | +import com.takensoft.cms.search.vo.SearchContentVO; | |
4 | +import com.takensoft.cms.search.vo.SearchVO; | |
5 | +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; | |
6 | + | |
7 | +import java.util.HashMap; | |
8 | +import java.util.List; | |
9 | + | |
10 | +/** | |
11 | + * @author : 하석형 | |
12 | + * @since : 2024.06.12 | |
13 | + * | |
14 | + * 통합 검색 관련 Mapper | |
15 | + */ | |
16 | +@Mapper("searchDAO") | |
17 | +public interface SearchDAO { | |
18 | + /** | |
19 | + * @author 하석형 | |
20 | + * @since 2024.06.12 | |
21 | + * 게시판 검색 목록 조회 개수 | |
22 | + */ | |
23 | + public int findAllCountByBbs(SearchVO searchVO) throws Exception; | |
24 | + | |
25 | + /** | |
26 | + * @author 하석형 | |
27 | + * @since 2024.06.12 | |
28 | + * 게시판 검색 목록 조회 | |
29 | + */ | |
30 | + public List<SearchContentVO> findAllByBbs(SearchVO searchVO) throws Exception; | |
31 | + | |
32 | + | |
33 | + | |
34 | + | |
35 | + /** ********************************* 컨텐츠 검색 - 기업 정보 (시작) ********************************* */ | |
36 | + /** | |
37 | + * @author 하석형 | |
38 | + * @since 2024.06.14 | |
39 | + * 기업 정보 검색 목록 조회 개수 | |
40 | + */ | |
41 | + public int findAllCountByEntInfo(SearchVO searchVO) throws Exception; | |
42 | + | |
43 | + /** | |
44 | + * @author 하석형 | |
45 | + * @since 2024.06.14 | |
46 | + * 기업 정보 검색 목록 조회 | |
47 | + */ | |
48 | + public List<HashMap<String, Object>> findAllByEntInfo(SearchVO searchVO) throws Exception; | |
49 | + | |
50 | + /** | |
51 | + * @author 하석형 | |
52 | + * @since 2024.06.14 | |
53 | + * 기업 상담 신청 검색 목록 조회 개수 | |
54 | + */ | |
55 | + public int findAllCountByEntDscsnAply(SearchVO searchVO) throws Exception; | |
56 | + | |
57 | + /** | |
58 | + * @author 하석형 | |
59 | + * @since 2024.06.14 | |
60 | + * 기업 상담 신청 검색 목록 조회 | |
61 | + */ | |
62 | + public List<HashMap<String, Object>> findAllByEntDscsnAply(SearchVO searchVO) throws Exception; | |
63 | + | |
64 | + /** | |
65 | + * @author 하석형 | |
66 | + * @since 2024.06.14 | |
67 | + * 투자 상담 검색 목록 조회 개수 | |
68 | + */ | |
69 | + public int findAllCountByIvstDscsn(SearchVO searchVO) throws Exception; | |
70 | + | |
71 | + /** | |
72 | + * @author 하석형 | |
73 | + * @since 2024.06.14 | |
74 | + * 투자 상담 검색 목록 조회 | |
75 | + */ | |
76 | + public List<HashMap<String, Object>> findAllByIvstDscsn(SearchVO searchVO) throws Exception; | |
77 | + | |
78 | + /** | |
79 | + * @author 하석형 | |
80 | + * @since 2024.06.14 | |
81 | + * 검토 사항 검색 목록 조회 개수 | |
82 | + */ | |
83 | + public int findAllCountByRvwMttr(SearchVO searchVO) throws Exception; | |
84 | + | |
85 | + /** | |
86 | + * @author 하석형 | |
87 | + * @since 2024.06.14 | |
88 | + * 검토 사항 검색 목록 조회 | |
89 | + */ | |
90 | + public List<HashMap<String, Object>> findAllByRvwMttr(SearchVO searchVO) throws Exception; | |
91 | + /** ********************************* 컨텐츠 검색 - 기업 정보 (종료) ********************************* */ | |
92 | +} |
+++ src/main/java/com/takensoft/cms/search/service/Impl/SearchServiceImpl.java
... | ... | @@ -0,0 +1,316 @@ |
1 | +package com.takensoft.cms.search.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.menu.service.MenuService; | |
4 | +import com.takensoft.cms.menu.vo.MenuRequest; | |
5 | +import com.takensoft.cms.menu.vo.SysMenuVO; | |
6 | +import com.takensoft.cms.search.dao.SearchDAO; | |
7 | +import com.takensoft.cms.search.service.SearchService; | |
8 | +import com.takensoft.cms.search.vo.SearchContentVO; | |
9 | +import com.takensoft.cms.search.vo.SearchMenuVO; | |
10 | +import com.takensoft.cms.search.vo.SearchResultVO; | |
11 | +import com.takensoft.cms.search.vo.SearchVO; | |
12 | +import lombok.RequiredArgsConstructor; | |
13 | +import org.apache.commons.lang3.StringEscapeUtils; | |
14 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
15 | +import org.springframework.stereotype.Service; | |
16 | + | |
17 | +import java.util.*; | |
18 | + | |
19 | +/** | |
20 | + * @author : 하석형 | |
21 | + * @since : 2024.06.12 | |
22 | + * | |
23 | + * 통합 검색 관련 구현체 | |
24 | + * EgovAbstractServiceImpl : 전자정부 상속 | |
25 | + * SearchService : 통합 검색 인터페이스 상속 | |
26 | + */ | |
27 | +@Service("searchService") | |
28 | +@RequiredArgsConstructor | |
29 | +public class SearchServiceImpl extends EgovAbstractServiceImpl implements SearchService { | |
30 | + | |
31 | + private final MenuService menuService; | |
32 | + private final SearchDAO searchDAO; | |
33 | + | |
34 | + /** | |
35 | + * @author 하석형 | |
36 | + * @since 2024.06.12 | |
37 | + * 통합 검색 | |
38 | + */ | |
39 | + public SearchResultVO searchAll (SearchVO searchVO) throws Exception { | |
40 | + SearchResultVO searchResultVO = new SearchResultVO(); | |
41 | + | |
42 | + /* 메뉴 목록 */ | |
43 | + MenuRequest mReq = new MenuRequest(); | |
44 | + mReq.setMenuType(searchVO.getMenuType()); // 메뉴타입: "government" | |
45 | + mReq.setRoles(searchVO.getRoles()); // 로그인 사용자 권한: "ROLE_ADMIN" / "ROLE_USER" | |
46 | + SysMenuVO topMenu = new SysMenuVO(); | |
47 | + List<SysMenuVO> menuList = menuService.findByMenuWithRouter(mReq); | |
48 | + topMenu.setChildList(menuList); | |
49 | + | |
50 | + //TODO: 메뉴명 검색 | |
51 | + | |
52 | + /* 검색 */ | |
53 | + this.searchMenu(topMenu, searchVO, searchResultVO); | |
54 | + | |
55 | + return searchResultVO; | |
56 | + } | |
57 | + | |
58 | + /** | |
59 | + * @author 하석형 | |
60 | + * @since 2024.06.12 | |
61 | + * 검색 함수 | |
62 | + */ | |
63 | + public void searchMenu (SysMenuVO sysMenu, SearchVO searchVO, SearchResultVO searchResultVO) throws Exception { | |
64 | + List<SysMenuVO> menuList = sysMenu.getChildList(); | |
65 | + for(SysMenuVO menu : menuList) { | |
66 | + SearchMenuVO searchMenu = new SearchMenuVO(); // 검색 메뉴 정보 | |
67 | + searchMenu.setMenuId(menu.getMenuId()); | |
68 | + searchMenu.setRouterUrl(menu.getRouterUrl()); | |
69 | + | |
70 | + // 전체 메뉴명 생성 | |
71 | + String fullMenuNm = ""; | |
72 | + if(sysMenu.getMenuNm() != null && !sysMenu.getMenuNm().isEmpty()) { | |
73 | + fullMenuNm = sysMenu.getMenuNm() + " > "; | |
74 | + } | |
75 | + fullMenuNm = fullMenuNm + menu.getMenuNm(); | |
76 | + searchMenu.setFullMenuNm(fullMenuNm); | |
77 | + | |
78 | + // 자식 메뉴 존재 시 재귀 처리 | |
79 | + if (!menu.getChildList().isEmpty()) { | |
80 | + menu.setMenuNm(fullMenuNm); // 자식 메뉴에 사용할 이전 전체 메뉴명 | |
81 | + this.searchMenu(menu, searchVO, searchResultVO); | |
82 | + } else { | |
83 | + // 메뉴 타입이 있을 시 | |
84 | + if (menu.getMenuType() != null && !menu.getMenuType().isEmpty()) { | |
85 | + String menuType = menu.getMenuType(); // bbs: 게시판, conts: 컨텐츠 | |
86 | + // 메뉴 URL이 있을 시 | |
87 | +// if(menu.getRouterUrl() != null && !menu.getRouterUrl().isEmpty()) { | |
88 | +// String routerUrl = menu.getRouterUrl(); // 메뉴 URL | |
89 | +// if (routerUrl.contains(".page")) { | |
90 | +// int lastSlashIndex = routerUrl.lastIndexOf('/'); // 마지막 '/' 인덱스 | |
91 | +// String path = routerUrl.substring(0, lastSlashIndex); // 마지막 '/' 이전 경로 | |
92 | +// } | |
93 | +// } | |
94 | + | |
95 | + /* 게시판 검색 */ | |
96 | + if (menuType.equals("bbs")) { | |
97 | + // 타입이 게시판일 시 게시판 내용 테이블에서 조회 | |
98 | + String bbsMngId = menu.getMenuTypeCtgry(); // 게시판 관리 ID | |
99 | + searchVO.setBbsMngId(bbsMngId); | |
100 | + | |
101 | + //TODO: (사용중)방법1.전체 개수 구하는 SQL, 미리보기 개수만큼 목록을 조회하는 SQL | |
102 | + //TODO: 방법2.전체 목록을 검색해서 개수를 구한 뒤, 미리보기 개수만큼 for문 사용해 목록 상단에서부터 따로 담기 | |
103 | + | |
104 | + // 전체 검색 목록 개수 | |
105 | + int totalListCount = searchDAO.findAllCountByBbs(searchVO); | |
106 | + searchResultVO.setPageCount(searchResultVO.getPageCount() + totalListCount); // 페이지 개수 | |
107 | + searchResultVO.setBoardCount(searchResultVO.getBoardCount() + totalListCount); // 게시판 개수 | |
108 | + searchMenu.setTotalListCount(totalListCount); | |
109 | + | |
110 | + // 미리보기 검색 게시판 목록 | |
111 | + List<SearchContentVO> bbsList = searchDAO.findAllByBbs(searchVO); | |
112 | + for(SearchContentVO bbs : bbsList) { | |
113 | + bbs.setContent(this.stripHtmlTags(bbs.getContent())); // HTML 태그 제거 | |
114 | + } | |
115 | + if (!bbsList.isEmpty()) { | |
116 | + searchMenu.setPreviewList(bbsList); // 미리보기 목록 추가 | |
117 | + searchResultVO.getPageList().add(searchMenu); // 페이지 목록에 추가 | |
118 | + searchResultVO.getBoardList().add(searchMenu); // 게시판 목록에 추가 | |
119 | + } | |
120 | + } | |
121 | + /* 컨텐츠 검색 */ | |
122 | + else if (menuType.equals("conts")) { | |
123 | + // 타입이 콘텐츠일 시 하드코딩으로 검색 조회 | |
124 | + String contsId = menu.getMenuTypeCtgry(); // 컨텐츠 ID | |
125 | + List<SearchContentVO> contentList = new ArrayList<>(); | |
126 | + | |
127 | + // 기업 정보 검색 | |
128 | + if(contsId.equals("CONTS_000000000000030")) { | |
129 | + this.searchEntInfo(searchVO, contentList, searchMenu, searchResultVO); | |
130 | + } | |
131 | + // 기업 상담 신청 검색 | |
132 | + else if(contsId.equals("CONTS_000000000000035")){ | |
133 | + this.searchEntDscsnAply(searchVO, contentList, searchMenu, searchResultVO); | |
134 | + } | |
135 | + // 투자 상담 검색 | |
136 | + else if(contsId.equals("CONTS_000000000000040")){ | |
137 | + this.searchIvstDscsn(searchVO, contentList, searchMenu, searchResultVO); | |
138 | + } | |
139 | + // 검토 사항 검색 | |
140 | + else if(contsId.equals("CONTS_000000000000037")){ | |
141 | + this.searchRvwMttr(searchVO, contentList, searchMenu, searchResultVO); | |
142 | + } | |
143 | + | |
144 | + if (!contentList.isEmpty()) { | |
145 | + searchMenu.setPreviewList(contentList); // 미리보기 목록 추가 | |
146 | + searchResultVO.getPageList().add(searchMenu); // 페이지 목록에 추가 | |
147 | + searchResultVO.getContentList().add(searchMenu); // 컨텐츠 목록에 추가 | |
148 | + } | |
149 | + } | |
150 | + } | |
151 | + } | |
152 | + } | |
153 | + } | |
154 | + | |
155 | + /** | |
156 | + * @author 하석형 | |
157 | + * @since 2024.06.13 | |
158 | + * HTML 태그 제거 | |
159 | + */ | |
160 | + public String stripHtmlTags(String html) { | |
161 | + if (html == null || html.isEmpty()) { | |
162 | + return html; | |
163 | + } | |
164 | + // HTML 태그 제거 | |
165 | + String noTags = html.replaceAll("<[^>]*>", ""); | |
166 | + // HTML 엔티티 디코딩 | |
167 | + return StringEscapeUtils.unescapeHtml4(noTags); | |
168 | + } | |
169 | + | |
170 | + | |
171 | + | |
172 | + /** ********************************* 컨텐츠 검색 - 기업 정보 (시작) ********************************* */ | |
173 | + /** | |
174 | + * @author 하석형 | |
175 | + * @since 2024.06.14 | |
176 | + * 기업 정보 검색 | |
177 | + */ | |
178 | + public void searchEntInfo (SearchVO searchVO, List<SearchContentVO> contentList, SearchMenuVO searchMenu, SearchResultVO searchResultVO) throws Exception { | |
179 | + // 전체 검색 목록 개수 | |
180 | + int totalListCount = searchDAO.findAllCountByEntInfo(searchVO); | |
181 | + this.searchListCount(totalListCount, searchMenu, searchResultVO); | |
182 | + | |
183 | + // 미리보기 검색 컨텐츠 목록 | |
184 | + List<HashMap<String, Object>> contsLists = searchDAO.findAllByEntInfo(searchVO); | |
185 | + for(HashMap<String, Object> conts : contsLists) { | |
186 | + String entNm = conts.get("ent_nm").toString(); // 기업명 | |
187 | + String rprsvNm = conts.get("rprsv_nm").toString(); // 대표자명 | |
188 | +// String clsbizYn = ""; // 기업상태 | |
189 | +// if(conts.get("clsbiz_yn").equals("Y")) { | |
190 | +// clsbizYn = "폐업"; | |
191 | +// } else if(conts.get("clsbiz_yn").equals("N")) { | |
192 | +// clsbizYn = "정상"; | |
193 | +// } else { | |
194 | +// clsbizYn = "-"; | |
195 | +// } | |
196 | +// conts.get("ivst_dscsn_inten"); // (보류)입주의향 | |
197 | + String rmrk = Optional.ofNullable(conts.get("rmrk")).map(Object::toString).orElse(""); // 비고 | |
198 | + String regDt = conts.get("reg_dt").toString(); // 등록일 | |
199 | + String pageId = conts.get("page_id").toString(); // 페이지 ID | |
200 | + | |
201 | + String makeTitle = String.format("[기업명: %s] [대표자: %s]", entNm, rprsvNm); // 제목 | |
202 | + String makeContent = rmrk; // 내용 | |
203 | + | |
204 | + // 검색 결과 형태로 변환 | |
205 | + this.convertToSearchContent(contentList, makeTitle, makeContent, regDt, pageId); | |
206 | + } | |
207 | + } | |
208 | + | |
209 | + /** | |
210 | + * @author 하석형 | |
211 | + * @since 2024.06.14 | |
212 | + * 기업 상담 신청 검색 | |
213 | + */ | |
214 | + public void searchEntDscsnAply (SearchVO searchVO, List<SearchContentVO> contentList, SearchMenuVO searchMenu, SearchResultVO searchResultVO) throws Exception { | |
215 | + // 전체 검색 목록 개수 | |
216 | + int totalListCount = searchDAO.findAllCountByEntDscsnAply(searchVO); | |
217 | + this.searchListCount(totalListCount, searchMenu, searchResultVO); | |
218 | + | |
219 | + // 미리보기 검색 컨텐츠 목록 | |
220 | + List<HashMap<String, Object>> contsLists = searchDAO.findAllByEntDscsnAply(searchVO); | |
221 | + for(HashMap<String, Object> conts : contsLists) { | |
222 | + String entNm = conts.get("ent_nm").toString(); // 기업명 | |
223 | + String prcsStts = conts.get("prcs_stts").toString(); // 진행상태 | |
224 | + String rmrk = Optional.ofNullable(conts.get("rmrk")).map(Object::toString).orElse(""); // 비고 | |
225 | + String regDt = conts.get("reg_dt").toString(); // 등록일 | |
226 | + String pageId = conts.get("page_id").toString(); // 페이지 ID | |
227 | + | |
228 | + String makeTitle = String.format("(%s)[기업명: %s]", prcsStts, entNm); // 제목 | |
229 | + String makeContent = rmrk; // 내용 | |
230 | + | |
231 | + // 검색 결과 형태로 변환 | |
232 | + this.convertToSearchContent(contentList, makeTitle, makeContent, regDt, pageId); | |
233 | + } | |
234 | + } | |
235 | + | |
236 | + /** | |
237 | + * @author 하석형 | |
238 | + * @since 2024.06.14 | |
239 | + * 투자 상담 검색 | |
240 | + */ | |
241 | + public void searchIvstDscsn (SearchVO searchVO, List<SearchContentVO> contentList, SearchMenuVO searchMenu, SearchResultVO searchResultVO) throws Exception { | |
242 | + // 전체 검색 목록 개수 | |
243 | + int totalListCount = searchDAO.findAllCountByIvstDscsn(searchVO); | |
244 | + this.searchListCount(totalListCount, searchMenu, searchResultVO); | |
245 | + | |
246 | + // 미리보기 검색 컨텐츠 목록 | |
247 | + List<HashMap<String, Object>> contsLists = searchDAO.findAllByIvstDscsn(searchVO); | |
248 | + for(HashMap<String, Object> conts : contsLists) { | |
249 | + String entNm = conts.get("ent_nm").toString(); // 기업명 | |
250 | + String ttl = conts.get("ttl").toString(); // 제목 | |
251 | + String mainCn = Optional.ofNullable(conts.get("main_cn")).map(Object::toString).orElse(""); // 주요내용 | |
252 | + String regDt = conts.get("reg_dt").toString(); // 등록일 | |
253 | + String pageId = conts.get("page_id").toString(); // 페이지 ID | |
254 | + | |
255 | + String makeTitle = String.format("[기업명: %s] - %s", entNm, ttl); // 제목 | |
256 | + String makeContent = mainCn; // 내용 | |
257 | + | |
258 | + // 검색 결과 형태로 변환 | |
259 | + this.convertToSearchContent(contentList, makeTitle, makeContent, regDt, pageId); | |
260 | + } | |
261 | + } | |
262 | + | |
263 | + /** | |
264 | + * @author 하석형 | |
265 | + * @since 2024.06.14 | |
266 | + * 검토 사항 검색 | |
267 | + */ | |
268 | + public void searchRvwMttr (SearchVO searchVO, List<SearchContentVO> contentList, SearchMenuVO searchMenu, SearchResultVO searchResultVO) throws Exception { | |
269 | + // 전체 검색 목록 개수 | |
270 | + int totalListCount = searchDAO.findAllCountByRvwMttr(searchVO); | |
271 | + this.searchListCount(totalListCount, searchMenu, searchResultVO); | |
272 | + | |
273 | + // 미리보기 검색 컨텐츠 목록 | |
274 | + List<HashMap<String, Object>> contsLists = searchDAO.findAllByRvwMttr(searchVO); | |
275 | + for(HashMap<String, Object> conts : contsLists) { | |
276 | + String entNm = conts.get("ent_nm").toString(); // 기업명 | |
277 | + String ttl = conts.get("ttl").toString(); // 투자상담명 | |
278 | + String type = conts.get("type").toString(); // 유형 | |
279 | + String mainCn = Optional.ofNullable(conts.get("rcpt_cn")).map(Object::toString).orElse(""); // 접수내용 | |
280 | + String regDt = conts.get("reg_dt").toString(); // 등록일 | |
281 | + String pageId = conts.get("page_id").toString(); // 페이지 ID | |
282 | + | |
283 | + String makeTitle = String.format("(%s)[기업명: %s] - %s", type, entNm, ttl); // 제목 | |
284 | + String makeContent = mainCn; // 내용 | |
285 | + | |
286 | + // 검색 결과 형태로 변환 | |
287 | + this.convertToSearchContent(contentList, makeTitle, makeContent, regDt, pageId); | |
288 | + } | |
289 | + } | |
290 | + | |
291 | + /** | |
292 | + * @author 하석형 | |
293 | + * @since 2024.06.14 | |
294 | + * 전체 검색 목록 조회 개수 | |
295 | + */ | |
296 | + public void searchListCount (int totalListCount, SearchMenuVO searchMenu, SearchResultVO searchResultVO) throws Exception { | |
297 | + searchResultVO.setPageCount(searchResultVO.getPageCount() + totalListCount); // 페이지 개수 | |
298 | + searchResultVO.setContentCount(searchResultVO.getContentCount() + totalListCount); // 게시판 개수 | |
299 | + searchMenu.setTotalListCount(totalListCount); | |
300 | + } | |
301 | + | |
302 | + /** | |
303 | + * @author 하석형 | |
304 | + * @since 2024.06.14 | |
305 | + * 컨텐츠를 검색 결과 형태로 변환 | |
306 | + */ | |
307 | + public void convertToSearchContent (List<SearchContentVO> contentList, String title, String content, String regDt, String pageId) throws Exception { | |
308 | + SearchContentVO searchContentVO = new SearchContentVO(); | |
309 | + searchContentVO.setTitle(title); | |
310 | + searchContentVO.setContent(content); | |
311 | + searchContentVO.setRegDt(regDt); | |
312 | + searchContentVO.setPageId(pageId); | |
313 | + contentList.add(searchContentVO); | |
314 | + } | |
315 | + /** ********************************* 컨텐츠 검색 - 기업 정보 (종료) ********************************* */ | |
316 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/search/service/SearchService.java
... | ... | @@ -0,0 +1,24 @@ |
1 | +package com.takensoft.cms.search.service; | |
2 | + | |
3 | +import com.takensoft.cms.search.vo.SearchResultVO; | |
4 | +import com.takensoft.cms.search.vo.SearchVO; | |
5 | + | |
6 | +import java.util.HashMap; | |
7 | +import java.util.List; | |
8 | +import java.util.Map; | |
9 | + | |
10 | +/** | |
11 | + * @author : 하석형 | |
12 | + * @since : 2024.06.12 | |
13 | + * | |
14 | + * 통합 검색 관련 인터페이스 | |
15 | + */ | |
16 | +public interface SearchService { | |
17 | + /** | |
18 | + * @author 하석형 | |
19 | + * @since 2024.06.12 | |
20 | + * 통합 검색 | |
21 | + */ | |
22 | + public SearchResultVO searchAll (SearchVO searchVO) throws Exception; | |
23 | + | |
24 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/cms/search/vo/SearchContentVO.java
... | ... | @@ -0,0 +1,39 @@ |
1 | +package com.takensoft.cms.search.vo; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +/** | |
7 | + * @author : 하석형 | |
8 | + * @since : 2024.06.12 | |
9 | + * | |
10 | + * 통합 검색 내용 관련 VO | |
11 | + */ | |
12 | +@Getter | |
13 | +@Setter | |
14 | +public class SearchContentVO { | |
15 | + /** | |
16 | + * 제목 | |
17 | + */ | |
18 | + private String title; | |
19 | + /** | |
20 | + * 내용 | |
21 | + */ | |
22 | + private String content; | |
23 | + /** | |
24 | + * 작성일 | |
25 | + */ | |
26 | + private String regDt; | |
27 | + /** | |
28 | + * 페이지 아이디 | |
29 | + */ | |
30 | + private String pageId; | |
31 | + /** | |
32 | + * (미사용)url | |
33 | + */ | |
34 | + private String url; | |
35 | + /** | |
36 | + * (미사용)첨부파일 ID | |
37 | + */ | |
38 | + private String fileMngId; | |
39 | +} |
+++ src/main/java/com/takensoft/cms/search/vo/SearchMenuVO.java
... | ... | @@ -0,0 +1,42 @@ |
1 | +package com.takensoft.cms.search.vo; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : 하석형 | |
11 | + * @since : 2024.06.12 | |
12 | + * | |
13 | + * 통합 검색 메뉴 관련 VO | |
14 | + */ | |
15 | +@Getter | |
16 | +@Setter | |
17 | +public class SearchMenuVO { | |
18 | + /** | |
19 | + * 상위 메뉴 아이디 | |
20 | + */ | |
21 | + private String upMenuId; | |
22 | + /** | |
23 | + * 메뉴 아이디 | |
24 | + */ | |
25 | + private String menuId; | |
26 | + /** | |
27 | + * 전체 메뉴 명 (상위메뉴명 + 메뉴명) | |
28 | + */ | |
29 | + private String fullMenuNm; | |
30 | + /** | |
31 | + * 라우터 경로 | |
32 | + */ | |
33 | + private String routerUrl; | |
34 | + /** | |
35 | + * 전체 목록 개수 | |
36 | + */ | |
37 | + private int totalListCount; | |
38 | + /** | |
39 | + * 미리보기 목록 | |
40 | + */ | |
41 | + private List<SearchContentVO> previewList = new ArrayList<>(); | |
42 | +} |
+++ src/main/java/com/takensoft/cms/search/vo/SearchResultVO.java
... | ... | @@ -0,0 +1,66 @@ |
1 | +package com.takensoft.cms.search.vo; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : 하석형 | |
11 | + * @since : 2024.06.12 | |
12 | + * | |
13 | + * 통합 검색 결과 관련 VO | |
14 | + */ | |
15 | +@Getter | |
16 | +@Setter | |
17 | +public class SearchResultVO { | |
18 | + /** | |
19 | + * (미사용)메뉴 개수 | |
20 | + */ | |
21 | + private int menuCount; | |
22 | + /** | |
23 | + * (미사용)미리보기 메뉴 목록 | |
24 | + */ | |
25 | + private List<SearchContentVO> menuList = new ArrayList<>(); | |
26 | + /** | |
27 | + * 페이지 개수 (컨텐츠 + 게시판) | |
28 | + */ | |
29 | + private int pageCount; | |
30 | + /** | |
31 | + * 페이지 목록 | |
32 | + */ | |
33 | + private List<SearchMenuVO> pageList = new ArrayList<>(); | |
34 | + /** | |
35 | + * 컨텐츠 개수 | |
36 | + */ | |
37 | + private int contentCount; | |
38 | + /** | |
39 | + * 컨텐츠 목록 | |
40 | + */ | |
41 | + private List<SearchMenuVO> contentList = new ArrayList<>(); | |
42 | + /** | |
43 | + * 게시판 개수 | |
44 | + */ | |
45 | + private int boardCount; | |
46 | + /** | |
47 | + * 게시판 목록 | |
48 | + */ | |
49 | + private List<SearchMenuVO> boardList = new ArrayList<>(); | |
50 | + /** | |
51 | + * (미사용)첨부파일 개수 | |
52 | + */ | |
53 | + private int fileCount; | |
54 | + /** | |
55 | + * (미사용)첨부파일 목록 | |
56 | + */ | |
57 | + private List<SearchMenuVO> fileList = new ArrayList<>(); | |
58 | + | |
59 | + public SearchResultVO () { | |
60 | + this.menuCount = 0; | |
61 | + this.pageCount = 0; | |
62 | + this.contentCount = 0; | |
63 | + this.boardCount = 0; | |
64 | + this.fileCount = 0; | |
65 | + } | |
66 | +} |
+++ src/main/java/com/takensoft/cms/search/vo/SearchVO.java
... | ... | @@ -0,0 +1,64 @@ |
1 | +package com.takensoft.cms.search.vo; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * @author : 하석형 | |
11 | + * @since : 2024.06.12 | |
12 | + * | |
13 | + * 통합 검색 관련 VO | |
14 | + */ | |
15 | +@Getter | |
16 | +@Setter | |
17 | +public class SearchVO { | |
18 | + /** | |
19 | + * 검색어 | |
20 | + */ | |
21 | + private String searchText; | |
22 | + /** | |
23 | + * (미사용)검색 조건 | |
24 | + * title : 제목, content : 내용 | |
25 | + */ | |
26 | + private String searchType; | |
27 | + /** | |
28 | + * (미사용)검색 정렬 | |
29 | + * L : 최신순, A : 정확도 | |
30 | + */ | |
31 | + private String sort; | |
32 | + /** | |
33 | + * (미사용)검색 시작일 | |
34 | + */ | |
35 | + private String startDt; | |
36 | + /** | |
37 | + * (미사용)검색 종료일 | |
38 | + */ | |
39 | + private String endDt; | |
40 | + /** | |
41 | + * 카테고리별 미리보기 개수 | |
42 | + */ | |
43 | + private int typePreCnt; | |
44 | + /** | |
45 | + * 사용자 Id | |
46 | + */ | |
47 | + private String mbrId; | |
48 | + /** | |
49 | + * 사용자 권한정보 | |
50 | + */ | |
51 | + private List<String> roles; | |
52 | + /** | |
53 | + * 메뉴 종류 | |
54 | + */ | |
55 | + private String menuType; | |
56 | + /** | |
57 | + * 게시판 관리 ID (게시판 검색 전용) | |
58 | + */ | |
59 | + private String bbsMngId; | |
60 | + | |
61 | +// public SearchVO() { | |
62 | +// this.typePreCnt = 5; | |
63 | +// } | |
64 | +} |
+++ src/main/java/com/takensoft/cms/search/web/SearchController.java
... | ... | @@ -0,0 +1,53 @@ |
1 | +package com.takensoft.cms.search.web; | |
2 | + | |
3 | +import com.takensoft.cms.search.service.SearchService; | |
4 | +import com.takensoft.cms.search.vo.SearchResultVO; | |
5 | +import com.takensoft.cms.search.vo.SearchVO; | |
6 | +import com.takensoft.common.util.ResponseData; | |
7 | +import lombok.RequiredArgsConstructor; | |
8 | +import lombok.extern.slf4j.Slf4j; | |
9 | +import org.springframework.http.HttpHeaders; | |
10 | +import org.springframework.http.HttpStatus; | |
11 | +import org.springframework.http.MediaType; | |
12 | +import org.springframework.http.ResponseEntity; | |
13 | +import org.springframework.web.bind.annotation.*; | |
14 | + | |
15 | +import java.nio.charset.Charset; | |
16 | + | |
17 | +/** | |
18 | + * @author : 하석형 | |
19 | + * @since : 2024.06.12 | |
20 | + * | |
21 | + * 통합 검색 관련 컨트롤러 | |
22 | + */ | |
23 | +@RestController | |
24 | +@RequiredArgsConstructor | |
25 | +@Slf4j | |
26 | +@RequestMapping("/sys/search") | |
27 | +public class SearchController { | |
28 | + | |
29 | + private final SearchService searchService; | |
30 | + | |
31 | + /** | |
32 | + * @author 하석형 | |
33 | + * @since 2024.06.11 | |
34 | + * @param searchVO | |
35 | + * @return | |
36 | + * @throws Exception | |
37 | + * | |
38 | + * 통합 검색 | |
39 | + */ | |
40 | + @PostMapping("/totalSearch.json") | |
41 | + public ResponseEntity<?> totalSearch(@RequestBody SearchVO searchVO) throws Exception { | |
42 | + SearchResultVO result = searchService.searchAll(searchVO); | |
43 | + | |
44 | + // 응답 처리 | |
45 | + HttpHeaders headers = new HttpHeaders(); | |
46 | + headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); | |
47 | + ResponseData responseData = new ResponseData(); | |
48 | + responseData.setStatus(HttpStatus.OK); | |
49 | + responseData.setMessage("정상적으로 조회가 처리되었습니다."); | |
50 | + responseData.setData(result); | |
51 | + return new ResponseEntity<>(responseData, headers, HttpStatus.OK); | |
52 | + } | |
53 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/HierachyVO.java
... | ... | @@ -0,0 +1,43 @@ |
1 | +package com.takensoft.common; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | +import lombok.NoArgsConstructor; | |
6 | +import lombok.Setter; | |
7 | + | |
8 | +import java.util.ArrayList; | |
9 | +import java.util.List; | |
10 | + | |
11 | +@Setter | |
12 | +@Getter | |
13 | +@NoArgsConstructor | |
14 | +@AllArgsConstructor | |
15 | +public class HierachyVO { | |
16 | + | |
17 | + /** | |
18 | + * 공통으로 사용될 아이디 | |
19 | + */ | |
20 | + private String id; | |
21 | + /** | |
22 | + * 공통으로 사용될 상위 아이디 | |
23 | + */ | |
24 | + private String upId; | |
25 | + /** | |
26 | + * 공통으로 사용될 이름 | |
27 | + */ | |
28 | + private String nm; | |
29 | + /** | |
30 | + * 공통으로 사용될 깊이(레벨) | |
31 | + */ | |
32 | + private int grd; | |
33 | + /** | |
34 | + * 공통으로 사용될 순서 | |
35 | + */ | |
36 | + private int sn; | |
37 | + | |
38 | + /** | |
39 | + * 공통으로 사용될 자식 객체 | |
40 | + */ | |
41 | + List<HierachyVO> childList = new ArrayList<HierachyVO>(); | |
42 | + | |
43 | +} |
+++ src/main/java/com/takensoft/common/Pagination.java
... | ... | @@ -0,0 +1,91 @@ |
1 | +package com.takensoft.common; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +import java.util.HashMap; | |
7 | +import java.util.Map; | |
8 | + | |
9 | +@Getter | |
10 | +@Setter | |
11 | +public class Pagination { | |
12 | + private int currentPage = 1; // 현재 페이지 | |
13 | + private int recordSize = 10; // 한 페이지에 표시할 데이터 개수 | |
14 | + private int pageSize = 10; // 하단에 표시할 페이지 번호 개수 | |
15 | + | |
16 | + private int totalRecordCount; // 전체 데이터 개수 | |
17 | + private int totalPageCount; // 전체 페이지 개수 | |
18 | + private int startPage; // 첫 페이지 번호 | |
19 | + private int endPage; // 끝 페이지 번호 | |
20 | + private int limitStart; // LIMIT 시작 위치 | |
21 | + private boolean existPrevPage; // 이전 페이지 존재 여부 | |
22 | + private boolean existNextPage; // 다음 페이지 존재 여부 | |
23 | + | |
24 | + private String searchType; // 검색조건 | |
25 | + private String searchText; // 검색어 | |
26 | + | |
27 | + private String startDt; // 시작일 | |
28 | + private String endDt; // 종료일 | |
29 | + | |
30 | + private String id; // 게시판 아이디 (게시판 내용 목록 조회 조건시 사용) | |
31 | + | |
32 | + private String cateId; // 상세 분류 아이디 | |
33 | + private String cateValue; // 상세 분류 내용 | |
34 | + | |
35 | + private String mvnInten; // 입주의향 (기업정보 전용) | |
36 | + private String mouInten; // MOU의향 (기업정보 전용) | |
37 | + | |
38 | + private String type; // 형태 (검토사항 전용) | |
39 | + private String prgrsCrs; // 진행단계 (검토사항 전용) | |
40 | + | |
41 | + private String mbrId; // 멤버 Id (권한 확인 용도) | |
42 | + private String isAdmin; // 멤버 권한 관리자 여부 (권한 확인 용도) | |
43 | + | |
44 | + public Pagination(int totalRecordCount, Map<String, String> params) { | |
45 | + this.currentPage = Integer.parseInt(params.getOrDefault("currentPage", "1")); | |
46 | + this.recordSize = Integer.parseInt(params.getOrDefault("recordSize", "1")); | |
47 | + this.pageSize = Integer.parseInt(params.getOrDefault("pageSize", "10")); | |
48 | + this.searchType = (String)params.get("searchType"); | |
49 | + this.searchText = (String)params.get("searchText"); | |
50 | + this.startDt = (String)params.get("startDt"); | |
51 | + this.endDt = (String)params.get("endDt"); | |
52 | + this.id = (String)params.get("id"); | |
53 | + this.cateId = (String)params.get("cateId"); | |
54 | + this.cateValue = (String)params.get("cateValue"); | |
55 | + this.mvnInten = (String)params.get("mvnInten"); | |
56 | + this.mouInten = (String)params.get("mouInten"); | |
57 | + this.type = (String)params.get("type"); | |
58 | + this.prgrsCrs = (String)params.get("prgrsCrs"); | |
59 | + this.mbrId = (String)params.get("mbrId"); | |
60 | + this.isAdmin = (String)params.get("isAdmin"); | |
61 | + | |
62 | + if (totalRecordCount > 0) { | |
63 | + // 전체 데이터 개수 | |
64 | + this.totalRecordCount = totalRecordCount; | |
65 | + | |
66 | + // 전체 페이지 개수 | |
67 | + this.totalPageCount = ((this.totalRecordCount - 1) / this.recordSize) + 1; | |
68 | + if (this.currentPage > this.totalPageCount) { | |
69 | + this.currentPage = this.totalPageCount; | |
70 | + } | |
71 | + | |
72 | + // 첫 페이지 번호 | |
73 | + this.startPage = ((this.currentPage - 1) / this.pageSize) * this.pageSize + 1; | |
74 | + | |
75 | + // 끝 페이지 번호 | |
76 | + this.endPage = this.startPage + this.pageSize - 1; | |
77 | + if (this.endPage > this.totalPageCount) { | |
78 | + this.endPage = this.totalPageCount; | |
79 | + } | |
80 | + | |
81 | + // LIMIT 시작 위치 | |
82 | + this.limitStart = (this.currentPage - 1) * this.recordSize; | |
83 | + | |
84 | + // 이전 페이지 존재 여부 | |
85 | + this.existPrevPage = this.startPage != 1; | |
86 | + | |
87 | + // 다음 페이지 존재 여부 | |
88 | + this.existNextPage = (this.endPage * this.recordSize) < this.totalRecordCount; | |
89 | + } | |
90 | + } | |
91 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/config/CacheConfig.java
... | ... | @@ -0,0 +1,10 @@ |
1 | +package com.takensoft.common.config; | |
2 | + | |
3 | +import org.springframework.cache.annotation.EnableCaching; | |
4 | +import org.springframework.context.annotation.Configuration; | |
5 | + | |
6 | +@Configuration | |
7 | +@EnableCaching | |
8 | +public class CacheConfig { | |
9 | + | |
10 | +} |
+++ src/main/java/com/takensoft/common/config/CmsDataSourceConfig.java
... | ... | @@ -0,0 +1,63 @@ |
1 | +package com.takensoft.common.config; | |
2 | + | |
3 | +import org.apache.ibatis.session.SqlSessionFactory; | |
4 | +import org.mybatis.spring.SqlSessionFactoryBean; | |
5 | +import org.mybatis.spring.SqlSessionTemplate; | |
6 | +import org.mybatis.spring.annotation.MapperScan; | |
7 | +import org.springframework.beans.factory.annotation.Qualifier; | |
8 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
9 | +import org.springframework.boot.jdbc.DataSourceBuilder; | |
10 | +import org.springframework.context.ApplicationContext; | |
11 | +import org.springframework.context.annotation.Bean; | |
12 | +import org.springframework.context.annotation.Configuration; | |
13 | +import org.springframework.context.annotation.Primary; | |
14 | + | |
15 | +import javax.sql.DataSource; | |
16 | + | |
17 | +@Configuration | |
18 | +@MapperScan(basePackages="com.takensoft.*.*.dao, com.takensoft.*.*.*.dao", sqlSessionFactoryRef = "cmsSqlSessionFactory") | |
19 | +public class CmsDataSourceConfig { | |
20 | + | |
21 | + @Primary | |
22 | + @Bean(name = "cmsDataSource") | |
23 | + @ConfigurationProperties(prefix = "spring.cms.datasource") | |
24 | + public DataSource cmsDataSource() { | |
25 | + return DataSourceBuilder.create().build(); | |
26 | + } | |
27 | + | |
28 | + @Primary | |
29 | + @Bean(name = "cmsSqlSessionFactory") | |
30 | + public SqlSessionFactory cmsSqlSessionFactory(@Qualifier("cmsDataSource") DataSource cmsDataSource, | |
31 | + ApplicationContext applicationContext) throws Exception { | |
32 | + SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | |
33 | + sqlSessionFactoryBean.setDataSource(cmsDataSource); | |
34 | + sqlSessionFactoryBean.setTypeAliasesPackage("com.takensoft.**.**.vo, com.takensoft.**.**.dto, com.takensoft.common"); | |
35 | + sqlSessionFactoryBean.setMapperLocations(applicationContext.getResources("classpath:mybatis/mapper/**/*-SQL.xml")); | |
36 | + | |
37 | + // MyBatis Configuration 설정 추가 | |
38 | + org.apache.ibatis.session.Configuration myBatisConfig = new org.apache.ibatis.session.Configuration(); | |
39 | + myBatisConfig.setCacheEnabled(true); | |
40 | + myBatisConfig.setLazyLoadingEnabled(false); | |
41 | + myBatisConfig.setMultipleResultSetsEnabled(true); | |
42 | + myBatisConfig.setUseColumnLabel(true); | |
43 | + myBatisConfig.setUseGeneratedKeys(false); | |
44 | + myBatisConfig.setDefaultExecutorType(org.apache.ibatis.session.ExecutorType.SIMPLE); | |
45 | + myBatisConfig.setDefaultStatementTimeout(25000); | |
46 | + myBatisConfig.setCallSettersOnNulls(true); | |
47 | + myBatisConfig.setMapUnderscoreToCamelCase(true); | |
48 | + | |
49 | + sqlSessionFactoryBean.setConfiguration(myBatisConfig); | |
50 | + | |
51 | + return sqlSessionFactoryBean.getObject(); | |
52 | + } | |
53 | + | |
54 | + @Primary | |
55 | + @Bean(name = "firstSessionTemplate") | |
56 | + public SqlSessionTemplate firstSqlSessionTemplate(@Qualifier("cmsSqlSessionFactory") SqlSessionFactory cmsSqlSessionFactory) { | |
57 | + return new SqlSessionTemplate(cmsSqlSessionFactory); | |
58 | + } | |
59 | +} | |
60 | + | |
61 | + | |
62 | + | |
63 | + |
+++ src/main/java/com/takensoft/common/config/CommonConfig.java
... | ... | @@ -0,0 +1,69 @@ |
1 | +package com.takensoft.common.config; | |
2 | + | |
3 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
4 | +import com.fasterxml.jackson.databind.SerializationFeature; | |
5 | +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | |
6 | +import org.egovframe.rte.fdl.cmmn.trace.LeaveaTrace; | |
7 | +import org.egovframe.rte.fdl.cmmn.trace.handler.DefaultTraceHandler; | |
8 | +import org.egovframe.rte.fdl.cmmn.trace.handler.TraceHandler; | |
9 | +import org.egovframe.rte.fdl.cmmn.trace.manager.DefaultTraceHandleManager; | |
10 | +import org.egovframe.rte.fdl.cmmn.trace.manager.TraceHandlerService; | |
11 | +import org.springframework.context.annotation.Bean; | |
12 | +import org.springframework.context.annotation.Configuration; | |
13 | +import org.springframework.util.AntPathMatcher; | |
14 | +import org.springframework.web.servlet.view.json.MappingJackson2JsonView; | |
15 | + | |
16 | +@Configuration | |
17 | +public class CommonConfig { | |
18 | + | |
19 | + @Bean(name="jsonView") | |
20 | + public MappingJackson2JsonView getJsonView () { | |
21 | + ObjectMapper objectMapper = getObjectMapper(); | |
22 | + MappingJackson2JsonView jsonView = new MappingJackson2JsonView(objectMapper); | |
23 | + jsonView.setExtractValueFromSingleKeyModel(true); | |
24 | + return jsonView; | |
25 | + } | |
26 | + | |
27 | + @Bean(name = "objectMapper") | |
28 | + public ObjectMapper getObjectMapper() { | |
29 | + ObjectMapper mapper = new ObjectMapper(); | |
30 | + | |
31 | + mapper.registerModule(new JavaTimeModule()); | |
32 | + //기본 날짜 포맷 비활성화 | |
33 | + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | |
34 | + | |
35 | + //새로운 날짜 포맷 세팅 | |
36 | + /*SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
37 | + mapper.setDateFormat(dateFormat); | |
38 | + mapper.setTimeZone(TimeZone.getTimeZone("Asia/Seoul"));*/ | |
39 | + | |
40 | + return mapper; | |
41 | + } | |
42 | + | |
43 | + @Bean | |
44 | + public AntPathMatcher antPathMatcher() { | |
45 | + return new AntPathMatcher(); | |
46 | + } | |
47 | + | |
48 | + @Bean | |
49 | + public DefaultTraceHandler defaultTraceHandler() { | |
50 | + return new DefaultTraceHandler(); | |
51 | + } | |
52 | + | |
53 | + @Bean | |
54 | + public DefaultTraceHandleManager traceHandlerService() { | |
55 | + DefaultTraceHandleManager defaultTraceHandleManager = new DefaultTraceHandleManager(); | |
56 | + defaultTraceHandleManager.setReqExpMatcher(antPathMatcher()); | |
57 | + defaultTraceHandleManager.setPatterns(new String[]{"*"}); | |
58 | + defaultTraceHandleManager.setHandlers(new TraceHandler[]{defaultTraceHandler()}); | |
59 | + return defaultTraceHandleManager; | |
60 | + } | |
61 | + | |
62 | + @Bean | |
63 | + public LeaveaTrace leaveaTrace() { | |
64 | + LeaveaTrace leaveaTrace = new LeaveaTrace(); | |
65 | + leaveaTrace.setTraceHandlerServices(new TraceHandlerService[]{traceHandlerService()}); | |
66 | + return leaveaTrace; | |
67 | + } | |
68 | + | |
69 | +} |
+++ src/main/java/com/takensoft/common/config/CorsMvcConfig.java
... | ... | @@ -0,0 +1,22 @@ |
1 | +package com.takensoft.common.config; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Value; | |
4 | +import org.springframework.context.annotation.Configuration; | |
5 | +import org.springframework.web.servlet.config.annotation.CorsRegistry; | |
6 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |
7 | + | |
8 | +@Configuration | |
9 | +public class CorsMvcConfig implements WebMvcConfigurer { | |
10 | + | |
11 | + private static String FRONT_URL; // 프론트 경로 | |
12 | + @Value("${front.url}") | |
13 | + public void setFrontUrl(String value) { | |
14 | + FRONT_URL = value; | |
15 | + } | |
16 | + | |
17 | + @Override | |
18 | + public void addCorsMappings(CorsRegistry corsRegistry) { | |
19 | + corsRegistry.addMapping("/**") | |
20 | + .allowedOrigins(FRONT_URL); | |
21 | + } | |
22 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/config/SecurityConfig.java
... | ... | @@ -0,0 +1,135 @@ |
1 | +package com.takensoft.common.config; | |
2 | + | |
3 | +import com.takensoft.cms.accesCtrl.service.AccesCtrlService; | |
4 | +import com.takensoft.cms.mber.service.LgnHstryService; | |
5 | +import com.takensoft.cms.mber.service.RefreshTokenService; | |
6 | +import com.takensoft.common.filter.AccesFilter; | |
7 | +import com.takensoft.common.filter.JWTFilter; | |
8 | +import com.takensoft.common.filter.LoginFilter; | |
9 | +import com.takensoft.common.util.CommonUtils; | |
10 | +import com.takensoft.common.util.CustomAccessDenieHandler; | |
11 | +import com.takensoft.common.util.CustomAuthenticationEntryPoint; | |
12 | +import com.takensoft.common.util.JWTUtil; | |
13 | +import org.springframework.beans.factory.annotation.Value; | |
14 | +import org.springframework.context.annotation.Bean; | |
15 | +import org.springframework.context.annotation.Configuration; | |
16 | +import org.springframework.security.authentication.AuthenticationManager; | |
17 | +import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; | |
18 | +import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
19 | +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | |
20 | +import org.springframework.security.config.http.SessionCreationPolicy; | |
21 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
22 | +import org.springframework.security.web.SecurityFilterChain; | |
23 | +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | |
24 | +import org.springframework.web.cors.CorsConfiguration; | |
25 | +import org.springframework.web.cors.CorsConfigurationSource; | |
26 | + | |
27 | +import javax.servlet.http.HttpServletRequest; | |
28 | +import java.util.Collections; | |
29 | + | |
30 | +/** | |
31 | + * @author takensoft | |
32 | + * @since 2024.04.01 | |
33 | + * | |
34 | + * 스프링 시큐리티 설정 | |
35 | + */ | |
36 | +@Configuration | |
37 | +@EnableWebSecurity | |
38 | +public class SecurityConfig { | |
39 | + | |
40 | + // AuthenticationManager가 인자로 받을 AuthenticationConfiguration 객체 생성자 주입 | |
41 | + private final AuthenticationConfiguration authenticationConfiguration; | |
42 | + private final JWTUtil jwtUtil; | |
43 | + private final RefreshTokenService refreshTokenService; | |
44 | + private final LgnHstryService lgnHstryService; | |
45 | + private final AccesCtrlService accesCtrlService; | |
46 | + private final CustomAuthenticationEntryPoint authenticationEntryPoint; | |
47 | + private final CustomAccessDenieHandler accessDenieHandler; | |
48 | + private final CommonUtils commonUtils; | |
49 | + private final CommonConfig commonConfig; | |
50 | + | |
51 | + private static String FRONT_URL; // 프론트 접근 허용 URL | |
52 | + private static long JWT_ACCESSTIME; // access 토큰 유지 시간 | |
53 | + private static long JWT_REFRESHTIME; // refresh 토큰 유지 시간 | |
54 | + private static int COOKIE_TIME; // 쿠키 유지 시간 | |
55 | + | |
56 | + public SecurityConfig(AuthenticationConfiguration authenticationConfiguration, JWTUtil jwtUtil, RefreshTokenService refreshTokenService, AccesCtrlService accesCtrlService, CommonConfig commonConfig, | |
57 | + LgnHstryService lgnHstryService, CustomAuthenticationEntryPoint authenticationEntryPoint, CustomAccessDenieHandler accessDenieHandler, CommonUtils commonUtils, | |
58 | + @Value("${front.url}")String fUrl,@Value("${jwt.accessTime}")long aTime, @Value("${jwt.refreshTime}")long rTime, @Value("${cookie.time}")int ctime) { | |
59 | + | |
60 | + this.authenticationConfiguration = authenticationConfiguration; | |
61 | + this.refreshTokenService = refreshTokenService; | |
62 | + this.lgnHstryService = lgnHstryService; | |
63 | + this.accesCtrlService = accesCtrlService; | |
64 | + this.authenticationEntryPoint = authenticationEntryPoint; | |
65 | + this.accessDenieHandler = accessDenieHandler; | |
66 | + this.jwtUtil = jwtUtil; | |
67 | + this.commonUtils = commonUtils; | |
68 | + this.commonConfig = commonConfig; | |
69 | + | |
70 | + this.FRONT_URL = fUrl; | |
71 | + this.JWT_ACCESSTIME = aTime; | |
72 | + this.JWT_REFRESHTIME = rTime; | |
73 | + this.COOKIE_TIME = ctime; | |
74 | + } | |
75 | + | |
76 | + // AuthenticationManager Bean 등록 | |
77 | + @Bean | |
78 | + public AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception { | |
79 | + return configuration.getAuthenticationManager(); | |
80 | + } | |
81 | + | |
82 | + // 해시 암호화 | |
83 | + @Bean | |
84 | + public BCryptPasswordEncoder bCryptPasswordEncoder() { | |
85 | + return new BCryptPasswordEncoder(); | |
86 | + } | |
87 | + | |
88 | + @Bean | |
89 | + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | |
90 | + http.cors((cors) -> cors | |
91 | + .configurationSource(new CorsConfigurationSource() { | |
92 | + @Override | |
93 | + public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { | |
94 | + CorsConfiguration configuration = new CorsConfiguration(); | |
95 | + configuration.setAllowedOrigins(Collections.singletonList(FRONT_URL)); // 허용할 프론트 포트 포함 경로 입력 | |
96 | + configuration.setAllowedMethods(Collections.singletonList("*")); // 허용할 메소드(GET, POST, PUT 등) | |
97 | + configuration.setAllowedHeaders(Collections.singletonList("*")); // 허용할 헤드 | |
98 | + configuration.setAllowCredentials(true); // 프론트에서 credentials 설정하면 true | |
99 | + configuration.setMaxAge(3600L); // 허용을 물고 있을 시간 | |
100 | + configuration.setExposedHeaders(Collections.singletonList("Authorization")); // 서버에서 JWT를 Authorization에 담아 보내기 위해 허용을 함 | |
101 | + return configuration; | |
102 | + } | |
103 | + }) | |
104 | + ); | |
105 | + // csrf disable | |
106 | + http.csrf((auth) -> auth.disable()); | |
107 | + // formLogin disable | |
108 | + http.formLogin((auth) -> auth.disable()); | |
109 | + // http basic 인증 방식 disable | |
110 | + http.httpBasic((auth) -> auth.disable()); | |
111 | + // 세션 설정 | |
112 | + http.sessionManagement((session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)); | |
113 | + | |
114 | + http.exceptionHandling((exception) -> exception | |
115 | + .authenticationEntryPoint(authenticationEntryPoint) // 접근 권한이 없는 경우에 호출 | |
116 | + .accessDeniedHandler(accessDenieHandler) // 인증되지 않은 상태로 접근 했을 때 호출 | |
117 | + ); | |
118 | + | |
119 | + http.authorizeHttpRequests((auth) -> auth | |
120 | + .antMatchers("/", "/mbr/**", "/company/**", "/refresh/**", "/sys/**").permitAll() // 회원관련, 시스템 제공 관련, 기업용페이지는 누구나 접근 가능 | |
121 | + .antMatchers("/admin/**").hasRole("ADMIN") // 관리자 페이지는 ADMIN 권한을 가진 사용자만 접근 가능 | |
122 | + .antMatchers("/editFileUpload/**", "/fileUpload/**").permitAll() // 에디터 파일 업로드 | |
123 | + .anyRequest().authenticated() // 그 외에는 로그인한 사용자만 접근 가능 | |
124 | +// .anyRequest().permitAll() // 모든 사용자 접근 가능 | |
125 | + ); | |
126 | + | |
127 | + | |
128 | + http.addFilterBefore(new JWTFilter(jwtUtil, commonConfig), LoginFilter.class); // 토큰 검증 필터 | |
129 | + http.addFilterBefore(new AccesFilter(accesCtrlService, commonUtils, commonConfig), JWTFilter.class); // 아이피 검증 | |
130 | + http.addFilterAt(new LoginFilter(authenticationManager(authenticationConfiguration), jwtUtil, refreshTokenService, lgnHstryService, commonUtils, | |
131 | + commonConfig, JWT_ACCESSTIME, JWT_REFRESHTIME, COOKIE_TIME), UsernamePasswordAuthenticationFilter.class); // 로그인 필터 | |
132 | + | |
133 | + return http.build(); | |
134 | + } | |
135 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/config/UmsDataSourceConfig.java
... | ... | @@ -0,0 +1,56 @@ |
1 | +package com.takensoft.common.config; | |
2 | + | |
3 | + | |
4 | +import org.apache.ibatis.session.SqlSessionFactory; | |
5 | +import org.mybatis.spring.SqlSessionFactoryBean; | |
6 | +import org.mybatis.spring.SqlSessionTemplate; | |
7 | +import org.mybatis.spring.annotation.MapperScan; | |
8 | +import org.springframework.beans.factory.annotation.Qualifier; | |
9 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
10 | +import org.springframework.boot.jdbc.DataSourceBuilder; | |
11 | +import org.springframework.context.ApplicationContext; | |
12 | +import org.springframework.context.annotation.Bean; | |
13 | +import org.springframework.context.annotation.Configuration; | |
14 | +import org.springframework.web.context.WebApplicationContext; | |
15 | + | |
16 | +import javax.sql.DataSource; | |
17 | + | |
18 | +@Configuration | |
19 | +@MapperScan(basePackages="com.takensoft.ums.dao", sqlSessionFactoryRef = "umsSqlSessionFactory") | |
20 | +public class UmsDataSourceConfig { | |
21 | + @Bean(name = "umsDataSource") | |
22 | + @ConfigurationProperties(prefix="spring.ums.datasource") | |
23 | + public DataSource umsDataSource() { | |
24 | + return DataSourceBuilder.create().build(); | |
25 | + } | |
26 | + | |
27 | + @Bean(name = "umsSqlSessionFactory") | |
28 | + public SqlSessionFactory umsSqlSessionFactory(@Qualifier("umsDataSource") DataSource umsDataSource, | |
29 | + ApplicationContext applicationContext) throws Exception { | |
30 | + SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | |
31 | + sqlSessionFactoryBean.setDataSource(umsDataSource); | |
32 | + sqlSessionFactoryBean.setTypeAliasesPackage("com.takensoft.ums.vo"); | |
33 | + sqlSessionFactoryBean.setMapperLocations(applicationContext.getResources("classpath:mybatis/mapper-ora/**/*-SQL.xml")); | |
34 | + | |
35 | + // MyBatis Configuration 설정 추가 | |
36 | + org.apache.ibatis.session.Configuration myBatisConfig = new org.apache.ibatis.session.Configuration(); | |
37 | + myBatisConfig.setCacheEnabled(true); | |
38 | + myBatisConfig.setLazyLoadingEnabled(false); | |
39 | + myBatisConfig.setMultipleResultSetsEnabled(true); | |
40 | + myBatisConfig.setUseColumnLabel(true); | |
41 | + myBatisConfig.setUseGeneratedKeys(false); | |
42 | + myBatisConfig.setDefaultExecutorType(org.apache.ibatis.session.ExecutorType.SIMPLE); | |
43 | + myBatisConfig.setDefaultStatementTimeout(25000); | |
44 | + myBatisConfig.setCallSettersOnNulls(true); | |
45 | + myBatisConfig.setMapUnderscoreToCamelCase(true); | |
46 | + | |
47 | + sqlSessionFactoryBean.setConfiguration(myBatisConfig); | |
48 | + | |
49 | + return sqlSessionFactoryBean.getObject(); | |
50 | + } | |
51 | + | |
52 | + @Bean(name = "umsSessionTemplate") | |
53 | + public SqlSessionTemplate umsSqlSessionTemplate(@Qualifier("umsSqlSessionFactory") SqlSessionFactory umsSqlSessionFactory) { | |
54 | + return new SqlSessionTemplate(umsSqlSessionFactory); | |
55 | + } | |
56 | +} |
+++ src/main/java/com/takensoft/common/config/WebConfig.java
... | ... | @@ -0,0 +1,26 @@ |
1 | +package com.takensoft.common.config; | |
2 | + | |
3 | +import org.springframework.context.annotation.Bean; | |
4 | +import org.springframework.context.annotation.Configuration; | |
5 | +import org.springframework.web.filter.CommonsRequestLoggingFilter; | |
6 | +import org.springframework.web.filter.ForwardedHeaderFilter; | |
7 | + | |
8 | +import javax.servlet.Filter; | |
9 | + | |
10 | +@Configuration | |
11 | +public class WebConfig { | |
12 | + @Bean | |
13 | + public Filter forwardedHeaderFilter() { | |
14 | + return new ForwardedHeaderFilter(); | |
15 | + } | |
16 | + | |
17 | + @Bean | |
18 | + public CommonsRequestLoggingFilter requestLoggingFilter() { | |
19 | + CommonsRequestLoggingFilter loggingFilter = new CommonsRequestLoggingFilter(); | |
20 | + loggingFilter.setIncludeClientInfo(true); | |
21 | + loggingFilter.setIncludeQueryString(true); | |
22 | + loggingFilter.setIncludePayload(true); | |
23 | + loggingFilter.setIncludeHeaders(true); | |
24 | + return loggingFilter; | |
25 | + } | |
26 | +} |
+++ src/main/java/com/takensoft/common/excel/annotation/ExcelColumnName.java
... | ... | @@ -0,0 +1,12 @@ |
1 | +package com.takensoft.common.excel.annotation; | |
2 | + | |
3 | +import java.lang.annotation.ElementType; | |
4 | +import java.lang.annotation.Retention; | |
5 | +import java.lang.annotation.RetentionPolicy; | |
6 | +import java.lang.annotation.Target; | |
7 | + | |
8 | +@Target(ElementType.FIELD) | |
9 | +@Retention(RetentionPolicy.RUNTIME) | |
10 | +public @interface ExcelColumnName { | |
11 | + String headerName() default ""; | |
12 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/excel/annotation/ExcelFileName.java
... | ... | @@ -0,0 +1,12 @@ |
1 | +package com.takensoft.common.excel.annotation; | |
2 | + | |
3 | +import java.lang.annotation.ElementType; | |
4 | +import java.lang.annotation.Retention; | |
5 | +import java.lang.annotation.RetentionPolicy; | |
6 | +import java.lang.annotation.Target; | |
7 | + | |
8 | +@Target(ElementType.TYPE) | |
9 | +@Retention(RetentionPolicy.RUNTIME) | |
10 | +public @interface ExcelFileName { | |
11 | + String fileName() default ""; | |
12 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/excel/resource/ExcelRenderResource.java
... | ... | @@ -0,0 +1,17 @@ |
1 | +package com.takensoft.common.excel.resource; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.RequiredArgsConstructor; | |
5 | +import java.util.*; | |
6 | + | |
7 | +@Getter | |
8 | +@RequiredArgsConstructor | |
9 | +public class ExcelRenderResource { | |
10 | + private final String excelFileName; | |
11 | + private final Map<String, String> excelHeaderNames; | |
12 | + private final List<String> dataFieldNames; | |
13 | + | |
14 | + public String getExcelHeaderName(String dataFieldName) { | |
15 | + return excelHeaderNames.get(dataFieldName); | |
16 | + } | |
17 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/excel/resource/ExcelRenderResourceFactory.java
... | ... | @@ -0,0 +1,35 @@ |
1 | +package com.takensoft.common.excel.resource; | |
2 | + | |
3 | +import com.takensoft.common.excel.annotation.ExcelColumnName; | |
4 | +import com.takensoft.common.excel.annotation.ExcelFileName; | |
5 | +import com.takensoft.common.excel.util.SuperClassReflectionUtil; | |
6 | +import org.springframework.util.StringUtils; | |
7 | +import java.util.*; | |
8 | +import java.lang.reflect.Field; | |
9 | + | |
10 | +public class ExcelRenderResourceFactory { | |
11 | + public static ExcelRenderResource prepareRenderResource(Class<?> type) { | |
12 | + String fileName = getFileName(type); | |
13 | + Map<String, String> headerNamesMap = new LinkedHashMap<>(); | |
14 | + List<String> fieldNames = new ArrayList<>(); | |
15 | + for (Field field : SuperClassReflectionUtil.getAllFields(type)) { | |
16 | + if (field.isAnnotationPresent(ExcelColumnName.class)) { | |
17 | + ExcelColumnName annotation = field.getAnnotation(ExcelColumnName.class); | |
18 | + fieldNames.add(field.getName()); | |
19 | + String headerName = annotation.headerName(); | |
20 | + headerName = StringUtils.hasText(headerName) ? headerName : field.getName(); | |
21 | + headerNamesMap.put(field.getName(), headerName); | |
22 | + } | |
23 | + } | |
24 | + return new ExcelRenderResource(fileName, headerNamesMap, fieldNames); | |
25 | + } | |
26 | + | |
27 | + private static String getFileName(Class<?> type) { | |
28 | + String fileName = type.getSimpleName(); | |
29 | + if (type.isAnnotationPresent(ExcelColumnName.class)) { | |
30 | + fileName = type.getAnnotation(ExcelFileName.class).fileName(); | |
31 | + if(!StringUtils.hasText(fileName)) fileName = type.getSimpleName(); | |
32 | + } | |
33 | + return fileName; | |
34 | + } | |
35 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/excel/service/ExcelCreateService.java
... | ... | @@ -0,0 +1,309 @@ |
1 | +package com.takensoft.common.excel.service; | |
2 | + | |
3 | +import com.takensoft.common.excel.resource.ExcelRenderResource; | |
4 | +import com.takensoft.common.excel.resource.ExcelRenderResourceFactory; | |
5 | +import com.takensoft.common.excel.util.SuperClassReflectionUtil; | |
6 | +import org.apache.poi.ss.usermodel.*; | |
7 | +import org.apache.poi.util.IOUtils; | |
8 | +import org.apache.poi.xssf.streaming.SXSSFWorkbook; | |
9 | +import org.springframework.util.ObjectUtils; | |
10 | + | |
11 | +import java.io.File; | |
12 | +import java.io.FileInputStream; | |
13 | +import java.io.FileOutputStream; | |
14 | +import java.io.InputStream; | |
15 | +import java.lang.reflect.Field; | |
16 | +import java.nio.file.Paths; | |
17 | +import java.util.Base64; | |
18 | +import java.util.List; | |
19 | + | |
20 | +public class ExcelCreateService<T> { | |
21 | + private Workbook workbook; | |
22 | + private Sheet sheet; | |
23 | + private ExcelRenderResource resource; | |
24 | + private List<T> dataList; | |
25 | + private static final String BASE64_PNG_PRE_FIX = "data:image/png;base64,"; | |
26 | + | |
27 | + public ExcelCreateService(Workbook workbook, Sheet sheet, List<T> dataList, Class<T> type) { | |
28 | + this.workbook = workbook; | |
29 | + this.sheet = sheet; | |
30 | + this.resource = ExcelRenderResourceFactory.prepareRenderResource(type); | |
31 | + this.dataList = dataList; | |
32 | + } | |
33 | + | |
34 | + // 헤더 스타일 | |
35 | + private CellStyle theadStyle() { | |
36 | + CellStyle headerCellStyle = tbodyStyle(); | |
37 | + headerCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); | |
38 | + headerCellStyle.setFillPattern(FillPatternType.BRICKS); | |
39 | + return headerCellStyle; | |
40 | + } | |
41 | + // 내용 스타일 | |
42 | + private CellStyle tbodyStyle() { | |
43 | + CellStyle bodyCellStyle = workbook.createCellStyle(); | |
44 | + bodyCellStyle.setBorderLeft(BorderStyle.THIN); | |
45 | + bodyCellStyle.setBorderRight(BorderStyle.THIN); | |
46 | + bodyCellStyle.setBorderTop(BorderStyle.THIN); | |
47 | + bodyCellStyle.setBorderBottom(BorderStyle.THIN); | |
48 | + bodyCellStyle.setWrapText(true); | |
49 | + return bodyCellStyle; | |
50 | + } | |
51 | + // 빈칸 스타일 | |
52 | + private CellStyle emptyStyle() { | |
53 | + CellStyle emptyStyle = workbook.createCellStyle(); | |
54 | + emptyStyle.setBorderLeft(BorderStyle.NONE); | |
55 | + emptyStyle.setBorderRight(BorderStyle.NONE); | |
56 | + emptyStyle.setBorderTop(BorderStyle.NONE); | |
57 | + emptyStyle.setBorderBottom(BorderStyle.NONE); | |
58 | + return emptyStyle; | |
59 | + } | |
60 | + | |
61 | + // 세로 적재 테이블 그리기 | |
62 | + public int createVertical(ExcelRenderResource resource, List<T> dataList, int rowIndex) throws NoSuchFieldException, IllegalAccessException { | |
63 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
64 | + // tr | |
65 | + Row row = sheet.createRow(rowIndex++); | |
66 | + // th | |
67 | + Cell cell = row.createCell(0); | |
68 | + String value = resource.getExcelHeaderName(dataFieldName); | |
69 | + cell.setCellValue(value); | |
70 | + cell.setCellStyle(theadStyle()); | |
71 | + int columnIndex = 1; | |
72 | + // td | |
73 | + for (T data : dataList) { | |
74 | + cell = row.createCell(columnIndex++); | |
75 | + Field field = SuperClassReflectionUtil.getField(data.getClass(), (dataFieldName)); | |
76 | + field.setAccessible(true); | |
77 | + Object cellValue = field.get(data); | |
78 | + field.setAccessible(false); | |
79 | + setCellValue(cell, cellValue); | |
80 | + } | |
81 | + } | |
82 | + | |
83 | + return rowIndex; | |
84 | + } | |
85 | + | |
86 | + // 가로 적재 테이블 그리기 | |
87 | + public int createHorizontal(ExcelRenderResource resource, List<T> dataList, int rowIndex) throws NoSuchFieldException, IllegalAccessException { | |
88 | + // tr | |
89 | + Row row = sheet.createRow(rowIndex++); | |
90 | + // th | |
91 | + int columnIndex = 0; | |
92 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
93 | + Cell cell = row.createCell(columnIndex++); | |
94 | + String value = resource.getExcelHeaderName(dataFieldName); | |
95 | + cell.setCellValue(value); | |
96 | + cell.setCellStyle(theadStyle()); | |
97 | + } | |
98 | + // td | |
99 | + for (T data : dataList) { | |
100 | + row = sheet.createRow(rowIndex++); | |
101 | + columnIndex = 0; | |
102 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
103 | + Cell cell = row.createCell(columnIndex++); | |
104 | + Field field = SuperClassReflectionUtil.getField(data.getClass(), (dataFieldName)); | |
105 | + field.setAccessible(true); | |
106 | + Object cellValue = field.get(data); | |
107 | + field.setAccessible(false); | |
108 | + setCellValue(cell, cellValue); | |
109 | + } | |
110 | + } | |
111 | + | |
112 | + return rowIndex; | |
113 | + } | |
114 | + | |
115 | + // 세로형 가로 적재 테이블 그리기 | |
116 | + public int createVH(ExcelRenderResource resource, List<T> dataList, int rowIndex) throws NoSuchFieldException, IllegalAccessException { | |
117 | + for (T data : dataList) { | |
118 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
119 | + // tr | |
120 | + Row row = sheet.createRow(rowIndex++); | |
121 | + | |
122 | + int columnIndex = 0; | |
123 | + | |
124 | + // th | |
125 | + Cell cell = row.createCell(columnIndex++); | |
126 | + String value = resource.getExcelHeaderName(dataFieldName); | |
127 | + cell.setCellValue(value); | |
128 | + cell.setCellStyle(theadStyle()); | |
129 | + | |
130 | + // td | |
131 | + cell = row.createCell(columnIndex++); | |
132 | + Field field = SuperClassReflectionUtil.getField(data.getClass(), (dataFieldName)); | |
133 | + field.setAccessible(true); | |
134 | + Object cellValue = field.get(data); | |
135 | + field.setAccessible(false); | |
136 | + setCellValue(cell, cellValue); | |
137 | + } | |
138 | + } | |
139 | + | |
140 | + return rowIndex; | |
141 | + } | |
142 | + | |
143 | + // 구분선 | |
144 | + public int createHr(int rowIndex) { | |
145 | + // tr | |
146 | + Row row = sheet.createRow(rowIndex++); | |
147 | + Cell cell = row.createCell(0); | |
148 | + setCellValue(cell, " "); | |
149 | + cell.setCellStyle(emptyStyle()); | |
150 | + return rowIndex; | |
151 | + } | |
152 | + | |
153 | + // 제목 | |
154 | + public int createCaption(int rowIndex, String caption) { | |
155 | + // tr | |
156 | + Row row = sheet.createRow(rowIndex++); | |
157 | + Cell cell = row.createCell(0); | |
158 | + setCellValue(cell, caption); | |
159 | + cell.setCellStyle(emptyStyle()); | |
160 | + return rowIndex; | |
161 | + } | |
162 | + | |
163 | + // 셀 내 데이터 입력 | |
164 | + private void setCellValue(Cell cell, Object cellValue) { | |
165 | + if (cellValue instanceof Number) { | |
166 | + Number numberValue = (Number) cellValue; | |
167 | + cell.setCellValue(numberValue.doubleValue()); | |
168 | + cell.setCellStyle(tbodyStyle()); | |
169 | + return; | |
170 | + } | |
171 | + cell.setCellValue(ObjectUtils.isEmpty(cellValue) ? "" : String.valueOf(cellValue)); | |
172 | + cell.setCellStyle(tbodyStyle()); | |
173 | + } | |
174 | + | |
175 | + /** | |
176 | + * @author 박정하 | |
177 | + * @since 2024.03.28 | |
178 | + * | |
179 | + * 차트 이미지 넣기 | |
180 | + */ | |
181 | + public void chartDraw(Sheet sheet, String chart, int rowNum, int cellNum) { | |
182 | + if (chart != null && chart.equals("")) { | |
183 | + InputStream in = null; | |
184 | + FileOutputStream fos = null; | |
185 | + File imageFile = null; | |
186 | + | |
187 | + try { | |
188 | + String encodingStr = chart.replace(BASE64_PNG_PRE_FIX, ""); | |
189 | + | |
190 | + Base64.Decoder decoder = Base64.getDecoder(); | |
191 | + byte[] decodeImg = decoder.decode(encodingStr); | |
192 | + | |
193 | + String uploadPath = Paths.get("C:", "upload-files").toString(); | |
194 | + File dir = new File(uploadPath); | |
195 | + if (dir.exists() == false) { | |
196 | + dir.mkdirs(); | |
197 | + } | |
198 | + uploadPath = dir.getPath(); | |
199 | + | |
200 | + imageFile = new File(uploadPath + "/chartImg.png"); | |
201 | + fos = new FileOutputStream(imageFile); | |
202 | + fos.write(decodeImg); | |
203 | + | |
204 | + in = new FileInputStream(imageFile); | |
205 | + byte[] bytes = IOUtils.toByteArray(in); | |
206 | + int pictureIdx = workbook.addPicture(bytes, SXSSFWorkbook.PICTURE_TYPE_PNG); | |
207 | + | |
208 | + final CreationHelper helper = workbook.getCreationHelper(); | |
209 | + final Drawing drawing = sheet.createDrawingPatriarch(); | |
210 | + final ClientAnchor anchor = helper.createClientAnchor(); | |
211 | + | |
212 | + // 이미지를 출력할 CELL 위치 선정 | |
213 | + anchor.setCol1(cellNum++); | |
214 | + anchor.setRow1(rowNum++); | |
215 | + | |
216 | + // 이미지 그리기 | |
217 | + final Picture pict = drawing.createPicture(anchor, pictureIdx); | |
218 | + pict.resize(); // 이미지 사이즈 비율 설정 | |
219 | + rowNum = rowNum + 20; | |
220 | + } catch(Exception e) { | |
221 | + e.printStackTrace(); | |
222 | + } finally { | |
223 | + IOUtils.closeQuietly(in); | |
224 | + IOUtils.closeQuietly(fos); | |
225 | + imageFile.delete(); | |
226 | + } | |
227 | + } | |
228 | + } | |
229 | + | |
230 | + // 세로 적재 테이블 그리기 (기업정보용) | |
231 | + public int createVerticalByEntInfo(ExcelRenderResource resource, List<T> dataList, int rowIndex) throws NoSuchFieldException, IllegalAccessException { | |
232 | + String isIvstDscsn = null; | |
233 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
234 | + if (dataFieldName!= "isIvstDscsn" && dataFieldName != "mvnInten" && dataFieldName != "mouInten" && dataFieldName != "rmrk") { | |
235 | + rowIndex = createTableByEntInfo(resource, rowIndex, dataFieldName); | |
236 | + } | |
237 | + } | |
238 | + | |
239 | + rowIndex = createHr(rowIndex); // 구분선 | |
240 | + rowIndex = createCaption(rowIndex, "세부정보"); | |
241 | + | |
242 | + Field field = SuperClassReflectionUtil.getField(dataList.get(0).getClass(), ("isIvstDscsn")); | |
243 | + field.setAccessible(true); | |
244 | + isIvstDscsn = field.get(dataList.get(0)).toString(); | |
245 | + field.setAccessible(false); | |
246 | + | |
247 | + rowIndex = createTableByEntInfo(resource, rowIndex, "isIvstDscsn"); | |
248 | + if (isIvstDscsn == "Y") { | |
249 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
250 | + if (dataFieldName == "mvnInten" || dataFieldName == "mouInten") { | |
251 | + rowIndex = createTableByEntInfo(resource, rowIndex, dataFieldName); | |
252 | + } | |
253 | + } | |
254 | + } | |
255 | + rowIndex = createTableByEntInfo(resource, rowIndex, "rmrk"); | |
256 | + | |
257 | + return rowIndex; | |
258 | + } | |
259 | + // 테이블 그리기 | |
260 | + private int createTableByEntInfo(ExcelRenderResource resource, int rowIndex, String dataFieldName) throws NoSuchFieldException, IllegalAccessException { | |
261 | + // tr | |
262 | + Row row = sheet.createRow(rowIndex++); | |
263 | + // th | |
264 | + Cell cell = row.createCell(0); | |
265 | + String value = resource.getExcelHeaderName(dataFieldName); | |
266 | + cell.setCellValue(value); | |
267 | + cell.setCellStyle(theadStyle()); | |
268 | + // td | |
269 | + cell = row.createCell(1); | |
270 | + Field field = SuperClassReflectionUtil.getField(dataList.get(0).getClass(), (dataFieldName)); | |
271 | + field.setAccessible(true); | |
272 | + Object cellValue = field.get(dataList.get(0)); | |
273 | + field.setAccessible(false); | |
274 | + setCellValue(cell, cellValue); | |
275 | + return rowIndex; | |
276 | + } | |
277 | + | |
278 | + // 기업정보 전체 테이블 그리기 (기업정보용) | |
279 | + public int createByEntInfoAll(ExcelRenderResource resource, List<T> dataList, int rowIndex) throws NoSuchFieldException, IllegalAccessException { | |
280 | + // tr | |
281 | + Row row = sheet.createRow(rowIndex++); | |
282 | + | |
283 | + // th | |
284 | + int columnIndex = 0; | |
285 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
286 | + Cell cell = row.createCell(columnIndex++); | |
287 | + String value = resource.getExcelHeaderName(dataFieldName); | |
288 | + cell.setCellValue(value); | |
289 | + cell.setCellStyle(theadStyle()); | |
290 | + } | |
291 | + | |
292 | + // td | |
293 | + for (T data : dataList) { | |
294 | + row = sheet.createRow(rowIndex++); | |
295 | + columnIndex = 0; | |
296 | + | |
297 | + for (String dataFieldName : resource.getDataFieldNames()) { | |
298 | + Cell cell = row.createCell(columnIndex++); | |
299 | + Field field = SuperClassReflectionUtil.getField(data.getClass(), (dataFieldName)); | |
300 | + field.setAccessible(true); | |
301 | + Object cellValue = field.get(data); | |
302 | + field.setAccessible(false); | |
303 | + setCellValue(cell, cellValue); | |
304 | + } | |
305 | + } | |
306 | + | |
307 | + return rowIndex; | |
308 | + } | |
309 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/excel/service/ExcelService.java
... | ... | @@ -0,0 +1,19 @@ |
1 | +package com.takensoft.common.excel.service; | |
2 | + | |
3 | +import com.takensoft.cms.cntnStats.dto.CntnStatsExcelDTO; | |
4 | +import com.takensoft.portal.entInfo.dto.BplcExcelDTO; | |
5 | +import com.takensoft.portal.entInfo.dto.EntInfoExcelDTO; | |
6 | +import com.takensoft.portal.ivstDscsn.dto.IvstDscsnExcelDTO; | |
7 | +import com.takensoft.portal.rvwMttr.dto.RvwMttrExcelDTO; | |
8 | +import com.takensoft.portal.rvwMttr.dto.RvwMttrPrgrsExcelDTO; | |
9 | + | |
10 | +import javax.servlet.http.HttpServletResponse; | |
11 | +import java.util.List; | |
12 | + | |
13 | +public interface ExcelService { | |
14 | + public void ivstDscsnExcelDownload(HttpServletResponse response, IvstDscsnExcelDTO ivstDscsn) throws Exception; | |
15 | + public void rvwMttrExcelDownload(HttpServletResponse response, RvwMttrExcelDTO rvwMttr, List<RvwMttrPrgrsExcelDTO> prgrsList) throws Exception; | |
16 | + public void entInfoExcelDownload(HttpServletResponse response, EntInfoExcelDTO entInfo, List<BplcExcelDTO> bplcList) throws Exception; | |
17 | + public void cntnStatsExcelDownload(HttpServletResponse response, List<CntnStatsExcelDTO> cntnStats, String chart) throws Exception; | |
18 | + public void entInfoExcelDownloadAll(HttpServletResponse response, List<EntInfoExcelDTO> entInfoList) throws Exception; | |
19 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/excel/service/Impl/ExcelServiceImpl.java
... | ... | @@ -0,0 +1,180 @@ |
1 | +package com.takensoft.common.excel.service.Impl; | |
2 | + | |
3 | +import com.takensoft.cms.cntnStats.dto.CntnStatsExcelDTO; | |
4 | +import com.takensoft.common.excel.resource.ExcelRenderResource; | |
5 | +import com.takensoft.common.excel.resource.ExcelRenderResourceFactory; | |
6 | +import com.takensoft.common.excel.service.ExcelCreateService; | |
7 | +import com.takensoft.common.excel.service.ExcelService; | |
8 | +import com.takensoft.portal.entInfo.dto.BplcExcelDTO; | |
9 | +import com.takensoft.portal.entInfo.dto.EntInfoExcelDTO; | |
10 | +import com.takensoft.portal.ivstDscsn.dto.IvstDscsnExcelDTO; | |
11 | +import com.takensoft.portal.rvwMttr.dto.RvwMttrExcelDTO; | |
12 | +import com.takensoft.portal.rvwMttr.dto.RvwMttrPrgrsExcelDTO; | |
13 | +import lombok.RequiredArgsConstructor; | |
14 | +import org.apache.poi.ss.usermodel.Sheet; | |
15 | +import org.apache.poi.ss.usermodel.Workbook; | |
16 | +import org.apache.poi.xssf.streaming.SXSSFSheet; | |
17 | +import org.apache.poi.xssf.streaming.SXSSFWorkbook; | |
18 | +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; | |
19 | +import org.springframework.http.HttpHeaders; | |
20 | +import org.springframework.stereotype.Service; | |
21 | + | |
22 | +import javax.servlet.http.HttpServletResponse; | |
23 | +import java.io.IOException; | |
24 | +import java.nio.charset.StandardCharsets; | |
25 | +import java.util.*; | |
26 | + | |
27 | +@Service("excelService") | |
28 | +@RequiredArgsConstructor | |
29 | +public class ExcelServiceImpl extends EgovAbstractServiceImpl implements ExcelService { | |
30 | + // 엑셀 파일 출력 | |
31 | + public static void writeExcel(HttpServletResponse response, Workbook workbook, ExcelRenderResource resource) throws IOException { | |
32 | + String fileName = new String(resource.getExcelFileName().getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); | |
33 | + response.setContentType("ms-vnd/excel"); | |
34 | + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=" + fileName + ".xlsx")); | |
35 | + workbook.write(response.getOutputStream()); | |
36 | + workbook.close(); | |
37 | + } | |
38 | + | |
39 | + // 투자상담 | |
40 | + @Override | |
41 | + public void ivstDscsnExcelDownload(HttpServletResponse response, IvstDscsnExcelDTO ivstDscsn) throws Exception { | |
42 | + // 기본 세팅 | |
43 | + Workbook workbook = new SXSSFWorkbook(); | |
44 | + Sheet sheet = workbook.createSheet(); | |
45 | + int rowIndex = 0; | |
46 | + | |
47 | + // 개별 설정 | |
48 | + ExcelRenderResource mainResource = ExcelRenderResourceFactory.prepareRenderResource(IvstDscsnExcelDTO.class); | |
49 | + List<IvstDscsnExcelDTO> mainDataList = new ArrayList<>(); | |
50 | + mainDataList.add(ivstDscsn); | |
51 | + | |
52 | + // 엑셀 그리기 | |
53 | + ExcelCreateService<IvstDscsnExcelDTO> mainExcel = new ExcelCreateService(workbook, sheet, mainDataList, mainDataList.getClass()); | |
54 | + mainExcel.createVertical(mainResource, mainDataList, rowIndex); | |
55 | + | |
56 | + // 엑셀 사이즈 지정 | |
57 | + sheetSize(sheet, 2); | |
58 | + | |
59 | + // 엑셀 파일 출력 | |
60 | + writeExcel(response, workbook, mainResource); | |
61 | + } | |
62 | + | |
63 | + // 검토사항 | |
64 | + @Override | |
65 | + public void rvwMttrExcelDownload(HttpServletResponse response, RvwMttrExcelDTO rvwMttr, List<RvwMttrPrgrsExcelDTO> prgrsList) throws Exception { | |
66 | + // 기본 세팅 | |
67 | + Workbook workbook = new SXSSFWorkbook(); | |
68 | + Sheet sheet = workbook.createSheet(); | |
69 | + int rowIndex = 0; | |
70 | + | |
71 | + // 개별 설정 | |
72 | + ExcelRenderResource mainResource = ExcelRenderResourceFactory.prepareRenderResource(RvwMttrExcelDTO.class); | |
73 | + List<RvwMttrExcelDTO> mainDataList = new ArrayList<>(); | |
74 | + mainDataList.add(rvwMttr); | |
75 | + | |
76 | + ExcelRenderResource prgrsResource = ExcelRenderResourceFactory.prepareRenderResource(RvwMttrPrgrsExcelDTO.class); | |
77 | + | |
78 | + // 엑셀 그리기 | |
79 | + ExcelCreateService<RvwMttrExcelDTO> mainExcel = new ExcelCreateService(workbook, sheet, mainDataList, mainDataList.getClass()); | |
80 | + rowIndex = mainExcel.createCaption(rowIndex, "기본정보"); | |
81 | + rowIndex = mainExcel.createVertical(mainResource, mainDataList, rowIndex); | |
82 | + | |
83 | + rowIndex = mainExcel.createHr(rowIndex); // 구분선 | |
84 | + rowIndex = mainExcel.createCaption(rowIndex, "진행단계 및 지원방안"); | |
85 | + ExcelCreateService<RvwMttrPrgrsExcelDTO> prgrsExcel = new ExcelCreateService(workbook, sheet, prgrsList, prgrsList.getClass()); | |
86 | + rowIndex = prgrsExcel.createVH(prgrsResource, prgrsList, rowIndex); | |
87 | + | |
88 | + // 엑셀 사이즈 지정 | |
89 | + sheetSize(sheet, 2); | |
90 | + | |
91 | + // 엑셀 파일 출력 | |
92 | + writeExcel(response, workbook, mainResource); | |
93 | + } | |
94 | + | |
95 | + // 기업정보 | |
96 | + @Override | |
97 | + public void entInfoExcelDownload(HttpServletResponse response, EntInfoExcelDTO entInfo, List<BplcExcelDTO> bplcList) throws Exception { | |
98 | + // 기본 세팅 | |
99 | + Workbook workbook = new SXSSFWorkbook(); | |
100 | + Sheet sheet = workbook.createSheet(); | |
101 | + int rowIndex = 0; | |
102 | + | |
103 | + // 개별 설정 | |
104 | + ExcelRenderResource mainResource = ExcelRenderResourceFactory.prepareRenderResource(EntInfoExcelDTO.class); | |
105 | + List<EntInfoExcelDTO> mainDataList = new ArrayList<>(); | |
106 | + mainDataList.add(entInfo); | |
107 | + | |
108 | + ExcelRenderResource bplcResource = ExcelRenderResourceFactory.prepareRenderResource(BplcExcelDTO.class); | |
109 | + | |
110 | + // 엑셀 그리기 | |
111 | + ExcelCreateService<EntInfoExcelDTO> mainExcel = new ExcelCreateService(workbook, sheet, mainDataList, mainDataList.getClass()); | |
112 | + rowIndex = mainExcel.createCaption(rowIndex, "기본정보"); | |
113 | + rowIndex = mainExcel.createVerticalByEntInfo(mainResource, mainDataList, rowIndex); | |
114 | + | |
115 | + rowIndex = mainExcel.createHr(rowIndex); // 구분선 | |
116 | + rowIndex = mainExcel.createCaption(rowIndex, "주요사업장"); | |
117 | + ExcelCreateService<BplcExcelDTO> bplcExcel = new ExcelCreateService(workbook, sheet, bplcList, bplcList.getClass()); | |
118 | + bplcExcel.createVertical(bplcResource, bplcList, rowIndex); | |
119 | + | |
120 | + // 엑셀 사이즈 지정 | |
121 | + sheetSize(sheet, 2); | |
122 | + | |
123 | + // 엑셀 파일 출력 | |
124 | + writeExcel(response, workbook, mainResource); | |
125 | + } | |
126 | + | |
127 | + // 통계관리 | |
128 | + @Override | |
129 | + public void cntnStatsExcelDownload(HttpServletResponse response, List<CntnStatsExcelDTO> mainDataList, String chart) throws Exception { | |
130 | + // 기본 세팅 | |
131 | + Workbook workbook = new SXSSFWorkbook(); | |
132 | + Sheet sheet = workbook.createSheet(); | |
133 | + int rowIndex = 0; | |
134 | + | |
135 | + // 개별 설정 | |
136 | + ExcelRenderResource mainResource = ExcelRenderResourceFactory.prepareRenderResource(CntnStatsExcelDTO.class); | |
137 | + | |
138 | + // 엑셀 그리기 | |
139 | + ExcelCreateService<CntnStatsExcelDTO> mainExcel = new ExcelCreateService(workbook, sheet, mainDataList, mainDataList.getClass()); | |
140 | + mainExcel.chartDraw(sheet, chart, rowIndex, mainResource.getDataFieldNames().size() + 1); | |
141 | + rowIndex = mainExcel.createHorizontal(mainResource, mainDataList, rowIndex); | |
142 | + | |
143 | + // 엑셀 사이즈 지정 | |
144 | + int cellNumber = mainResource.getDataFieldNames().size(); | |
145 | + sheetSize(sheet, cellNumber); | |
146 | + | |
147 | + // 엑셀 파일 출력 | |
148 | + writeExcel(response, workbook, mainResource); | |
149 | + } | |
150 | + | |
151 | + // 기업정보 전체 다운로드 | |
152 | + public void entInfoExcelDownloadAll(HttpServletResponse response, List<EntInfoExcelDTO> mainDataList) throws Exception { | |
153 | + // 기본 세팅 | |
154 | + Workbook workbook = new SXSSFWorkbook(); | |
155 | + Sheet sheet = workbook.createSheet(); | |
156 | + int rowIndex = 0; | |
157 | + | |
158 | + // 개별 설정 | |
159 | + ExcelRenderResource mainResource = ExcelRenderResourceFactory.prepareRenderResource(EntInfoExcelDTO.class); | |
160 | + | |
161 | + // 엑셀 그리기 | |
162 | + ExcelCreateService<EntInfoExcelDTO> mainExcel = new ExcelCreateService(workbook, sheet, mainDataList, mainDataList.getClass()); | |
163 | + mainExcel.createByEntInfoAll(mainResource, mainDataList, rowIndex); | |
164 | + | |
165 | + // 엑셀 사이즈 지정 | |
166 | + int cellNumber = mainResource.getDataFieldNames().size(); | |
167 | + sheetSize(sheet, cellNumber); | |
168 | + | |
169 | + // 엑셀 파일 출력 | |
170 | + writeExcel(response, workbook, mainResource); | |
171 | + } | |
172 | + | |
173 | + public void sheetSize(Sheet sheet, int cellNumber){ | |
174 | + ((SXSSFSheet)sheet).trackAllColumnsForAutoSizing(); | |
175 | + for(int k = 0 ; k < cellNumber + 1; k++){ | |
176 | + sheet.autoSizeColumn(k); | |
177 | + sheet.setColumnWidth(k, Math.min(150*150, sheet.getColumnWidth(k) + 1024)); | |
178 | + } | |
179 | + } | |
180 | +}(파일 끝에 줄바꿈 문자 없음) |
+++ src/main/java/com/takensoft/common/excel/util/SuperClassReflectionUtil.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/exception/IdDuplicationException.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/dao/FileDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/dao/FileMngDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/service/FileMngService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/service/FileService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/service/Impl/FileMngServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/vo/FileMngVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/vo/FileVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/file/web/FileController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/filter/AccesFilter.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/filter/JWTFilter.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/filter/LoginFilter.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/idgen/context/ContextIdgen.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/idgen/dao/IdgenMapper.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/idgen/service/IdgenService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/idgen/vo/IdgenVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/CommonUtils.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/CustomAccessDenieHandler.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/CustomAuthenticationEntryPoint.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/ErrorResponse.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/JWTUtil.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/KISA_SEED_CBC.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/ResponseData.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/common/util/Secret.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entDscsnAply/dao/EntDscsnAplyDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entDscsnAply/service/EntDscsnAplyService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entDscsnAply/service/Impl/EntDscsnAplyServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entDscsnAply/vo/EntDscsnAplyVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entDscsnAply/web/EntDscsnAplyController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/dao/BplcDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/dao/EntInfoDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/dto/BplcExcelDTO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/dto/EntInfoExcelDTO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/service/BplcService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/service/EntInfoService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/service/Impl/BplcServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/service/Impl/EntInfoServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/vo/BplcVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/vo/EntInfoVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/entInfo/web/EntInfoController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/ivstDscsn/dao/IvstDscsnDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/ivstDscsn/dto/IvstDscsnExcelDTO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/ivstDscsn/service/Impl/IvstDscsnServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/ivstDscsn/service/IvstDscsnService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/ivstDscsn/vo/IvstDscsnVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/ivstDscsn/web/IvstDscsnController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/main/dao/GovernmentMainDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/main/service/GovernmentMainService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/main/service/impl/GovernmentMainServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/main/web/GovernmentMainController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/dao/RvwMttrDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/dao/RvwMttrPrgrsDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/dto/RvwMttrExcelDTO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/dto/RvwMttrPrgrsExcelDTO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/service/Impl/RvwMttrPrgrsServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/service/Impl/RvwMttrServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/service/RvwMttrPrgrsService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/service/RvwMttrService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/vo/RvwMttrPrgrsVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/vo/RvwMttrVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/rvwMttr/web/RvwMttrController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/statistics/dao/StatisticsDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/statistics/service/Impl/StatisticsServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/statistics/service/StatisticsService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/portal/statistics/web/StatisticsController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/ums/dao/UmsDAO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/ums/service/Impl/UmsServiceImpl.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/ums/service/UmsService.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/ums/vo/UmsVO.java
This diff is skipped because there are too many other diffs. |
+++ src/main/java/com/takensoft/ums/web/UmsController.java
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/application.yml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/log4jdbc.log4j2.properties
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper-ora/ums/ums-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/accesCtrl/accesCtrl-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/bbs/bbsCn-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/bbs/bbsMng-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/bbs/bbsRouter-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/bbs/bbsTypeMng-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/bbs/cmnt-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/bbs/search-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/bbs/wordMng-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/cntnStats/cntnStats-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/codeManage/codeManage-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/common/Idgen-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/common/file-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/common/fileManage-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/contsType/contsType-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/dept/dept-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/entDscsnAply/entDscsnAply-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/entInfo/bplc-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/entInfo/entInfo-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/invtDscsn/invtDscsn-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/main/adminMain-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/main/governmentMain-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/mber/admMbr-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/mber/lgnHstry-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/mber/mber-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/mber/refresh-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/popup/popup-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/prvcInqHstry/prvcInqHstry-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/rvwMttr/rvwMttr-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/rvwMttr/rvwMttrPrgrs-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/resources/mybatis/mapper/statistics/statistics-SQL.xml
This diff is skipped because there are too many other diffs. |
+++ src/main/webapp/META-INF/MANIFEST.MF
This diff is skipped because there are too many other diffs. |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?