kcgFileManager/src/main/java/com/dbnt/kcgfilemanager/controller/adminController.java

93 lines
2.8 KiB
Java
Raw Normal View History

2021-11-30 10:05:43 +00:00
package com.dbnt.kcgfilemanager.controller;
2021-11-29 09:38:48 +00:00
2021-11-30 10:05:43 +00:00
import com.dbnt.kcgfilemanager.model.CommonCode;
import com.dbnt.kcgfilemanager.service.CommonCodeService;
2021-11-29 09:38:48 +00:00
import lombok.RequiredArgsConstructor;
2021-12-01 09:54:01 +00:00
import org.json.simple.JSONObject;
2021-11-29 09:38:48 +00:00
import org.springframework.stereotype.Controller;
2021-12-01 09:54:01 +00:00
import org.springframework.web.bind.annotation.*;
2021-11-30 10:05:43 +00:00
import org.springframework.web.servlet.ModelAndView;
2021-12-01 09:54:01 +00:00
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.http.HttpResponse;
2021-11-30 10:05:43 +00:00
import java.util.List;
2021-11-29 09:38:48 +00:00
@Controller
@RequiredArgsConstructor
@RequestMapping("/admin")
public class adminController {
2021-11-30 10:05:43 +00:00
private final CommonCodeService commonCodeService;
2021-11-29 09:38:48 +00:00
/** * 회원가입 페이지 이동 * @return */
@GetMapping("/signup")
public String goSignup() {
return "login/signup";
}
/** * Admin 페이지 이동 * @return */
@GetMapping("/main")
public String goAdmin() {
return "admin/main";
}
@GetMapping("/userMgt")
public String userMgt() {
return "admin/userMgt";
}
@GetMapping("/modifyRequest")
public String modifyRequest() {
return "admin/modifyRequest";
}
@GetMapping("/codeMgt")
2021-11-30 10:05:43 +00:00
public ModelAndView codeMgt(CommonCode commonCode) {
ModelAndView mav = new ModelAndView("admin/codeMgt");
2021-12-01 09:54:01 +00:00
mav.addObject("categoryList", commonCodeService.selectCommonCodeCategory(commonCode));
2021-11-30 10:05:43 +00:00
return mav;
2021-11-29 09:38:48 +00:00
}
2021-12-01 09:54:01 +00:00
@GetMapping("/codeValue")
public ModelAndView codeValue(CommonCode commonCode) {
ModelAndView mav = new ModelAndView("admin/codeValue");
mav.addObject("valueList", commonCodeService.selectCommonCodeValue(commonCode));
return mav;
}
@PutMapping("/insertCommonCode")
public void insertCommonCode(HttpServletResponse res, CommonCode commonCode){
res.setCharacterEncoding("UTF-8");
res.setContentType("text/html; charset=UTF-8");
PrintWriter writerJson = null;
JSONObject jsonObject = new JSONObject();
commonCodeService.insertCommonCode(commonCode);
jsonObject.put("codeSq", commonCode.getCodeSq());
jsonObject.put("category", commonCode.getCategory());
jsonObject.put("value", commonCode.getValue());
try {
writerJson = res.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
writerJson.print(jsonObject);
}
@PutMapping("/updateCommonCode")
public void updateCommonCode(HttpServletResponse res, List<CommonCode> commonCodeList){
res.setCharacterEncoding("UTF-8");
res.setContentType("text/html; charset=UTF-8");
PrintWriter writerJson = null;
JSONObject jsonObject = new JSONObject();
System.out.println(commonCodeList.size());
// jsonObject.put("codeSq", commonCode.getCodeSq());
try {
writerJson = res.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
writerJson.print(jsonObject);
}
2021-11-29 09:38:48 +00:00
}