修改密码问题
This commit is contained in:
parent
9fa57f992d
commit
d0f245fc49
@ -6,12 +6,14 @@ import com.cm.common.exception.FileException;
|
|||||||
import com.cm.common.exception.SearchException;
|
import com.cm.common.exception.SearchException;
|
||||||
import com.cm.common.exception.UpdateException;
|
import com.cm.common.exception.UpdateException;
|
||||||
import com.cm.common.result.ErrorResult;
|
import com.cm.common.result.ErrorResult;
|
||||||
import com.cm.common.result.SuccessResult;
|
|
||||||
import com.cm.common.result.SuccessResultData;
|
import com.cm.common.result.SuccessResultData;
|
||||||
import com.cm.serviceusercenter.service.appversion.IAppVersionService;
|
import com.cm.serviceusercenter.service.appversion.IAppVersionService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -53,8 +55,8 @@ public class AppVersionAppController extends AbstractController {
|
|||||||
@ApiImplicitParam(name = "appVersionId", value = "app版本ID", paramType = "path")
|
@ApiImplicitParam(name = "appVersionId", value = "app版本ID", paramType = "path")
|
||||||
})
|
})
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@GetMapping("downloadapp/{appVersionId}")
|
@GetMapping("download/{appVersionId}")
|
||||||
public void downloadApp(@PathVariable("appVersionId") String appVersionId, HttpServletRequest request, HttpServletResponse response) throws SearchException, FileException, UpdateException {
|
public void download(@PathVariable("appVersionId") String appVersionId, HttpServletRequest request, HttpServletResponse response) throws SearchException, FileException, UpdateException {
|
||||||
Map<String, Object> params = getParams();
|
Map<String, Object> params = getParams();
|
||||||
params.put("appVersionId", appVersionId);
|
params.put("appVersionId", appVersionId);
|
||||||
params.put("isRelease", 1);
|
params.put("isRelease", 1);
|
||||||
|
@ -31,8 +31,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -218,9 +216,9 @@ public class UserResourceController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation(value = "修改密码", notes = "修改密码接口")
|
@ApiOperation(value = "修改密码", notes = "修改密码接口")
|
||||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
@PostMapping("updateuserpassword")
|
@PostMapping("updateuserpassword/{userId}")
|
||||||
@CheckRequestBodyAnnotation
|
@CheckRequestBodyAnnotation
|
||||||
public SuccessResult updateUserPassword(AppChangePasswordVO appChangePasswordVO) throws ParamsException, SearchException, UpdateException {
|
public SuccessResult updateUserPassword(@PathVariable("userId") String userId, AppChangePasswordVO appChangePasswordVO) throws ParamsException, SearchException, UpdateException {
|
||||||
Map<String, Object> config = ConfigManager.getInstance().getConfig();
|
Map<String, Object> config = ConfigManager.getInstance().getConfig();
|
||||||
if (config.get(IUserService.PASSWORD_STRENGTH) != null) {
|
if (config.get(IUserService.PASSWORD_STRENGTH) != null) {
|
||||||
String passwordStrength = config.get(IUserService.PASSWORD_STRENGTH).toString();
|
String passwordStrength = config.get(IUserService.PASSWORD_STRENGTH).toString();
|
||||||
@ -237,7 +235,7 @@ public class UserResourceController extends BaseController {
|
|||||||
Map<String, Object> params = getParams();
|
Map<String, Object> params = getParams();
|
||||||
params.put("oldPassword", appChangePasswordVO.getOldPassword());
|
params.put("oldPassword", appChangePasswordVO.getOldPassword());
|
||||||
params.put("newPassword", appChangePasswordVO.getNewPassword());
|
params.put("newPassword", appChangePasswordVO.getNewPassword());
|
||||||
return userService.updateUserPassword(params);
|
return userService.updateUserPasswordByUserId(userId, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取密码状态", notes = "获取密码状态接口")
|
@ApiOperation(value = "获取密码状态", notes = "获取密码状态接口")
|
||||||
|
@ -4,7 +4,6 @@ import com.cm.common.exception.RemoveException;
|
|||||||
import com.cm.common.exception.SaveException;
|
import com.cm.common.exception.SaveException;
|
||||||
import com.cm.common.exception.SearchException;
|
import com.cm.common.exception.SearchException;
|
||||||
import com.cm.common.exception.UpdateException;
|
import com.cm.common.exception.UpdateException;
|
||||||
import com.cm.common.plugin.pojo.bos.UserResourceBO;
|
|
||||||
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
||||||
import com.cm.common.pojo.ListPage;
|
import com.cm.common.pojo.ListPage;
|
||||||
import com.cm.common.pojo.dtos.UserAttrInfoDTO;
|
import com.cm.common.pojo.dtos.UserAttrInfoDTO;
|
||||||
@ -21,7 +20,6 @@ import com.cm.serviceusercenter.pojo.pos.UserPO;
|
|||||||
import com.cm.serviceusercenter.pojo.vos.DepartmentUserVO;
|
import com.cm.serviceusercenter.pojo.vos.DepartmentUserVO;
|
||||||
import com.cm.serviceusercenter.pojo.vos.UserVO;
|
import com.cm.serviceusercenter.pojo.vos.UserVO;
|
||||||
import com.cm.serviceusercenter.pojo.vos.user.*;
|
import com.cm.serviceusercenter.pojo.vos.user.*;
|
||||||
import io.micrometer.core.instrument.search.Search;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -405,6 +403,16 @@ public interface IUserService {
|
|||||||
*/
|
*/
|
||||||
SuccessResult updateUserPassword(String token, Map<String, Object> params) throws SearchException, UpdateException;
|
SuccessResult updateUserPassword(String token, Map<String, Object> params) throws SearchException, UpdateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户密码
|
||||||
|
* @param userId
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
* @throws UpdateException
|
||||||
|
*/
|
||||||
|
SuccessResult updateUserPasswordByUserId(String userId, Map<String, Object> params) throws SearchException, UpdateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户APP设备列表
|
* 获取用户APP设备列表
|
||||||
*
|
*
|
||||||
@ -873,4 +881,6 @@ public interface IUserService {
|
|||||||
*/
|
*/
|
||||||
List<UserDepartmentResourceBO> listUserDepartmentResourceByPositionIds(List<String> positionIds) throws SearchException;
|
List<UserDepartmentResourceBO> listUserDepartmentResourceByPositionIds(List<String> positionIds) throws SearchException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.cm.common.constants.ISystemConstant;
|
|||||||
import com.cm.common.enums.RoleDataAuthorityEnum;
|
import com.cm.common.enums.RoleDataAuthorityEnum;
|
||||||
import com.cm.common.exception.*;
|
import com.cm.common.exception.*;
|
||||||
import com.cm.common.plugin.excel.error.AbstractErrorExcelHandler;
|
import com.cm.common.plugin.excel.error.AbstractErrorExcelHandler;
|
||||||
import com.cm.common.plugin.pojo.bos.UserResourceBO;
|
|
||||||
import com.cm.common.plugin.pojo.bos.department.DepartmentResourceBO;
|
import com.cm.common.plugin.pojo.bos.department.DepartmentResourceBO;
|
||||||
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
import com.cm.common.plugin.pojo.bos.user.UserDepartmentResourceBO;
|
||||||
import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO;
|
import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO;
|
||||||
@ -595,6 +594,7 @@ public class UserServiceImpl extends BaseService implements IUserService {
|
|||||||
return userDepartmentResourceBOs;
|
return userDepartmentResourceBOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID列表
|
* 部门ID列表
|
||||||
*
|
*
|
||||||
@ -958,6 +958,24 @@ public class UserServiceImpl extends BaseService implements IUserService {
|
|||||||
return new SuccessResult();
|
return new SuccessResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResult updateUserPasswordByUserId(String userId, Map<String, Object> params) throws SearchException, UpdateException {
|
||||||
|
String oldPassword = DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(params.get("oldPassword").toString())));
|
||||||
|
String newPassword = DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(params.get("newPassword").toString())));
|
||||||
|
params.clear();
|
||||||
|
params.put("userId", userId);
|
||||||
|
UserPO userPO = userDao.getUserPO(params);
|
||||||
|
if (!passwordEncoder.matches(oldPassword, userPO.getUserPassword())) {
|
||||||
|
throw new UpdateException("旧密码错误");
|
||||||
|
}
|
||||||
|
params.put("userPassword", passwordEncoder.encode(newPassword));
|
||||||
|
params.put("gmtPasswordModified", DateUtil.getDay());
|
||||||
|
setUpdateInfoByUserId(params, userId);
|
||||||
|
userDao.updateUser(params);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserAppDevicePO> listUserAppDevice(Map<String, Object> params) throws SearchException {
|
public List<UserAppDevicePO> listUserAppDevice(Map<String, Object> params) throws SearchException {
|
||||||
return userDao.listUserAppDevice(params);
|
return userDao.listUserAppDevice(params);
|
||||||
|
Loading…
Reference in New Issue
Block a user