diff --git a/src/main/java/com/cm/serviceusercenter/controller/app/apis/appversion/AppVersionAppController.java b/src/main/java/com/cm/serviceusercenter/controller/app/apis/appversion/AppVersionAppController.java index 70491a4..b3eb13b 100644 --- a/src/main/java/com/cm/serviceusercenter/controller/app/apis/appversion/AppVersionAppController.java +++ b/src/main/java/com/cm/serviceusercenter/controller/app/apis/appversion/AppVersionAppController.java @@ -6,12 +6,14 @@ import com.cm.common.exception.FileException; import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.common.result.ErrorResult; -import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.serviceusercenter.service.appversion.IAppVersionService; import io.swagger.annotations.*; 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.HttpServletResponse; @@ -53,8 +55,8 @@ public class AppVersionAppController extends AbstractController { @ApiImplicitParam(name = "appVersionId", value = "app版本ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("downloadapp/{appVersionId}") - public void downloadApp(@PathVariable("appVersionId") String appVersionId, HttpServletRequest request, HttpServletResponse response) throws SearchException, FileException, UpdateException { + @GetMapping("download/{appVersionId}") + public void download(@PathVariable("appVersionId") String appVersionId, HttpServletRequest request, HttpServletResponse response) throws SearchException, FileException, UpdateException { Map params = getParams(); params.put("appVersionId", appVersionId); params.put("isRelease", 1); diff --git a/src/main/java/com/cm/serviceusercenter/controller/resources/system/user/UserResourceController.java b/src/main/java/com/cm/serviceusercenter/controller/resources/system/user/UserResourceController.java index adca1b5..ba8d669 100644 --- a/src/main/java/com/cm/serviceusercenter/controller/resources/system/user/UserResourceController.java +++ b/src/main/java/com/cm/serviceusercenter/controller/resources/system/user/UserResourceController.java @@ -31,8 +31,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -218,9 +216,9 @@ public class UserResourceController extends BaseController { @ApiOperation(value = "修改密码", notes = "修改密码接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("updateuserpassword") + @PostMapping("updateuserpassword/{userId}") @CheckRequestBodyAnnotation - public SuccessResult updateUserPassword(AppChangePasswordVO appChangePasswordVO) throws ParamsException, SearchException, UpdateException { + public SuccessResult updateUserPassword(@PathVariable("userId") String userId, AppChangePasswordVO appChangePasswordVO) throws ParamsException, SearchException, UpdateException { Map config = ConfigManager.getInstance().getConfig(); if (config.get(IUserService.PASSWORD_STRENGTH) != null) { String passwordStrength = config.get(IUserService.PASSWORD_STRENGTH).toString(); @@ -237,7 +235,7 @@ public class UserResourceController extends BaseController { Map params = getParams(); params.put("oldPassword", appChangePasswordVO.getOldPassword()); params.put("newPassword", appChangePasswordVO.getNewPassword()); - return userService.updateUserPassword(params); + return userService.updateUserPasswordByUserId(userId, params); } @ApiOperation(value = "获取密码状态", notes = "获取密码状态接口") diff --git a/src/main/java/com/cm/serviceusercenter/service/system/user/IUserService.java b/src/main/java/com/cm/serviceusercenter/service/system/user/IUserService.java index d4dba29..3f7d63d 100644 --- a/src/main/java/com/cm/serviceusercenter/service/system/user/IUserService.java +++ b/src/main/java/com/cm/serviceusercenter/service/system/user/IUserService.java @@ -4,7 +4,6 @@ import com.cm.common.exception.RemoveException; import com.cm.common.exception.SaveException; import com.cm.common.exception.SearchException; 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.pojo.ListPage; 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.UserVO; import com.cm.serviceusercenter.pojo.vos.user.*; -import io.micrometer.core.instrument.search.Search; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; @@ -405,6 +403,16 @@ public interface IUserService { */ SuccessResult updateUserPassword(String token, Map params) throws SearchException, UpdateException; + /** + * 修改用户密码 + * @param userId + * @param params + * @return + * @throws SearchException + * @throws UpdateException + */ + SuccessResult updateUserPasswordByUserId(String userId, Map params) throws SearchException, UpdateException; + /** * 获取用户APP设备列表 * @@ -873,4 +881,6 @@ public interface IUserService { */ List listUserDepartmentResourceByPositionIds(List positionIds) throws SearchException; + + } diff --git a/src/main/java/com/cm/serviceusercenter/service/system/user/impl/UserServiceImpl.java b/src/main/java/com/cm/serviceusercenter/service/system/user/impl/UserServiceImpl.java index 2d2afa7..f894aeb 100644 --- a/src/main/java/com/cm/serviceusercenter/service/system/user/impl/UserServiceImpl.java +++ b/src/main/java/com/cm/serviceusercenter/service/system/user/impl/UserServiceImpl.java @@ -6,7 +6,6 @@ import com.cm.common.constants.ISystemConstant; import com.cm.common.enums.RoleDataAuthorityEnum; import com.cm.common.exception.*; 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.user.UserDepartmentResourceBO; import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO; @@ -595,6 +594,7 @@ public class UserServiceImpl extends BaseService implements IUserService { return userDepartmentResourceBOs; } + /** * 部门ID列表 * @@ -958,6 +958,24 @@ public class UserServiceImpl extends BaseService implements IUserService { return new SuccessResult(); } + @Override + public SuccessResult updateUserPasswordByUserId(String userId, Map 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 public List listUserAppDevice(Map params) throws SearchException { return userDao.listUserAppDevice(params);