From 4fefb85e524b4b6e00efba04457797d8a32829a5 Mon Sep 17 00:00:00 2001 From: whycrzg <ruanzhigang@whycst.com> Date: 星期二, 02 二月 2021 14:24:18 +0800 Subject: [PATCH] update --- src/main/java/com/fgkj/controller/User_infController.java | 457 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 241 insertions(+), 216 deletions(-) diff --git a/src/main/java/com/fgkj/controller/User_infController.java b/src/main/java/com/fgkj/controller/User_infController.java index 04feea9..2d9ce73 100644 --- a/src/main/java/com/fgkj/controller/User_infController.java +++ b/src/main/java/com/fgkj/controller/User_infController.java @@ -11,6 +11,7 @@ import com.google.gson.Gson; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -22,140 +23,165 @@ @RequestMapping("userInf") @RestController @Api(tags = "userInf鎺ュ彛") -public class User_infController{ - @Resource - private User_infService service; - @Resource - private User_logService uservice; - @Resource - private UtilityFactoryService utilityFactoryService; +public class User_infController { + @Resource + private User_infService service; + @Resource + private User_logService uservice; + @Resource + private UtilityFactoryService utilityFactoryService; - // private Batt_User_Permit bup; - // ServiceModel model = new ServiceModel(); - // private User_inf uif; - // private String result; - // private String addjson; //娣诲姞鐢ㄦ埛鐨勭敤鎴穓son鏁扮粍 - // private String upjson; //鏇存柊鐢ㄦ埛鐨勭敤鎴穓son鏁扮粍 - - //娣诲姞鐢ㄦ埛 - @PostMapping("/") - @ApiOperation(notes = "",value="娣诲姞鐢ㄦ埛") - public ServiceModel add(@RequestBody User_inf uif) { - System.out.println("uif = " + uif); - uif.setUpassword(ActionUtil.EncryptionMD5(uif.getUpassword()).toString()); - ServiceModel model = service.add(uif); - { - String msg="娣诲姞鏂扮敤鎴�:"+uif.getuName(); - User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg); - uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 - } - - return model; - } + // private Batt_User_Permit bup; + // ServiceModel model = new ServiceModel(); + // private User_inf uif; + // private String result; + // private String addjson; //娣诲姞鐢ㄦ埛鐨勭敤鎴穓son鏁扮粍 + // private String upjson; //鏇存柊鐢ㄦ埛鐨勭敤鎴穓son鏁扮粍 + + //娣诲姞鐢ㄦ埛 + @PostMapping("/") + @ApiOperation(notes = "{ \"uSnId\": \"1\", \"uName\": \"t2\", \"uShenFenId\": \"\", \"uEmployeeId\": \"\", \"uTelephone\": \"\", \"uMobilephone\": \"\", \"uEmail\": \"\", \"uAddr\": \"\", \"uBirthDay\": \"2021-01-11 08:26:29\", \"uAccessionDay\": \"2021-01-11 08:26:29\", \"uSex\": \"\", \"uDepartment\": \"\", \"uProTitle\": \"\", \"uAuthority\": \"\", \"uJobGroup\": \"\", \"uDuties\": \"\", \"uTasks\": \"\", \"uBaojiusr\": 0, \"uNote\": \"ss\", \"permitgroupName\": \"\", \"upassword\": \"ss\", \"license\": \"\" }", value = "娣诲姞鐢ㄦ埛") + public ServiceModel add(@RequestBody User_inf uif) { +// System.out.println("uif = " + uif); + uif.setUpassword(ActionUtil.EncryptionMD5(uif.getUpassword()).toString()); + ServiceModel model = service.add(uif); + { + String msg = "娣诲姞鏂扮敤鎴�:" + uif.getuName(); + User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg); + uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 + } + + return model; + } + //淇敼鐢ㄦ埛淇℃伅 - @PutMapping("/") - @ApiOperation(notes = "",value="淇敼鐢ㄦ埛淇℃伅") - public ServiceModel update(@RequestBody User_inf uif) { - ServiceModel model = new ServiceModel(); - model = service.update(uif); - { - String msg="淇敼"+uif.getuName()+"鐨勭敤鎴蜂俊鎭�"; - User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); - uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 - } - - return model; - } + @PutMapping("/") + @ApiOperation(notes = "{ \"uId\": \"1012\", \"uSnId\": \"1\", \"uName\": \"news\", \"uShenFenId\": \"\", \"uEmployeeId\": \"\", \"uTelephone\": \"\", \"uMobilephone\": \"\", \"uEmail\": \"\", \"uAddr\": \"\", \"uBirthDay\": \"2021-01-11 08:26:29\", \"uAccessionDay\": \"2021-01-11 08:26:29\", \"uSex\": \"\", \"uDepartment\": \"\", \"uProTitle\": \"\", \"uAuthority\": \"\", \"uJobGroup\": \"\", \"uDuties\": \"\", \"uTasks\": \"\", \"uBaojiusr\": 0, \"uNote\": \"ss\", \"permitgroupName\": \"\", \"upassword\": \"ss\", \"license\": \"\" }", value = "淇敼鐢ㄦ埛淇℃伅") + public ServiceModel update(@RequestBody User_inf uif) { + ServiceModel model = new ServiceModel(); + model = service.update(uif); + { + String msg = "淇敼" + uif.getuName() + "鐨勭敤鎴蜂俊鎭�"; + User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); + uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 + } + + return model; + } + //鍒犻櫎鐢ㄦ埛淇℃伅 - @DeleteMapping("/") - @ApiOperation(notes = "",value="鍒犻櫎鐢ㄦ埛淇℃伅") - public ServiceModel delete(@RequestBody User_inf uif) { - ServiceModel model = new ServiceModel(); - if(uif!=null){ - model = service.delete(uif); - { - String msg="鍒犻櫎"+uif.getuName()+"鐨勭敤鎴蜂俊鎭�"; - User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg); - uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 - } - } - - return model; - } - @PostMapping("byCondition") - @ApiOperation(notes = "",value="byCondition") - public ServiceModel serchByCondition(@RequestBody User_inf uif) { - return service.serchByCondition(uif); - } + @DeleteMapping("/") + @ApiOperation(notes = "", value = "鍒犻櫎鐢ㄦ埛淇℃伅") + public ServiceModel delete(@RequestParam Integer uId, @RequestParam String uName) { + User_inf uif = new User_inf(); + uif.setuId(uId); + uif.setuName(uName); + ServiceModel model = service.delete(uif); + { + String msg = "鍒犻櫎" + uif.getuName() + "鐨勭敤鎴蜂俊鎭�"; + User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg); + uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 + } + return model; + } - @PostMapping("all") - @ApiOperation(notes = "TODO 寰呮祴",value="all") - public ServiceModel searchAll(@RequestBody Batt_User_Permit bup) { - ServiceModel model = new ServiceModel(); - System.out.println("bup = " + bup); - if (bup.getPageBean() == null) { - model = service.searchAll(); - } else { - model = service.searchAll(bup); - } - return model; - } - //鏍规嵁鍛樺伐淇℃伅鍜屽憳宸ョ紪鍙峰幓鍖归厤鍚堥�傜殑鍛樺伐 - @PostMapping("byNameOrId") - @ApiOperation(notes = "",value="鍛樺伐淇℃伅鍜屽憳宸ョ紪鍙峰幓鍖归厤鍚堥�傜殑鍛樺伐") - public ServiceModel searchByNameOrId(@RequestBody Batt_User_Permit bup) { - ServiceModel model = service.searchByNameOrId(bup); - - return model; - } - //閲嶇疆鐢ㄦ埛瀵嗙爜 - @PutMapping("resetPassword") - @ApiOperation(notes = "",value="閲嶇疆鐢ㄦ埛瀵嗙爜") - public ServiceModel resetPassword(@RequestBody User_inf uif){ - ServiceModel model = new ServiceModel(); - model=service.resetPassword(uif); - { - String msg="閲嶇疆"+uif.getuName()+"鐢ㄦ埛鐨勫瘑鐮�"; - User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); - uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 - } - - return model; - } + @PostMapping("byCondition") + @ApiOperation(notes = "", value = "byCondition") + public ServiceModel serchByCondition(@RequestParam String uName) { + User_inf uif = new User_inf(); + uif.setuName(uName); + return service.serchByCondition(uif); + } - //鏍规嵁鐢ㄦ埛鐨刬d鏌ヨ鐢ㄦ埛鎵�鍦ㄧ殑鍖呮満缁� - @PostMapping("byInfo") - @ApiOperation(notes = "",value="鐢ㄦ埛鐨刬d鏌ヨ鐢ㄦ埛鎵�鍦ㄧ殑鍖呮満缁�") - public ServiceModel serchByInfo(@RequestBody User_inf uif){ - ServiceModel model=service.serchByInfo(uif); - - return model; - } + @PostMapping("all") + @ApiOperation(notes = "pageSize&pageNum浼�0鏃朵笉鍒嗛〉锛屾煡璇㈡潯浠朵笉鍚� ", value = "all") + public ServiceModel searchAll(@ApiParam(value = "椤甸潰鏉℃暟", required = true) @RequestParam Integer pageSize, @ApiParam(value = "椤电爜", required = true) @RequestParam Integer pageNum) { + ServiceModel model = new ServiceModel(); + if (pageSize == 0 && pageNum == 0) { + model = service.searchAll(); + } else { + Batt_User_Permit bup = new Batt_User_Permit(); + PageBean pageBean = new PageBean(); + pageBean.setPageSize(pageSize); + pageBean.setPageNum(pageNum); + bup.setPageBean(pageBean); + model = service.searchAll(bup); + } + return model; + } - //娣诲姞鏂扮殑鐢ㄦ埛妯℃澘 - @PostMapping("newUser") - @ApiOperation(notes = "",value="娣诲姞鏂扮殑鐢ㄦ埛妯℃澘") - public ServiceModel createNewUser(){ - User_inf uinf=utilityFactoryService.CreateUinf(); - System.out.println("uinf = " + uinf); - ServiceModel model=new ServiceModel(); - if(uinf!=null){ - model.setCode(1); - model.setData(uinf); - } - - return model; - } - - - //鏇存柊澶氫釜鐢ㄦ埛 - @PutMapping("user") - @ApiOperation(notes = "",value="鏇存柊澶氫釜鐢ㄦ埛") - public ServiceModel updateUser(@RequestBody List<User_inf> addlist){ - Gson gson=ActionUtil.getGson("yyyy-MM-dd"); - String msg=""; - ServiceModel model = new ServiceModel(); + //鏍规嵁鍛樺伐淇℃伅鍜屽憳宸ョ紪鍙峰幓鍖归厤鍚堥�傜殑鍛樺伐 + @PostMapping("byNameOrId") + @ApiOperation(notes = "", value = "鍛樺伐淇℃伅鍜屽憳宸ョ紪鍙峰幓鍖归厤鍚堥�傜殑鍛樺伐") + public ServiceModel searchByNameOrId(@ApiParam(value = "鍛樺伐淇℃伅", required = true) @RequestParam String uName, @ApiParam(value = "鍛樺伐缂栧彿", required = true) @RequestParam String uEmployeeId, @ApiParam(value = "椤甸潰鏉℃暟", required = true) @RequestParam Integer pageSize, @ApiParam(value = "椤电爜", required = true) @RequestParam Integer pageNum) { + Batt_User_Permit bup = new Batt_User_Permit(); + User_inf user_inf = new User_inf(); + user_inf.setuName(uName); + user_inf.setuEmployeeId(uEmployeeId); + PageBean pageBean = new PageBean(); + pageBean.setPageSize(pageSize); + pageBean.setPageNum(pageNum); + bup.setUinf(user_inf); + bup.setPageBean(pageBean); + ServiceModel model = service.searchByNameOrId(bup); + + return model; + } + + //閲嶇疆鐢ㄦ埛瀵嗙爜 + @PutMapping("resetPassword") + @ApiOperation(notes = "", value = "閲嶇疆鐢ㄦ埛瀵嗙爜") + public ServiceModel resetPassword(@RequestParam Integer uId, @RequestParam String upassword, @RequestParam String uName) { + User_inf uif = new User_inf(); + ServiceModel model = new ServiceModel(); + uif.setuId(uId); + uif.setUpassword(upassword); + uif.setuName(uName); + model = service.resetPassword(uif); + if (model.getCode() == 1) { + String msg = "閲嶇疆" + uif.getuName() + "鐢ㄦ埛鐨勫瘑鐮�"; + User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg); + uservice.add(ulog);//灏嗙敤鎴风殑鎿嶄綔璁板綍涓嬫潵 + } + + return model; + } + + //鏍规嵁鐢ㄦ埛鐨刬d鏌ヨ鐢ㄦ埛鎵�鍦ㄧ殑鍖呮満缁� + @PostMapping("byInfo") + @ApiOperation(notes = "", value = "鐢ㄦ埛鐨刬d鏌ヨ鐢ㄦ埛鎵�鍦ㄧ殑鍖呮満缁�") + public ServiceModel serchByInfo(@RequestParam Integer uId) { + User_inf uif = new User_inf(); + uif.setuId(uId); + ServiceModel model = service.serchByInfo(uif); + + return model; + } + + //娣诲姞鏂扮殑鐢ㄦ埛妯℃澘 + @PostMapping("newUser") + @ApiOperation(notes = "", value = "娣诲姞鏂扮殑鐢ㄦ埛妯℃澘") + public ServiceModel createNewUser() { + User_inf uinf = utilityFactoryService.CreateUinf(); + System.out.println("uinf = " + uinf); + ServiceModel model = new ServiceModel(); + if (uinf != null) { + model.setCode(1); + model.setData(uinf); + } + + return model; + } + + + //鏇存柊澶氫釜鐢ㄦ埛 + @PutMapping("user") + @ApiOperation(notes = "", value = "鏇存柊澶氫釜鐢ㄦ埛 TODO") + public ServiceModel updateUser(@RequestBody List<User_inf> addlist) { + Gson gson = ActionUtil.getGson("yyyy-MM-dd"); + String msg = ""; + ServiceModel model = new ServiceModel(); /*if(addjson!=null && addjson.length()>0){ List<User_inf> addlist=gson.fromJson(addjson, new TypeToken<List<User_inf>>(){}.getType()); if(addlist!=null && addlist.size()>0){ @@ -173,99 +199,98 @@ }*/ + model.setMsg(msg); - model.setMsg(msg); - - //System.out.println(result); - return model; - } - - //淇敼澶氫釜鐢ㄦ埛 - @PostMapping("user") - @ApiOperation(notes = "",value="淇敼澶氫釜鐢ㄦ埛") - public ServiceModel addUser(@RequestBody List<Battalarm_data> list){ - ServiceModel model = new ServiceModel(); + //System.out.println(result); + return model; + } + + //淇敼澶氫釜鐢ㄦ埛 + @PostMapping("user") + @ApiOperation(notes = "", value = "淇敼澶氫釜鐢ㄦ埛 TODO") + public ServiceModel addUser(@RequestBody List<Battalarm_data> list) { + ServiceModel model = new ServiceModel(); /*if(addjson!=null && addjson.length()>0){ Gson gson=new Gson(); List<Battalarm_data> list=gson.fromJson(addjson, new TypeToken<List<User_inf>>(){}.getType()); }*/ - return model; - } - - - //淇敼瀵嗙爜 - @PutMapping("password") - @ApiOperation(notes = "",value="淇敼瀵嗙爜") - public ServiceModel updatePassword(@RequestBody User_inf uif){ - ServiceModel model = new ServiceModel(); - User_inf uinf=(User_inf)ActionUtil.getUser(); - if(uinf!=null && uif!=null){ - uinf.setuSnId(uif.getuSnId()); - model=service.updatePassword(uinf); - } - - return model; - } - - //鏌ヨ褰撳墠鐢ㄦ埛鐨勪俊鎭� - @GetMapping("userFromSession") - @ApiOperation(notes = "",value="鏌ヨ褰撳墠鐢ㄦ埛鐨勪俊鎭�") - public ServiceModel serchUserfromSession(){ - ServiceModel model = new ServiceModel(); - User_inf uif= (User_inf) ActionUtil.getUser(); - if (uif!=null) { - model.setCode(1); - model.setData(uif); - } - return model; - } - - //妫�鏌ョ敤鎴风殑瀵嗙爜 - @GetMapping("checkUserPass") - @ApiOperation(notes = "",value="妫�鏌ョ敤鎴风殑瀵嗙爜") - public ServiceModel checkUserPass(@RequestParam String addjson){ - User_inf user = (User_inf)ActionUtil.getUser(); - ServiceModel model = new ServiceModel(); - if(user != null && null != user.getUpassword() && user.getUpassword().equals(addjson)){ - model.setCode(1); - }else{ - model.setCode(0); - } - model.setData(null); - return model; - } - - //鏌ヨ褰撳墠鐢ㄦ埛鐨勭敤鎴峰悕 - @GetMapping("uName") - @ApiOperation(notes = "",value="鏌ヨ褰撳墠鐢ㄦ埛鐨勭敤鎴峰悕") - public ServiceModelImpl searchUname(){ - User_inf user = (User_inf)ActionUtil.getUser(); - ServiceModelImpl model = new ServiceModelImpl(); - if(user != null){ - model.setCode(1); - model.setMsgN(user.getuName()); - }else{ - model.setCode(0); - model.setMsg("You are not logged in, please log in"); - } - - return model; - } - - //鐣岄潰璇锋眰鐩戞祴鏈嶅姟鏄惁鏂紑 - @PostMapping("checkService") - @ApiOperation(notes = "",value="鐣岄潰璇锋眰鐩戞祴鏈嶅姟鏄惁鏂紑") - public ServiceModel checkService(@RequestBody ServiceModel model){ - return model; - } - - //鍖呮満缁勯噸鍋氾紙绌挎妗嗭級鏌ヨ鎵�鏈夌殑鐢ㄦ埛 - @GetMapping("csAll") - @ApiOperation(notes = "",value="鍖呮満缁勯噸鍋氾紙绌挎妗嗭級鏌ヨ鎵�鏈夌殑鐢ㄦ埛") - public ServiceModel searchCS_All() { - ServiceModel model=service.searchCS_All(); - - return model; - } + return model; + } + + + //淇敼瀵嗙爜 + @PutMapping("password") + @ApiOperation(notes = "session 涓幏鍙杣Id", value = "淇敼瀵嗙爜") + public ServiceModel updatePassword(@ApiParam(value = "鏄庢枃瀵嗙爜", required = true) @RequestParam String pwd) { + ServiceModel model = new ServiceModel(); + User_inf uinf = (User_inf) ActionUtil.getUser(); + if (uinf != null && !pwd.isEmpty()) { + uinf.setuSnId(pwd); + model = service.updatePassword(uinf); + } + + return model; + } + + //鏌ヨ褰撳墠鐢ㄦ埛鐨勪俊鎭� + @GetMapping("userFromSession") + @ApiOperation(notes = "", value = "鏌ヨ褰撳墠鐢ㄦ埛鐨勪俊鎭�") + public ServiceModel serchUserfromSession() { + ServiceModel model = new ServiceModel(); + User_inf uif = (User_inf) ActionUtil.getUser(); + if (uif != null) { + model.setCode(1); + model.setData(uif); + } + return model; + } + + //妫�鏌ョ敤鎴风殑瀵嗙爜 + @GetMapping("checkUserPass") + @ApiOperation(notes = "", value = "妫�鏌ョ敤鎴风殑瀵嗙爜") + public ServiceModel checkUserPass(@ApiParam(value = "闇�瑕佹鏌ョ殑瀵嗙爜", required = true) @RequestParam String checkpwd) { + User_inf user = (User_inf) ActionUtil.getUser(); + ServiceModel model = new ServiceModel(); + if (user != null && null != user.getUpassword() && user.getUpassword().equals(checkpwd)) { + model.setCode(1); + } else { + model.setCode(0); + } + model.setData(null); + return model; + } + + //鏌ヨ褰撳墠鐢ㄦ埛鐨勭敤鎴峰悕 + @GetMapping("uName") + @ApiOperation(notes = "", value = "鏌ヨ褰撳墠鐢ㄦ埛鐨勭敤鎴峰悕") + public ServiceModelImpl searchUname() { + User_inf user = (User_inf) ActionUtil.getUser(); + ServiceModelImpl model = new ServiceModelImpl(); + if (user != null) { + model.setCode(1); + model.setMsgN(user.getuName()); + } else { + model.setCode(0); + model.setMsg("You are not logged in, please log in"); + } + + return model; + } + + //鐣岄潰璇锋眰鐩戞祴鏈嶅姟鏄惁鏂紑 + @PostMapping("checkService") + @ApiOperation(notes = "", value = "鐣岄潰璇锋眰鐩戞祴鏈嶅姟鏄惁鏂紑") + public ServiceModel checkService(@RequestBody ServiceModel model) { + return model; + } + + //鍖呮満缁勯噸鍋氾紙绌挎妗嗭級鏌ヨ鎵�鏈夌殑鐢ㄦ埛 + @GetMapping("csAll") + @ApiOperation(notes = "", value = "鍖呮満缁勯噸鍋氾紙绌挎妗嗭級鏌ヨ鎵�鏈夌殑鐢ㄦ埛") + public ServiceModel searchCS_All() { + ServiceModel model = service.searchCS_All(); + + return model; + } } -- Gitblit v1.9.1