提交 a22110a9 authored 作者: gongwenjie's avatar gongwenjie

合并分支 'gwj' 到 'master'

Gwj 查看合并请求 !18
流水线 #24 已取消 于阶段
...@@ -89,4 +89,5 @@ public interface PasUserDao extends MongoRepository<User, String> { ...@@ -89,4 +89,5 @@ public interface PasUserDao extends MongoRepository<User, String> {
List<User> findAllByDepartmentIdIn(List<String> departmentIds); List<User> findAllByDepartmentIdIn(List<String> departmentIds);
} }
...@@ -32,6 +32,9 @@ public class Department { ...@@ -32,6 +32,9 @@ public class Department {
@NotNull(message = "部门等级不可为空") @NotNull(message = "部门等级不可为空")
String level; String level;
@ApiModelProperty(value = "部门描述",example = "1")
String description;
@ApiModelProperty(value = "上级部门id",example = "1") @ApiModelProperty(value = "上级部门id",example = "1")
String parentId; String parentId;
......
...@@ -8,9 +8,12 @@ import io.swagger.annotations.Api; ...@@ -8,9 +8,12 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import static org.springframework.http.ResponseEntity.ok; import static org.springframework.http.ResponseEntity.ok;
...@@ -29,7 +32,7 @@ public class UserManageController { ...@@ -29,7 +32,7 @@ public class UserManageController {
@ApiOperation(value = "根据id查询用户", response = User.class) @ApiOperation(value = "根据id查询用户", response = User.class)
@GetMapping("/findUser/{id}") @GetMapping("/findUser/{id}")
public ResponseEntity addUser(@RequestBody @Valid String id) { public ResponseEntity findUser(@RequestBody @Valid String id) {
return ok(userManageService.findUserById(id)); return ok(userManageService.findUserById(id));
} }
...@@ -53,4 +56,29 @@ public class UserManageController { ...@@ -53,4 +56,29 @@ public class UserManageController {
// return ok(userManageService.findUserWork(id,status)); // return ok(userManageService.findUserWork(id,status));
// } // }
@ApiOperation(value = "更新当前用户自身信息")
@PutMapping("/updateSelf")
public ResponseEntity updateSelf(@RequestBody @NotNull User user){
User userById = userManageService.findUserById(user.getId());
boolean b = userManageService.updateSelf(user,userById);
if(b){
return ok("更改密码成功");
}
return ok("更改密码失败");
}
@ApiOperation(value = "更新当前用户密码")
@PutMapping("/password")
public ResponseEntity updatePassword(@RequestBody @NotNull User user){
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User principal = (User) authentication.getPrincipal();
User userByUsername = userManageService.findfindUserByUsername(principal.getUsername());
userByUsername.setPassword(user.getPassword());
boolean b = userManageService.updatePas(userByUsername);
if(b){
return ok("更改密码成功");
}
return ok("更改密码失败");
}
} }
...@@ -34,6 +34,22 @@ public interface UserManageService { ...@@ -34,6 +34,22 @@ public interface UserManageService {
*/ */
List<Department> findDepartmentList(String id); List<Department> findDepartmentList(String id);
boolean updatePas(User user);
/**
* 根据用户名查询用户
* @param username
* @return
*/
User findfindUserByUsername(String username);
/**
* 修改用户自身信息
* @param userById
* @return
*/
boolean updateSelf(User user,User userById);
// /** // /**
// * 根据任务状态查询人员任务列表 // * 根据任务状态查询人员任务列表
// * @param id // * @param id
......
...@@ -11,6 +11,7 @@ import com.zjty.tynotes.pas.entity.vo.PageResponse; ...@@ -11,6 +11,7 @@ import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.entity.vo.UserVo; import com.zjty.tynotes.weekly.subject.entity.vo.UserVo;
import com.zjty.tynotes.weekly.subject.service.UserManageService; import com.zjty.tynotes.weekly.subject.service.UserManageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -21,7 +22,8 @@ import java.util.*; ...@@ -21,7 +22,8 @@ import java.util.*;
*/ */
@Service @Service
public class UserManageServiceImpl implements UserManageService { public class UserManageServiceImpl implements UserManageService {
@Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
@Autowired @Autowired
private PasUserDao pasUserDao; private PasUserDao pasUserDao;
@Autowired @Autowired
...@@ -162,6 +164,28 @@ public class UserManageServiceImpl implements UserManageService { ...@@ -162,6 +164,28 @@ public class UserManageServiceImpl implements UserManageService {
} }
@Override
public boolean updatePas(User user) {
String encode = bCryptPasswordEncoder.encode(user.getPassword());
user.setPassword(encode);
pasUserDao.save(user);
return true;
}
@Override
public User findfindUserByUsername(String username) {
return pasUserDao.findByUsername(username);
}
@Override
public boolean updateSelf(User user,User userById) {
userById.setPhone1(user.getPhone1());
userById.setPhone2(user.getPhone2());
userById.setEmail(user.getEmail());
userById.setAddress(user.getAddress());
return false;
}
private List<Department> findDepartmentList(List<Department> des, List<Department> deps){ private List<Department> findDepartmentList(List<Department> des, List<Department> deps){
for (Department department : deps) { for (Department department : deps) {
if(!des.contains(department)){ if(!des.contains(department)){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论