package com.dbnt.kcgfilemanager.controller; import com.dbnt.kcgfilemanager.model.CommonCode; import com.dbnt.kcgfilemanager.model.UserInfo; import com.dbnt.kcgfilemanager.service.CommonCodeService; import com.dbnt.kcgfilemanager.service.UserInfoService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/admin") public class adminController { private final CommonCodeService commonCodeService; private final UserInfoService userInfoService; @GetMapping("/main") public ModelAndView goAdmin() { ModelAndView mav = new ModelAndView("admin/main"); return mav; } @GetMapping("/userMgt") public ModelAndView userMgt(UserInfo userInfo) { userInfo.setQueryInfo(); ModelAndView mav = new ModelAndView("admin/userMgt"); mav.addObject("userInfoList", userInfoService.selectUserInfoList(userInfo)); userInfo.setContentCnt(userInfoService.selectUserInfoListCnt(userInfo)); userInfo.setPaginationInfo(); mav.addObject("searchParams", userInfo); return mav; } @PostMapping("/insertUserInfo") public String insertUserInfo(UserInfo userInfo){ return userInfoService.insertUserInfo(userInfo); } @PostMapping("/updateUserInfo") public String updateUserInfo(UserInfo userInfo){ return userInfoService.updateUserInfo(userInfo); } @GetMapping("/selectUserInfo") public ModelAndView selectUserInfo(UserInfo userInfo){ ModelAndView mav = new ModelAndView("admin/userInfo"); mav.addObject("userInfo", userInfoService.selectUserInfo(userInfo)); return mav; } @GetMapping("/modifyRequest") public ModelAndView modifyRequest() { ModelAndView mav = new ModelAndView("admin/modifyRequest"); return mav; } @GetMapping("/codeMgt") public ModelAndView codeMgt(CommonCode commonCode) { ModelAndView mav = new ModelAndView("admin/codeMgt"); mav.addObject("categoryList", commonCodeService.selectCommonCodeCategory(commonCode)); return mav; } @GetMapping("/codeValue") public ModelAndView codeValue(CommonCode commonCode) { ModelAndView mav = new ModelAndView("admin/codeValue"); mav.addObject("valueList", commonCodeService.selectCommonCodeValue(commonCode.getCategory())); return mav; } @PostMapping("/insertCode") public CommonCode insertCommonCode(CommonCode commonCode){ commonCodeService.insertCommonCode(commonCode); return commonCode; } @PutMapping(value = "/deleteCode") @ResponseBody public int deleteCommonCode(@RequestBody List codeList) { commonCodeService.updateCommonCode(codeList); return codeList.size(); } }