Преглед на файлове

app账户管理新增修改密码

李书文 преди 1 година
родител
ревизия
72cb65007e

+ 10 - 0
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserController.java

@@ -4,9 +4,11 @@ import java.util.List;
 
 import com.pj.api.dto.*;
 
+import com.pj.project.app_user.dto.PassDto;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import com.pj.utils.sg.*;
@@ -61,6 +63,14 @@ public class AppUserController {
 		return AjaxJson.getSuccess();
 	}
 
+	/** 修改密码 */
+	@RequestMapping("pass")
+	@SaCheckPermission( AppUser.PERMISSION_CODE_EDIT)
+	public AjaxJson pass(@Validated PassDto dto){
+		System.out.println("dto:"+dto.getPassword());
+		return AjaxJson.toAjax(appUserService.pass(dto));
+	}
+
 	/** 查 - 根据id */
 	@RequestMapping("getById")
 		@SaCheckPermission(AppUser.PERMISSION_CODE)

+ 14 - 0
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

@@ -29,6 +29,7 @@ import com.pj.enummj.IsLock;
 import com.pj.enummj.Status;
 import com.pj.project.app_user.dto.ForgetPasswordDto;
 import com.pj.project.app_user.dto.LoginDto;
+import com.pj.project.app_user.dto.PassDto;
 import com.pj.project.app_user.dto.RegisterDto;
 import com.pj.project.app_user.vo.AppUserVo;
 import com.pj.project.app_user_login_log.AppUserLoginLog;
@@ -128,6 +129,19 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
     }
 
     /**
+     * 修改密码
+     * @param dto
+     * @return
+     */
+    boolean pass(PassDto dto) {
+        AppUser user=new AppUser();
+        user.setId(dto.getId());
+        user.setUpdateTime(new Date());
+        user.setPassword(passwordEncoder.encode(dto.getPassword()));
+        return updateById(user);
+    }
+
+    /**
      * 查
      */
     AppUser getById(Long id) {

+ 16 - 0
sp-service/sp-admin/src/main/java/com/pj/project/app_user/dto/PassDto.java

@@ -0,0 +1,16 @@
+package com.pj.project.app_user.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class PassDto {
+
+    @NotNull(message = "id不能为空!")
+    private Long id;
+
+    @Size(min = 8, message = "密码不能少于8位")
+    private String password;
+}