@author Hellohao @version 1.0 @date 2019/8/19 16:35
| 21 | * @date 2019/8/19 16:35 |
| 22 | */ |
| 23 | @Controller |
| 24 | @RequestMapping("/admin/root") |
| 25 | public class GroupController { |
| 26 | @Autowired |
| 27 | private GroupService groupService; |
| 28 | |
| 29 | |
| 30 | @PostMapping("/getGrouplistForUsers") |
| 31 | @ResponseBody |
| 32 | public Msg getGrouplistForUsers() { |
| 33 | Msg msg = new Msg(); |
| 34 | List<Group> groupList = groupService.grouplist(0); |
| 35 | msg.setData(groupList); |
| 36 | return msg; |
| 37 | } |
| 38 | |
| 39 | @PostMapping(value = "/getGroupList") |
| 40 | @ResponseBody |
| 41 | public Msg getgrouplist(@RequestParam(value = "data", defaultValue = "") String data) { |
| 42 | Msg msg = new Msg(); |
| 43 | JSONObject jsonObj = JSONObject.parseObject(data); |
| 44 | Integer pageNum = jsonObj.getInteger("pageNum"); |
| 45 | Integer pageSize = jsonObj.getInteger("pageSize"); |
| 46 | PageHelper.startPage(pageNum, pageSize); |
| 47 | List<Group> group = null; |
| 48 | try { |
| 49 | group = groupService.grouplist(null); |
| 50 | PageInfo<Group> rolePageInfo = new PageInfo<>(group); |
| 51 | msg.setData(rolePageInfo); |
| 52 | } catch (Exception e) { |
| 53 | e.printStackTrace(); |
| 54 | msg.setCode("500"); |
| 55 | msg.setInfo("获取数据异常"); |
| 56 | } |
| 57 | return msg; |
| 58 | } |
| 59 | |
| 60 | @PostMapping(value = "/addGroup") |
| 61 | @ResponseBody |
| 62 | public Msg addisgroup(@RequestParam(value = "data", defaultValue = "") String data) { |
| 63 | JSONObject jsonObject = JSONObject.parseObject(data); |
| 64 | Group group = new Group(); |
| 65 | group.setGroupname(jsonObject.getString("groupname")); |
| 66 | group.setKeyid(jsonObject.getInteger("keyid")); |
| 67 | group.setUsertype(jsonObject.getInteger("usertype")); |
| 68 | group.setCompress(jsonObject.getBoolean("compress")?1:0); |
| 69 | Msg msg = groupService.addgroup(group); |
| 70 | return msg; |
| 71 | } |
| 72 | |
| 73 | @PostMapping("/updateGroup") |
| 74 | @ResponseBody |
| 75 | public Msg updategroup(@RequestParam(value = "data", defaultValue = "") String data) { |
| 76 | JSONObject jsonObject = JSONObject.parseObject(data); |
| 77 | Group group = new Group(); |
| 78 | group.setId(jsonObject.getInteger("id")); |
| 79 | if(jsonObject.getInteger("id")==1){ |
| 80 | group.setGroupname("默认群组"); |
nothing calls this directly
no outgoing calls
no test coverage detected