메뉴 권한 관리 작업 완료
parent
6c3aa18b94
commit
1a656c8f6d
|
|
@ -4,6 +4,7 @@ import {Link} from "react-router-dom";
|
||||||
import URL from "constants/url";
|
import URL from "constants/url";
|
||||||
import * as EgovNet from "api/egovFetch";
|
import * as EgovNet from "api/egovFetch";
|
||||||
import Form from "react-bootstrap/Form";
|
import Form from "react-bootstrap/Form";
|
||||||
|
import CODE from "../../../constants/code";
|
||||||
|
|
||||||
|
|
||||||
function MenuAuthMgt(props) {
|
function MenuAuthMgt(props) {
|
||||||
|
|
@ -29,7 +30,20 @@ function MenuAuthMgt(props) {
|
||||||
menuList.forEach(function (item, index) {
|
menuList.forEach(function (item, index) {
|
||||||
const checkboxs = [];
|
const checkboxs = [];
|
||||||
roleList.forEach(function (role) {
|
roleList.forEach(function (role) {
|
||||||
checkboxs.push(<div><Form.Check checked={item.menuAuth.includes(role.itemCd)}/></div>)
|
checkboxs.push(
|
||||||
|
<div>
|
||||||
|
<Form.Check className={role.itemCd} value={role.itemCd}
|
||||||
|
onClick={(e)=>{
|
||||||
|
const checked = e.target.checked;
|
||||||
|
if(checked) {
|
||||||
|
item.menuAuth += ","+role.itemCd
|
||||||
|
}else{
|
||||||
|
item.menuAuth = item.menuAuth.replace(","+role.itemCd, '');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
defaultChecked={item.menuAuth.includes(role.itemCd)}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
});
|
});
|
||||||
mutListTag.push(
|
mutListTag.push(
|
||||||
<div className={"list_item"} key={"userListDiv_"+index}>
|
<div className={"list_item"} key={"userListDiv_"+index}>
|
||||||
|
|
@ -59,7 +73,27 @@ function MenuAuthMgt(props) {
|
||||||
},[]);
|
},[]);
|
||||||
|
|
||||||
function editMenu(menu){
|
function editMenu(menu){
|
||||||
|
if(window.confirm("수정하시겠습니까?")) {
|
||||||
|
EgovNet.requestFetch(
|
||||||
|
'/admin/config/menu-auth-mgt',
|
||||||
|
{
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(menu)
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (Number(resp.resultCode) === Number(CODE.RCV_SUCCESS)) {
|
||||||
|
alert("수정되었습니다.")
|
||||||
|
} else if (Number(resp.resultCode) === Number(CODE.RCV_ERROR_AUTH)) {
|
||||||
|
console.log("토큰 갱신중.")
|
||||||
|
} else {
|
||||||
|
alert(resp.result.resultMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
|
|
|
||||||
|
|
@ -324,4 +324,30 @@ public class AdminConfigController extends BaseController {
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "메뉴 권한 수정",
|
||||||
|
description = "메뉴 권한 수정",
|
||||||
|
tags = {"AdminConfigController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "수정 성공"),
|
||||||
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
|
})
|
||||||
|
@RequestMapping(method = RequestMethod.PUT, value = "/menu-auth-mgt")
|
||||||
|
public ResultVO editMenuAuthMgt(@RequestBody TcMenu menu, @AuthenticationPrincipal LoginVO user){
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
if(user == null){
|
||||||
|
resultVO.setResultCode(ResponseCode.TOKEN_EXPIRED.getCode());
|
||||||
|
}else {
|
||||||
|
if (!user.getUserSe().equals("ACC_TP01")) {
|
||||||
|
resultVO.setResultCode(ResponseCode.AUTH_ERROR.getCode());
|
||||||
|
resultVO.setResultMessage(ResponseCode.AUTH_ERROR.getMessage());
|
||||||
|
} else {
|
||||||
|
adminConfigService.editMenuAuth(menu);
|
||||||
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.config.entity;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import org.hibernate.annotations.DynamicInsert;
|
||||||
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@NoArgsConstructor
|
||||||
|
@DynamicInsert
|
||||||
|
@DynamicUpdate
|
||||||
|
@Table(name = "tb_menu_role")
|
||||||
|
@IdClass(TbMenuRole.TbMenuRoleId.class)
|
||||||
|
public class TbMenuRole {
|
||||||
|
@Id
|
||||||
|
@Column(name = "role_id")
|
||||||
|
private String roleId;
|
||||||
|
@Id
|
||||||
|
@Column(name = "menu_id")
|
||||||
|
private String menuId;
|
||||||
|
@Column(name = "write_yn")
|
||||||
|
private String writeYn;
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class TbMenuRoleId implements Serializable {
|
||||||
|
private String roleId;
|
||||||
|
private String menuId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.dbnt.kcscbackend.admin.config.repository;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.admin.config.entity.TbMenuRole;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TbMenuRoleRepository extends JpaRepository<TbMenuRole, TbMenuRole.TbMenuRoleId> {
|
||||||
|
|
||||||
|
void deleteByMenuId(String menuId);
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.dbnt.kcscbackend.admin.config.service;
|
package com.dbnt.kcscbackend.admin.config.service;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.admin.config.entity.TbMenuRole;
|
||||||
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
import com.dbnt.kcscbackend.admin.config.entity.TcMenu;
|
||||||
import com.dbnt.kcscbackend.admin.config.mapper.TcMenuMapper;
|
import com.dbnt.kcscbackend.admin.config.mapper.TcMenuMapper;
|
||||||
|
import com.dbnt.kcscbackend.admin.config.repository.TbMenuRoleRepository;
|
||||||
import com.dbnt.kcscbackend.admin.config.repository.TcMenuRepository;
|
import com.dbnt.kcscbackend.admin.config.repository.TcMenuRepository;
|
||||||
import com.dbnt.kcscbackend.commonCode.entity.TcCodeGrp;
|
import com.dbnt.kcscbackend.commonCode.entity.TcCodeGrp;
|
||||||
import com.dbnt.kcscbackend.commonCode.entity.TcCodeItem;
|
import com.dbnt.kcscbackend.commonCode.entity.TcCodeItem;
|
||||||
|
|
@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -22,6 +25,7 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
|
||||||
private final TcCodeGrpRepository codeGrpRepository;
|
private final TcCodeGrpRepository codeGrpRepository;
|
||||||
private final TcCodeItemRepository codeItemRepository;
|
private final TcCodeItemRepository codeItemRepository;
|
||||||
private final TcMenuRepository menuRepository;
|
private final TcMenuRepository menuRepository;
|
||||||
|
private final TbMenuRoleRepository menuRoleRepository;
|
||||||
private final TcMenuMapper menuMapper;
|
private final TcMenuMapper menuMapper;
|
||||||
|
|
||||||
public List<TcCodeGrp> selectCodeGrpList(){
|
public List<TcCodeGrp> selectCodeGrpList(){
|
||||||
|
|
@ -144,4 +148,21 @@ public class AdminConfigService extends EgovAbstractServiceImpl {
|
||||||
public List<TcMenu> selectMenuAuthList(){
|
public List<TcMenu> selectMenuAuthList(){
|
||||||
return menuMapper.selectMenuAuthList();
|
return menuMapper.selectMenuAuthList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void editMenuAuth(TcMenu menu) {
|
||||||
|
String[] roleAry = menu.getMenuAuth().split(",");
|
||||||
|
menuRoleRepository.deleteByMenuId(menu.getMenuId());
|
||||||
|
List<TbMenuRole> roleList = new ArrayList<>();
|
||||||
|
for(String role: roleAry){
|
||||||
|
if(!role.isEmpty()){
|
||||||
|
TbMenuRole menuRole = new TbMenuRole();
|
||||||
|
menuRole.setMenuId(menu.getMenuId());
|
||||||
|
menuRole.setRoleId(role);
|
||||||
|
menuRole.setWriteYn("Y");
|
||||||
|
roleList.add(menuRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menuRoleRepository.saveAll(roleList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,10 @@
|
||||||
coalesce(b.role_cd, '') as menu_auth
|
coalesce(b.role_cd, '') as menu_auth
|
||||||
from tc_menu a
|
from tc_menu a
|
||||||
left outer join (
|
left outer join (
|
||||||
select menu_id , string_agg(role_id, ',') as role_cd
|
select menu_id , string_agg(role_id, ',') as role_cd
|
||||||
from (
|
from tb_menu_role
|
||||||
select distinct *
|
group by menu_id
|
||||||
from tb_menu_role
|
) b on a.menu_id = b.menu_id
|
||||||
) aa
|
|
||||||
group by menu_id
|
|
||||||
) b on a.menu_id = b.menu_id
|
|
||||||
where a.use_yn = 'Y'
|
where a.use_yn = 'Y'
|
||||||
order by a.menu_id asc
|
order by a.menu_id asc
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue