Browse Source

修改密码

xiongzhu 4 years ago
parent
commit
8c92a3fbf7

+ 3 - 0
src/main/java/com/izouma/nineth/domain/Collection.java

@@ -70,6 +70,9 @@ public class Collection extends BaseEntity {
     @ApiModelProperty("上架")
     private boolean onShelf;
 
+    @ApiModelProperty("可售")
+    private boolean salable;
+
     @ApiModelProperty("价格")
     @Column(precision = 10, scale = 2)
     private BigDecimal price;

+ 3 - 4
src/main/java/com/izouma/nineth/service/UserService.java

@@ -237,10 +237,9 @@ public class UserService {
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
     }
 
-    public String setPassword(Long userId, String key, String code, String password) {
-        if (!captchaService.verify(key, code)) {
-            throw new BusinessException("验证码错误");
-        }
+    public String setPassword(Long userId, String code, String password) {
+        User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
+        smsService.verify(user.getPhone(), code);
         return setPassword(userId, password);
     }
 

+ 2 - 2
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -76,8 +76,8 @@ public class CollectionController extends BaseController {
 
     @GetMapping("/myLikes")
     @ApiOperation("我收藏的")
-    public List<CollectionDTO> myLikes( ) {
-       return  collectionService.toDTO(collectionRepo.userLikes(SecurityUtils.getAuthenticatedUser().getId()));
+    public List<CollectionDTO> myLikes() {
+        return collectionService.toDTO(collectionRepo.userLikes(SecurityUtils.getAuthenticatedUser().getId()));
     }
 }
 

+ 2 - 2
src/main/java/com/izouma/nineth/web/UserController.java

@@ -123,8 +123,8 @@ public class UserController extends BaseController {
     }
 
     @PostMapping("/changePassword")
-    public String changePassword(@RequestParam String password, @RequestParam String key, @RequestParam String code) {
-        return userService.setPassword(SecurityUtils.getAuthenticatedUser().getId(), key, code, password);
+    public String changePassword(@RequestParam String password, @RequestParam String code) {
+        return userService.setPassword(SecurityUtils.getAuthenticatedUser().getId(), code, password);
     }
 
     @PreAuthorize("hasRole('ADMIN')")