- Home
- - 사이트관리
- - 기본 코드 관리
+ - 사이트관리
+ - 환경설정
+ - 기본 코드 관리
@@ -33,10 +41,10 @@ function BaseCodeMgt(props) {
-
+
-
+
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ChildCodeDiv.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ChildCodeDiv.jsx
index 8337b7c..ac43fd0 100644
--- a/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ChildCodeDiv.jsx
+++ b/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ChildCodeDiv.jsx
@@ -1,30 +1,74 @@
+import React, {useState, useImperativeHandle, forwardRef} from "react";
+import * as EgovNet from "api/egovFetch";
import {Container} from "react-bootstrap";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Form from 'react-bootstrap/Form'
import Button from "react-bootstrap/Button";
-function ChildCodeDiv(){
+function ChildCodeDiv({}, ref){
+
+ const [codeItemRow, setCodeItemRow] = useState();
+ const [grpCd, setGrpCd] = useState();
+
+ useImperativeHandle(ref, ()=>({
+ getCodeItemList
+ }))
+ async function getCodeItemList(parentCd){
+ setCodeItemRow([]);
+ setGrpCd(parentCd)
+ EgovNet.requestFetch(
+ '/admin/config/code-item?grpCd='+parentCd,
+ {
+ method: "GET"
+ },
+ (resp) => {
+ const codeItemList = resp.result.codeItemList;
+ const itemTag = [];
+ codeItemList.forEach(function (item, index){
+ itemTag.push(
+
+
+
+
+
+
+ )
+ })
+ setCodeItemRow(itemTag);
+ },
+ function (resp) {
+ console.log("err response : ", resp);
+ }
+ );
+ }
+
return (
- 코드
- 코드명
+ 코드
+ 코드명
삭제
수정
- {}
-
-
-
-
-
-
-
-
-
+ {codeItemRow}
+ {grpCd!=null?(
+
+
+
+
+
+
+
+
+
+ ):(
+
+ 코드 그룹을 선택해주세요.
+
+ )}
);
}
-export default ChildCodeDiv;
\ No newline at end of file
+export default forwardRef(ChildCodeDiv);
\ No newline at end of file
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ParentCodeDiv.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ParentCodeDiv.jsx
index ea01938..efe0710 100644
--- a/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ParentCodeDiv.jsx
+++ b/egovframe-template-simple-react-contribution/src/pages/admin/config/baseCode/ParentCodeDiv.jsx
@@ -1,55 +1,102 @@
import React, { useState, useEffect, useCallback } from 'react';
+import * as EgovNet from "api/egovFetch";
import {Container} from "react-bootstrap";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Form from 'react-bootstrap/Form'
import Button from "react-bootstrap/Button";
-import * as EgovNet from "api/egovFetch";
+import { FaRegHandPointRight } from "react-icons/fa";
-function ParentCodeDiv(props){
+function ParentCodeDiv({getCodeItem}){
const [codeGrpRow, setCodeGrpRow] = useState();
- function getCodeGrp(){
+ const getCodeGrp = useCallback(()=>{
EgovNet.requestFetch(
'/admin/config/code-grp',
{
- method: "GET",
- headers: {
- 'Content-type': 'application/json'
- },
- body: JSON.stringify({})
+ method: "GET"
},
(resp) => {
- debugger
+ const codeGrpList = resp.result.codeGrpList;
+ const grpTag = [];
+ codeGrpList.forEach(function (item, index){
+ grpTag.push(
+
+
+
+ {codeGrpChoose(e, item.grpCd)}} data-grpcd={item.grpCd}>{item.grpCd}
+
+
+
+
+
+ )
+ })
+ setCodeGrpRow(grpTag);
},
function (resp) {
console.log("err response : ", resp);
}
);
- }
+ });
useEffect(() => {
getCodeGrp();
}, []);
+ function codeGrpChoose(e, grpCd){
+ document.querySelectorAll(".selectIcon").forEach(function (item){
+ item.classList.value = 'selectIcon d-none'
+ })
+ e.target.parentElement.querySelector(".selectIcon").classList.value = "selectIcon"
+ getCodeItem(grpCd)
+ }
+
+ function addCodeGrp(){
+ const grpCd = document.querySelector("#grpCd");
+ const grpCdNm = document.querySelector("#grpCdNm");
+ EgovNet.requestFetch(
+ '/admin/config/code-grp',
+ {
+ method: "POST",
+ headers: {
+ 'Content-type': 'application/json'
+ },
+ body: JSON.stringify({
+ grpCd: grpCd.value,
+ grpCdNm: grpCdNm.value
+ })
+ },
+ (resp) => {
+ grpCd.value = "";
+ grpCdNm.value = "";
+ getCodeGrp();
+ },
+ function (resp) {
+ console.log("err response : ", resp);
+ }
+ );
+
+ }
+
return (
-
+
- 코드그룹
- 코드그룹명
+ 코드그룹
+ 코드그룹명
삭제
수정
{codeGrpRow}
-
-
+
+
-
-
+
+
-
+
);
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java
index abbe984..c6a6e35 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java
@@ -2,6 +2,7 @@ package com.dbnt.kcscbackend.admin.config;
import com.dbnt.kcscbackend.admin.config.entity.TcCodeGrp;
import com.dbnt.kcscbackend.admin.config.service.AdminConfigService;
+import com.dbnt.kcscbackend.auth.entity.LoginVO;
import com.dbnt.kcscbackend.config.common.BaseController;
import com.dbnt.kcscbackend.config.common.ResultVO;
import io.swagger.v3.oas.annotations.Operation;
@@ -10,6 +11,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@@ -34,7 +37,7 @@ public class AdminConfigController extends BaseController {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
- @RequestMapping(method = RequestMethod.GET, value = "/code-grp", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @RequestMapping(method = RequestMethod.GET, value = "/code-grp")
public ResultVO getCodeGrp() throws Exception{
ResultVO resultVO = new ResultVO();
Map resultMap = new HashMap<>();
@@ -52,12 +55,41 @@ public class AdminConfigController extends BaseController {
@ApiResponse(responseCode = "200", description = "조회 성공"),
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
})
- @RequestMapping(method = RequestMethod.GET, value = "/code-item", consumes = MediaType.APPLICATION_JSON_VALUE)
- public ResultVO getCodeItem(TcCodeGrp param) throws Exception{
+ @RequestMapping(method = RequestMethod.GET, value = "/code-item")
+ public ResultVO getCodeItem(String grpCd) throws Exception{
ResultVO resultVO = new ResultVO();
Map resultMap = new HashMap<>();
- resultMap.put("codeItemList", adminConfigService.selectCodeItemList(param.getGrpCd()));
+ resultMap.put("codeItemList", adminConfigService.selectCodeItemList(grpCd));
resultVO.setResult(resultMap);
return resultVO;
}
+
+ @Operation(
+ summary = "기본코드 그룹 저장",
+ description = "기본코드 그룹 저장",
+ tags = {"AdminConfigController"}
+ )
+ @ApiResponses(value = {
+ @ApiResponse(responseCode = "200", description = "저장 성공"),
+ @ApiResponse(responseCode = "303", description = "만료된 토큰"),
+ @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
+ })
+ @RequestMapping(method = RequestMethod.POST, value = "/code-grp", consumes = MediaType.APPLICATION_JSON_VALUE)
+ public ResultVO addCodeGrp(@RequestBody TcCodeGrp codeGrp, @AuthenticationPrincipal LoginVO user) throws Exception{
+ ResultVO resultVO = new ResultVO();
+ if(user == null){
+ resultVO.setResultCode(303);
+ }else{
+ if(!user.getUserSe().equals("ADM")){
+ resultVO.setResultCode(403);
+ }else{
+ Map resultMap = new HashMap<>();
+ adminConfigService.addCodeGrp(codeGrp);
+ //resultMap.put("codeGrpList", );
+ resultVO.setResult(resultMap);
+ resultVO.setResultCode(200);
+ }
+ }
+ return resultVO;
+ }
}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminConfigService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminConfigService.java
index d7833d0..1198576 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminConfigService.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/AdminConfigService.java
@@ -8,6 +8,7 @@ import com.dbnt.kcscbackend.admin.config.repository.TcCodeItemRepository;
import lombok.RequiredArgsConstructor;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -26,4 +27,9 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
public List selectCodeItemList(String grpCd){
return codeItemRepository.findByGrpCdOrderByGrpOrder(grpCd);
}
+
+ @Transactional
+ public void addCodeGrp(TcCodeGrp codeGrp) {
+ codeGrpRepository.save(codeGrp);
+ }
}