首页>代码>SSM开发强迫症简易自测量问卷系统,包括后台管理系统>/yhQuestion/src/main/java/com/yanhui/controller/backend/PaperTypeManageController.java
package com.yanhui.controller.backend; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.yanhui.constant.Global; import com.yanhui.controller.common.BaseController; import com.yanhui.pojo.SurveyType; @Controller @RequestMapping("/yhmanage/paperType/") public class PaperTypeManageController extends BaseController{ /** * 问卷类型树 * @return * @throws Exception */ @RequestMapping("/getPaperTypeList") public void getPaperTypeList(String page, String name, HttpServletRequest request, HttpServletResponse response) throws Exception{ //写入到前台 request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); JSONArray array = new JSONArray(); Map<String,Object> map = new HashMap<String,Object>(); List<SurveyType> surveyTypeList = surveyTypeService.listForPage(map); for (SurveyType type : surveyTypeList) { JSONObject jsonObject = new JSONObject(); jsonObject.put("id",type.getId()); jsonObject.put("name",type.getName()); jsonObject.put("pId",type.getParentId()); array.put(jsonObject); } System.out.println(array.toString()); response.getWriter().write(array.toString()); response.getWriter().flush(); response.getWriter().close(); } @RequestMapping("/insertPaperType") @ResponseBody public Map<String,Object> insertPaperType(SurveyType surveyType, HttpServletRequest request){ Map<String,Object> map = new HashMap<String,Object>(); try { Integer id = surveyType.getId(); if(id != null){ //更新 surveyTypeService.update(surveyType); map.put("message", Global.MSG_UPDATE_SUCCESS); }else{ //添加 surveyTypeService.insert(surveyType); map.put("message", Global.MSG_ADD_SUCCESS); } } catch (Exception e) { map.put("message", Global.MSG_FAIL); } return map; } /** * 删除 * @param id * @return */ @RequestMapping("/deletePaperType") @ResponseBody public Map<String,Object> deletePaperType(Integer id){ Map<String,Object> map = new HashMap<String,Object>(); try { map.put("parentId", id); List<SurveyType> list = surveyTypeService.listForPage(map); for(SurveyType type : list){ surveyTypeService.deleteById(type.getId()); } surveyTypeService.deleteById(id); map.put("message", Global.MSG_DEL_SUCCESS); } catch (Exception e) { map.put("message", Global.MSG_FAIL); } return map; } // /** // * 跳转到编辑页面 // * @return // */ // @RequestMapping("/edit-paper") // public String editPager(Integer id, HttpServletRequest request) { // if(id!=null){ // Paper paper = paperService.findById(id); // request.setAttribute("paper", paper); // } // return Global.WEB_BACK_PAGE + "/paper/paperEdit"; // } // // /** // * 批量删除 // * @param id // * @return // */ // @RequestMapping("/deletePapers") // @ResponseBody // public Map<String,Object> deletePapers(String ids){ // Map<String,Object> result = new HashMap<String,Object>(); // try { // String[] arry = ids.split(","); // for (int i = 0; i < arry.length; i++) { // String id = arry[i]; // if(!id.equals("")){ // paperService.deleteById(Integer.parseInt(id)); // } // } // result.put("status", Global.STATUS_1); // } catch (Exception e) { // result.put("status", Global.STATUS_0); // } // return result; // } // // /** // * 删除 // * @param id // * @return // */ // @RequestMapping("/deletePaperType") // @ResponseBody // public Map<String,Object> deletePaper(Integer id){ // Map<String,Object> result = new HashMap<String,Object>(); // try { // paperService.deleteById(id); // result.put("status", Global.STATUS_1); // } catch (Exception e) { // result.put("status", Global.STATUS_0); // } // return result; // } // // /** // * 跳转到用户添加页面 // * @return // */ // @RequestMapping("/user-add") // public String addUserPage(Integer id, HttpServletRequest request) { // if(id!=null){ // User user = userService.findById(id); // request.setAttribute("user", user); // } // return "/admin/user/user-add"; // } // // /** // * 添加用户 // * @return // */ // @RequestMapping("/insertPaper") // @ResponseBody // public Map<String,Object> insertPaper(Paper paper, HttpServletRequest request){ // Map<String,Object> map = new HashMap<String,Object>(); // try { // Integer id = paper.getId(); // if(id != null){ // //更新 // paperService.update(paper); // map.put("message", Global.MSG_UPDATE_SUCCESS); // }else{ // //添加 // paperService.insert(paper); // map.put("message", Global.MSG_ADD_SUCCESS); // } // map.put("status", Global.STATUS_1); // } catch (Exception e) { // map.put("status", Global.STATUS_0); // map.put("message", Global.MSG_FAIL); // } // return map; // } // // // /** // * 启用或停用状态 // * @return // */ // @RequestMapping("/startOrStopUser") // @ResponseBody // public Map<String,Object> startOrStopUser(Integer id, HttpServletRequest request){ // Map<String,Object> map = new HashMap<String,Object>(); // User user = userService.findById(id); // Boolean isActive = user.getIsActive(); // if(isActive){ // //修改为禁用 // user.setIsActive(false); // map.put("status", 0); // }else{ // //修改为可用 // user.setIsActive(true); // map.put("status", 1); // } // userService.update(user); // return map; // } // // // @RequestMapping("/findById") // @ResponseBody // public Map<String,Object> findById(int id){ // System.out.println("------------"+PropUtils.get("setting.version")); // Map<String,Object> map = new HashMap<String, Object>(); // User user = userService.findById(id); // map.put("user", user); // return map; // } }

shuangfu LV25
2023年12月2日
孙龙52 LV6
2022年7月25日
泓鼎168 LV20
2022年3月9日
wanglinddad LV55
2021年12月20日
qianzf LV12
2021年7月21日
ygbuhuide LV4
2021年5月14日
一字清华 LV8
2021年1月13日
123456nty LV37
2020年12月16日
xiadongdong LV12
2020年10月22日
as5675020 LV5
2020年9月18日

ma406805131 LV19
2024年12月18日
15578157792 LV7
2024年12月10日
pilipala888
2024年9月10日
暂无贡献等级
Song3LL
2024年7月22日
暂无贡献等级
老猪1978 LV1
2024年6月3日
1109851097 LV1
2024年5月7日
admin_z LV22
2024年1月28日
minjing123 LV8
2024年1月4日
shuangfu LV25
2023年12月2日
爱吃鱼的猫Vital LV6
2023年7月28日