From 28b5cc39d0a2d9939f70b4c980a31d9b27fc1e4c Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 19 七月 2022 14:27:30 +0800 Subject: [PATCH] 修复更新推流状态sql错误 --- src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java | 72 +++++++++++++++++++++++++++++++++-- 1 files changed, 67 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index 17fe2fb..ca6fc84 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -6,7 +6,9 @@ import com.genersoft.iot.vmp.service.IUserService; import com.genersoft.iot.vmp.storager.dao.dto.Role; import com.genersoft.iot.vmp.storager.dao.dto.User; +import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; +import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -20,7 +22,6 @@ import org.springframework.web.bind.annotation.*; import javax.security.sasl.AuthenticationException; -import java.text.SimpleDateFormat; import java.util.List; @Api(tags = "鐢ㄦ埛绠$悊") @@ -37,8 +38,6 @@ @Autowired private IRoleService roleService; - - private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @ApiOperation("鐧诲綍") @ApiImplicitParams({ @@ -135,8 +134,8 @@ return new ResponseEntity<>(result, HttpStatus.OK); } user.setRole(role); - user.setCreateTime(format.format(System.currentTimeMillis())); - user.setUpdateTime(format.format(System.currentTimeMillis())); + user.setCreateTime(DateUtil.getNow()); + user.setUpdateTime(DateUtil.getNow()); int addResult = userService.addUser(user); result.setCode(addResult > 0 ? 0 : -1); @@ -179,4 +178,67 @@ result.setData(allUsers); return new ResponseEntity<>(result, HttpStatus.OK); } + + /** + * 鍒嗛〉鏌ヨ鐢ㄦ埛 + * + * @param page 褰撳墠椤� + * @param count 姣忛〉鏌ヨ鏁伴噺 + * @return 鍒嗛〉鐢ㄦ埛鍒楄〃 + */ + @ApiOperation("鍒嗛〉鏌ヨ鐢ㄦ埛") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "褰撳墠椤�", required = true, dataTypeClass = Integer.class), + @ApiImplicitParam(name = "count", value = "姣忛〉鏌ヨ鏁伴噺", required = true, dataTypeClass = Integer.class), + }) + @GetMapping("/users") + public PageInfo<User> users(int page, int count) { + return userService.getUsers(page, count); + } + + @ApiOperation("閲嶇疆pushkey") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", required = true, value = "鐢ㄦ埛Id", dataTypeClass = Integer.class), + }) + @RequestMapping("/resetPushKey") + public ResponseEntity<WVPResult<String>> resetPushKey(@RequestParam Integer id) { + // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛id + int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); + WVPResult<String> result = new WVPResult<>(); + if (currenRoleId != 1) { + // 鍙敤瑙掕壊id涓�0鎵嶅彲浠ュ垹闄ゅ拰娣诲姞鐢ㄦ埛 + result.setCode(-1); + result.setMsg("鐢ㄦ埛鏃犳潈闄�"); + return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); + } + int resetPushKeyResult = userService.resetPushKey(id); + + result.setCode(resetPushKeyResult > 0 ? 0 : -1); + result.setMsg(resetPushKeyResult > 0 ? "success" : "fail"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + + @ApiOperation("绠$悊鍛樹慨鏀规櫘閫氱敤鎴峰瘑鐮�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "adminId", required = true, value = "绠$悊鍛榠d", dataTypeClass = String.class), + @ApiImplicitParam(name = "userId", required = true, value = "鐢ㄦ埛id", dataTypeClass = String.class), + @ApiImplicitParam(name = "password", required = true, value = "鏂板瘑鐮侊紙鏈猰d5鍔犲瘑鐨勫瘑鐮侊級", dataTypeClass = String.class), + }) + @PostMapping("/changePasswordForAdmin") + public String changePasswordForAdmin(@RequestParam int userId, @RequestParam String password) { + // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛id + LoginUser userInfo = SecurityUtils.getUserInfo(); + if (userInfo == null) { + return "fail"; + } + Role role = userInfo.getRole(); + if (role != null && role.getId() == 1) { + boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes())); + if (result) { + return "success"; + } + } + + return "fail"; + } } -- Gitblit v1.8.0