@@ -29,9 +29,4 @@ public class FrontBaseController { | |||
this.userId = Integer.valueOf(data.get("id").toString()); | |||
} | |||
public Integer getUserId(HttpServletRequest request) { | |||
String token = request.getHeader("token"); | |||
return 1; | |||
} | |||
} |
@@ -3,13 +3,13 @@ package com.taauav.front.controller; | |||
import com.taauav.admin.entity.LsAdmin; | |||
import com.taauav.admin.service.ILsAdminService; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.util.FunctionUtils; | |||
import com.taauav.common.util.JwtUtil; | |||
import com.taauav.common.util.StringUtils; | |||
import com.taauav.front.dto.UpdatePwdDto; | |||
import io.jsonwebtoken.Claims; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.servlet.http.HttpServletRequest; | |||
@@ -28,7 +28,7 @@ public class LSUserController extends FrontBaseController { | |||
* | |||
* @return | |||
*/ | |||
@PostMapping("/info") | |||
@GetMapping("/info") | |||
public Response info(HttpServletRequest request) { | |||
String token = request.getHeader("token"); | |||
Claims data = JwtUtil.parseJWT(token); | |||
@@ -37,5 +37,51 @@ public class LSUserController extends FrontBaseController { | |||
return response.success(adminInfo); | |||
} | |||
/** | |||
* 修改密码 | |||
* | |||
* @param updatePwdDto 参数 | |||
* @return | |||
*/ | |||
@PostMapping("/editPassword") | |||
public Response editPassword(@RequestBody UpdatePwdDto updatePwdDto) { | |||
// 获取个人信息 | |||
LsAdmin adminInfo = adminService.getById(this.userId); | |||
if (adminInfo == null) { | |||
return response.failure("用户信息不存在"); | |||
} | |||
// 判断用户状态 | |||
if (adminInfo.getStatus() != 1) { | |||
return response.failure("账号被禁用"); | |||
} | |||
// 原密码验证 | |||
if (StringUtils.isEmpty(updatePwdDto.getOldPassword())) { | |||
return response.failure("原密码不能为空"); | |||
} | |||
String oldPwd = FunctionUtils.password(updatePwdDto.getOldPassword()); | |||
if (!oldPwd.equals(adminInfo.getPassword())) { | |||
return response.failure("原密码输入错误"); | |||
} | |||
// 新密码验证 | |||
if (StringUtils.isEmpty(updatePwdDto.getPassword())) { | |||
return response.failure("新密码不能为空"); | |||
} | |||
if (StringUtils.isEmpty(updatePwdDto.getRePassword())) { | |||
return response.failure("确认密码不能为空"); | |||
} | |||
if (!updatePwdDto.getPassword().equals(updatePwdDto.getRePassword())) { | |||
return response.failure("两次输入的密码不一致"); | |||
} | |||
String newPassword = FunctionUtils.password(updatePwdDto.getPassword()); | |||
if (newPassword.equals(adminInfo.getPassword())) { | |||
return response.failure("新密码和原密码不能重复"); | |||
} | |||
adminInfo.setPassword(newPassword); | |||
boolean result = adminService.updateById(adminInfo); | |||
if (!result) { | |||
return response.failure("密码修改失败"); | |||
} | |||
return response.success("密码修改成功"); | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.taauav.front.dto; | |||
import lombok.Data; | |||
/** | |||
* 修改密码Dto | |||
*/ | |||
@Data | |||
public class UpdatePwdDto { | |||
/** | |||
* 旧密码 | |||
*/ | |||
private String oldPassword; | |||
/** | |||
* 新密码 | |||
*/ | |||
private String password; | |||
/** | |||
* 确认密码 | |||
*/ | |||
private String rePassword; | |||
} |
@@ -107,46 +107,46 @@ public class LSReportServiceImpl extends BaseServiceImpl<LSReportMapper, TauvRep | |||
} | |||
queryWrapper.eq("mark", 1); | |||
// 数据权限 | |||
List<BigInteger> driverAreaList = new ArrayList<>(); | |||
// 获取当前登录人员信息 | |||
LsAdmin lsAdmin = lsAdminMapper.selectById(userId); | |||
// 遍历数据权限 | |||
Map<Integer, String> map = adminService.getAdminAuthData(userId); | |||
for (Map.Entry<Integer, String> entry : map.entrySet()) { | |||
if (entry.getKey() == 1) { | |||
// 查看本人负责的河湖 | |||
if (lsAdmin.getDriverArea() != null && !driverAreaList.contains(lsAdmin.getDriverArea())) { | |||
driverAreaList.add(lsAdmin.getDriverArea()); | |||
} | |||
} else if (entry.getKey() == 2) { | |||
// 查看本人及下属人员负责的河湖 | |||
if (lsAdmin.getDriverArea() != null && !driverAreaList.contains(lsAdmin.getDriverArea())) { | |||
driverAreaList.add(lsAdmin.getDriverArea()); | |||
} | |||
// 获取下属人员负责的河流 | |||
List<BigInteger> cityIdsList = lsCityService.getChildCityIds(lsAdmin.getDriverArea()); | |||
if (!cityIdsList.isEmpty()) { | |||
cityIdsList.forEach(item -> { | |||
driverAreaList.add(item); | |||
}); | |||
} | |||
} else if (entry.getKey() == 3) { | |||
// 查看指定部门下人员负责河湖数据 | |||
if (!StringUtils.isEmpty(entry.getValue())) { | |||
String[] itemArr = entry.getValue().split(","); | |||
for (String s : itemArr) { | |||
if (driverAreaList.contains(lsAdmin.getDriverArea())) { | |||
continue; | |||
} | |||
driverAreaList.add(BigInteger.valueOf(Long.valueOf(s))); | |||
} | |||
} | |||
} | |||
} | |||
// 加入查询条件 | |||
queryWrapper.in("driver_area", driverAreaList); | |||
// // 数据权限 | |||
// List<BigInteger> driverAreaList = new ArrayList<>(); | |||
// // 获取当前登录人员信息 | |||
// LsAdmin lsAdmin = lsAdminMapper.selectById(userId); | |||
// // 遍历数据权限 | |||
// Map<Integer, String> map = adminService.getAdminAuthData(userId); | |||
// for (Map.Entry<Integer, String> entry : map.entrySet()) { | |||
// if (entry.getKey() == 1) { | |||
// // 查看本人负责的河湖 | |||
// if (lsAdmin.getDriverArea() != null && !driverAreaList.contains(lsAdmin.getDriverArea())) { | |||
// driverAreaList.add(lsAdmin.getDriverArea()); | |||
// } | |||
// } else if (entry.getKey() == 2) { | |||
// // 查看本人及下属人员负责的河湖 | |||
// if (lsAdmin.getDriverArea() != null && !driverAreaList.contains(lsAdmin.getDriverArea())) { | |||
// driverAreaList.add(lsAdmin.getDriverArea()); | |||
// } | |||
// // 获取下属人员负责的河流 | |||
// List<BigInteger> cityIdsList = lsCityService.getChildCityIds(lsAdmin.getDriverArea()); | |||
// if (!cityIdsList.isEmpty()) { | |||
// cityIdsList.forEach(item -> { | |||
// driverAreaList.add(item); | |||
// }); | |||
// } | |||
// } else if (entry.getKey() == 3) { | |||
// // 查看指定部门下人员负责河湖数据 | |||
// if (!StringUtils.isEmpty(entry.getValue())) { | |||
// String[] itemArr = entry.getValue().split(","); | |||
// for (String s : itemArr) { | |||
// if (driverAreaList.contains(lsAdmin.getDriverArea())) { | |||
// continue; | |||
// } | |||
// driverAreaList.add(BigInteger.valueOf(Long.valueOf(s))); | |||
// } | |||
// } | |||
// } | |||
// } | |||
// | |||
// // 加入查询条件 | |||
// queryWrapper.in("driver_area", driverAreaList); | |||
// 查询数据 | |||
IPage<TauvReport> page = new Page<>(query.getPage(), query.getPageSize()); |