기본코드관리 작업중.
parent
eee0b471bf
commit
021f61f126
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, {useRef} from 'react';
|
||||||
import CODE from "../../../constants/code";
|
import CODE from "../../../constants/code";
|
||||||
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
||||||
import {Link} from "react-router-dom";
|
import {Link} from "react-router-dom";
|
||||||
|
|
@ -11,14 +11,22 @@ import ChildCodeDiv from "./baseCode/ChildCodeDiv";
|
||||||
|
|
||||||
function BaseCodeMgt(props) {
|
function BaseCodeMgt(props) {
|
||||||
|
|
||||||
|
// ParentCodeDiv에서 ChildCodeDiv로 함수 호출 참고자료
|
||||||
|
// https://velog.io/@hssarah/React%EC%97%90%EC%84%9C-%EB%8B%A4%EB%A5%B8-Function-Component%EC%97%90-%EC%9E%88%EB%8A%94-%ED%95%A8%EC%88%98-%ED%98%B8%EC%B6%9C-React-Calling-Function-From-Another-Function-Component
|
||||||
|
|
||||||
|
const childRef = useRef(null);
|
||||||
|
function getCodeItem(grpCd){
|
||||||
|
childRef.current.getCodeItemList(grpCd);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="c_wrap">
|
<div className="c_wrap">
|
||||||
<div className="location">
|
<div className="location">
|
||||||
<ul>
|
<ul>
|
||||||
<li><Link to={URL.MAIN} className="home">Home</Link></li>
|
<li><Link to={URL.MAIN} className="home">Home</Link></li>
|
||||||
<li><Link to={URL.ADMIN}>사이트관리</Link></li>
|
<li>사이트관리</li>
|
||||||
<li>기본 코드 관리</li>
|
<li>환경설정</li>
|
||||||
|
<li><Link to={URL.ADMIN_BASE_CODE}>기본 코드 관리</Link></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div className="layout">
|
<div className="layout">
|
||||||
|
|
@ -33,10 +41,10 @@ function BaseCodeMgt(props) {
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={"6"}>
|
<Col xs={"6"}>
|
||||||
<ParentCodeDiv/>
|
<ParentCodeDiv getCodeItem={getCodeItem}/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={"6"}>
|
<Col xs={"6"}>
|
||||||
<ChildCodeDiv/>
|
<ChildCodeDiv ref={childRef}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,74 @@
|
||||||
|
import React, {useState, useImperativeHandle, forwardRef} from "react";
|
||||||
|
import * as EgovNet from "api/egovFetch";
|
||||||
import {Container} from "react-bootstrap";
|
import {Container} from "react-bootstrap";
|
||||||
import Row from "react-bootstrap/Row";
|
import Row from "react-bootstrap/Row";
|
||||||
import Col from "react-bootstrap/Col";
|
import Col from "react-bootstrap/Col";
|
||||||
import Form from 'react-bootstrap/Form'
|
import Form from 'react-bootstrap/Form'
|
||||||
import Button from "react-bootstrap/Button";
|
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(
|
||||||
|
<Row className={"py-2 border-bottom"}>
|
||||||
|
<Col xs={3}><Form.Control type={"text"} size={"sm"} defaultValue={item.itemCd}/></Col>
|
||||||
|
<Col xs={5}><Form.Control type={"text"} size={"sm"} defaultValue={item.itemNm}/></Col>
|
||||||
|
<Col xs={2}><Button variant={"danger"} size={"sm"}>삭제</Button></Col>
|
||||||
|
<Col xs={2}><Button variant={"primary"} size={"sm"}>수정</Button></Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
setCodeItemRow(itemTag);
|
||||||
|
},
|
||||||
|
function (resp) {
|
||||||
|
console.log("err response : ", resp);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className={"pt-3"}>
|
<Container className={"pt-3"}>
|
||||||
<Row className={"py-2 bg-light border-bottom"}>
|
<Row className={"py-2 bg-light border-bottom"}>
|
||||||
<Col xs={4}>코드</Col>
|
<Col xs={3}>코드</Col>
|
||||||
<Col xs={4}>코드명</Col>
|
<Col xs={5}>코드명</Col>
|
||||||
<Col xs={2}>삭제</Col>
|
<Col xs={2}>삭제</Col>
|
||||||
<Col xs={2}>수정</Col>
|
<Col xs={2}>수정</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{}
|
{codeItemRow}
|
||||||
<Row className={"py-1"}>
|
{grpCd!=null?(
|
||||||
<Col xs={4}>
|
<Row className={"py-1"}>
|
||||||
<Form.Control type={"text"} placeholder={"코드"} size={"sm"}/>
|
<Col xs={3}>
|
||||||
</Col>
|
<Form.Control type={"text"} placeholder={"코드"} size={"sm"}/>
|
||||||
<Col xs={4}>
|
</Col>
|
||||||
<Form.Control type={"text"} placeholder={"코드명"} size={"sm"}/>
|
<Col xs={5}>
|
||||||
</Col>
|
<Form.Control type={"text"} placeholder={"코드명"} size={"sm"}/>
|
||||||
<Col xs={{span:2, offset:2}}><Button type={"button"} variant={"primary"} size={"sm"}>등록</Button></Col>
|
</Col>
|
||||||
</Row>
|
<Col xs={{span:2, offset:2}}><Button type={"button"} variant={"primary"} size={"sm"}>등록</Button></Col>
|
||||||
|
</Row>
|
||||||
|
):(
|
||||||
|
<Row className={"py-1"}>
|
||||||
|
<Col>코드 그룹을 선택해주세요.</Col>
|
||||||
|
</Row>
|
||||||
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ChildCodeDiv;
|
export default forwardRef(ChildCodeDiv);
|
||||||
|
|
@ -1,55 +1,102 @@
|
||||||
import React, { useState, useEffect, useCallback } from 'react';
|
import React, { useState, useEffect, useCallback } from 'react';
|
||||||
|
import * as EgovNet from "api/egovFetch";
|
||||||
import {Container} from "react-bootstrap";
|
import {Container} from "react-bootstrap";
|
||||||
import Row from "react-bootstrap/Row";
|
import Row from "react-bootstrap/Row";
|
||||||
import Col from "react-bootstrap/Col";
|
import Col from "react-bootstrap/Col";
|
||||||
import Form from 'react-bootstrap/Form'
|
import Form from 'react-bootstrap/Form'
|
||||||
import Button from "react-bootstrap/Button";
|
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();
|
const [codeGrpRow, setCodeGrpRow] = useState();
|
||||||
|
|
||||||
function getCodeGrp(){
|
const getCodeGrp = useCallback(()=>{
|
||||||
EgovNet.requestFetch(
|
EgovNet.requestFetch(
|
||||||
'/admin/config/code-grp',
|
'/admin/config/code-grp',
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET"
|
||||||
headers: {
|
|
||||||
'Content-type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({})
|
|
||||||
},
|
},
|
||||||
(resp) => {
|
(resp) => {
|
||||||
debugger
|
const codeGrpList = resp.result.codeGrpList;
|
||||||
|
const grpTag = [];
|
||||||
|
codeGrpList.forEach(function (item, index){
|
||||||
|
grpTag.push(
|
||||||
|
<Row className={"py-2 border-bottom"}>
|
||||||
|
<Col xs={3}>
|
||||||
|
<FaRegHandPointRight className={"selectIcon d-none"}/>
|
||||||
|
<a href={"#"} onClick={(e)=>{codeGrpChoose(e, item.grpCd)}} data-grpcd={item.grpCd}>{item.grpCd}</a>
|
||||||
|
</Col>
|
||||||
|
<Col xs={5}><Form.Control type={"text"} size={"sm"} defaultValue={item.grpCdNm}/></Col>
|
||||||
|
<Col xs={2}><Button variant={"danger"} size={"sm"}>삭제</Button></Col>
|
||||||
|
<Col xs={2}><Button variant={"primary"} size={"sm"}>수정</Button></Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
setCodeGrpRow(grpTag);
|
||||||
},
|
},
|
||||||
function (resp) {
|
function (resp) {
|
||||||
console.log("err response : ", resp);
|
console.log("err response : ", resp);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCodeGrp();
|
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 (
|
return (
|
||||||
<Container className={"pt-3"}>
|
<Container className={"pt-3"} >
|
||||||
<Row className={"py-2 bg-light border-bottom"}>
|
<Row className={"py-2 bg-light border-bottom"}>
|
||||||
<Col xs={4}>코드그룹</Col>
|
<Col xs={3}>코드그룹</Col>
|
||||||
<Col xs={4}>코드그룹명</Col>
|
<Col xs={5}>코드그룹명</Col>
|
||||||
<Col xs={2}>삭제</Col>
|
<Col xs={2}>삭제</Col>
|
||||||
<Col xs={2}>수정</Col>
|
<Col xs={2}>수정</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{codeGrpRow}
|
{codeGrpRow}
|
||||||
<Row className={"py-1"}>
|
<Row className={"py-1"}>
|
||||||
<Col xs={4}>
|
<Col xs={3}>
|
||||||
<Form.Control type={"text"} placeholder={"코드그룹"} size={"sm"}/>
|
<Form.Control type={"text"} id={"grpCd"} placeholder={"코드그룹"} size={"sm"}/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={4}>
|
<Col xs={5}>
|
||||||
<Form.Control type={"text"} placeholder={"코드그룹명"} size={"sm"}/>
|
<Form.Control type={"text"} id={"grpCdNm"} placeholder={"코드그룹명"} size={"sm"}/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={{span:2, offset:2}}><Button type={"button"} variant={"primary"} size={"sm"}>등록</Button></Col>
|
<Col xs={{span:2, offset:2}}><Button type={"button"} variant={"primary"} size={"sm"} onClick={addCodeGrp}>등록</Button></Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.dbnt.kcscbackend.admin.config;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.config.entity.TcCodeGrp;
|
import com.dbnt.kcscbackend.admin.config.entity.TcCodeGrp;
|
||||||
import com.dbnt.kcscbackend.admin.config.service.AdminConfigService;
|
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.BaseController;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
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 io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.MediaType;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
@ -34,7 +37,7 @@ public class AdminConfigController extends BaseController {
|
||||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||||
@ApiResponse(responseCode = "403", 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{
|
public ResultVO getCodeGrp() throws Exception{
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
@ -52,12 +55,41 @@ public class AdminConfigController extends BaseController {
|
||||||
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||||
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
})
|
})
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/code-item", consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(method = RequestMethod.GET, value = "/code-item")
|
||||||
public ResultVO getCodeItem(TcCodeGrp param) throws Exception{
|
public ResultVO getCodeItem(String grpCd) throws Exception{
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
resultMap.put("codeItemList", adminConfigService.selectCodeItemList(param.getGrpCd()));
|
resultMap.put("codeItemList", adminConfigService.selectCodeItemList(grpCd));
|
||||||
resultVO.setResult(resultMap);
|
resultVO.setResult(resultMap);
|
||||||
return resultVO;
|
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<String, Object> resultMap = new HashMap<>();
|
||||||
|
adminConfigService.addCodeGrp(codeGrp);
|
||||||
|
//resultMap.put("codeGrpList", );
|
||||||
|
resultVO.setResult(resultMap);
|
||||||
|
resultVO.setResultCode(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.dbnt.kcscbackend.admin.config.repository.TcCodeItemRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -26,4 +27,9 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
|
||||||
public List<TcCodeItem> selectCodeItemList(String grpCd){
|
public List<TcCodeItem> selectCodeItemList(String grpCd){
|
||||||
return codeItemRepository.findByGrpCdOrderByGrpOrder(grpCd);
|
return codeItemRepository.findByGrpCdOrderByGrpOrder(grpCd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void addCodeGrp(TcCodeGrp codeGrp) {
|
||||||
|
codeGrpRepository.save(codeGrp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue