Browse Source

修改密码接口

feature/teamB_zz_wgh
jianjun 3 years ago
parent
commit
ec3981e40a
  1. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java
  2. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/OperUserService.java
  3. 15
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/OperUserServiceImpl.java

20
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java

@ -18,6 +18,8 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -29,9 +31,11 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.OperUserDTO;
import com.epmet.dto.PasswordDTO;
import com.epmet.dto.result.QueryOperUserResultDto;
import com.epmet.excel.OperUserExcel;
import com.epmet.service.OperUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -82,6 +86,22 @@ public class OperUserController {
return new Result();
}
/**
* desc:修改运营端用户 密码
* @param tokenDto
* @param dto
* @return
*/
@PutMapping(value = "updatePwd")
public Result updatePwd(@LoginUser TokenDto tokenDto,@RequestBody PasswordDTO dto) {
if (StringUtils.isBlank(dto.getNewPassword())){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误","参数错误");
}
operUserService.updatePwd(tokenDto.getUserId(),dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids) {
//效验数据

10
epmet-user/epmet-user-server/src/main/java/com/epmet/service/OperUserService.java

@ -20,6 +20,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.OperUserDTO;
import com.epmet.dto.PasswordDTO;
import com.epmet.entity.OperUserEntity;
import java.util.List;
@ -99,4 +100,11 @@ public interface OperUserService extends BaseService<OperUserEntity> {
* @return
*/
OperUserDTO getOperUserInfoById(String id);
}
/**
* desc:修改密码
* @param userId
* @param dto
*/
void updatePwd(String userId, PasswordDTO dto);
}

15
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/OperUserServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -29,6 +30,7 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.OperUserDao;
import com.epmet.dto.OperUserDTO;
import com.epmet.dto.PasswordDTO;
import com.epmet.entity.OperUserEntity;
import com.epmet.entity.UserEntity;
import com.epmet.feign.OperRoleUserFeignClient;
@ -40,6 +42,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -142,4 +145,16 @@ public class OperUserServiceImpl extends BaseServiceImpl<OperUserDao, OperUserEn
return operUserDao.selectOperUserInfoById(id);
}
@Override
public void updatePwd(String userId, PasswordDTO dto) {
OperUserEntity param = new OperUserEntity();
param.setUserId(userId);
param.setPassword(PasswordUtils.encode(dto.getNewPassword()));
param.setUpdatedTime(new Date());
param.setUpdatedBy(userId);
LambdaQueryWrapper<OperUserEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OperUserEntity::getUserId,userId);
baseDao.update(param, lambdaQueryWrapper);
}
}

Loading…
Cancel
Save