Compare commits

..

No commits in common. "ceda53a5aec6ff22d4d761c29f15a08adcf93148" and "ffb3dbac36cb02bcead237314388b031ac1993f1" have entirely different histories.

9 changed files with 4 additions and 112 deletions

View File

@ -98,21 +98,6 @@ public class UserCacheManager {
}
}
/**
* 清理用户缓存信息
* 用户信息变更时
* @param userName 用户名
*/
@Async
public void cleanEmployeesCache(String userName) {
// 转小写
userName = StringUtils.lowerCase(userName);
if (StringUtils.isNotEmpty(userName)) {
// 清除数据
redisUtils.del(LoginProperties.aCacheKey + userName);
}
}
public void addCustomerCache(String username, JwtUserDto customerDto) {
// 转小写
username = StringUtils.lowerCase(username);
@ -142,15 +127,4 @@ public class UserCacheManager {
redisUtils.set(LoginProperties.aCacheKey + username, employeeDto, time);
}
}
@Async
public void cleanCustomerCache(String username) {
// 转小写
username = StringUtils.lowerCase(username);
if (StringUtils.isNotEmpty(username)) {
// 清除数据
redisUtils.del(LoginProperties.bCacheKey + username);
}
}
}

View File

@ -2,15 +2,9 @@ package com.aircraft.modules.system.controller;
import com.aircraft.annotation.Log;
import com.aircraft.config.properties.RsaProperties;
import com.aircraft.exception.BadRequestException;
import com.aircraft.modules.system.domain.CnCustomer;
import com.aircraft.modules.system.domain.EmEmployees;
import com.aircraft.modules.system.domain.dto.UserPassVo;
import com.aircraft.modules.system.service.CnCustomerService;
import com.aircraft.utils.PageResult;
import com.aircraft.utils.RsaUtils;
import com.aircraft.utils.SecurityUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -118,22 +112,5 @@ public class CnCustomerController {
return new ResponseEntity<>(Collections.emptyList(),HttpStatus.OK);
}
@ApiOperation("修改密码")
@PostMapping(value = "/updatePass")
public ResponseEntity<Object> updateUserPass(@RequestBody UserPassVo passVo) throws Exception {
CnCustomer customer = entityService.findByUserName(SecurityUtils.getCurrentUsername());
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass());
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass());
if(!passwordEncoder.matches(oldPass, customer.getPassword())){
throw new BadRequestException("修改失败,旧密码错误");
}
if(passwordEncoder.matches(newPass, customer.getPassword())){
throw new BadRequestException("新密码不能与旧密码相同");
}
entityService.updatePass(customer.getUsername(),passwordEncoder.encode(newPass));
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -126,17 +126,17 @@ public class EmEmployeesController {
@ApiOperation("修改密码")
@PostMapping(value = "/updatePass")
public ResponseEntity<Object> updateUserPass(@RequestBody UserPassVo passVo) throws Exception {
EmEmployees emEmployees = emEmployeesService.findByUserName(SecurityUtils.getCurrentUsername());
User user = userService.findByName(SecurityUtils.getCurrentUsername());
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass());
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass());
if(!passwordEncoder.matches(oldPass, emEmployees.getPassword())){
if(!passwordEncoder.matches(oldPass, user.getPassword())){
throw new BadRequestException("修改失败,旧密码错误");
}
if(passwordEncoder.matches(newPass, emEmployees.getPassword())){
if(passwordEncoder.matches(newPass, user.getPassword())){
throw new BadRequestException("新密码不能与旧密码相同");
}
emEmployeesService.updatePass(emEmployees.getUsername(),passwordEncoder.encode(newPass));
userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass));
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@ -3,8 +3,6 @@ package com.aircraft.modules.system.mapper;
import com.aircraft.modules.system.domain.CnCustomer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* <p>
@ -17,6 +15,4 @@ import org.apache.ibatis.annotations.Select;
@Mapper
public interface CnCustomerMapper extends BaseMapper<CnCustomer> {
@Select("update cn_customer set password = #{password} where username = #{username}")
void updatePass(@Param("username") String username, @Param("password") String password);
}

View File

@ -17,8 +17,6 @@ package com.aircraft.modules.system.mapper;
import com.aircraft.modules.system.domain.EmEmployees;
import com.aircraft.modules.system.domain.dto.EmEmployeesQueryCriteria;
import java.util.Date;
import java.util.List;
import java.util.Set;
@ -30,7 +28,6 @@ import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;
/**
* @author lhb
@ -46,7 +43,4 @@ public interface EmEmployeesMapper extends BaseMapper<EmEmployees> {
List<EmEmployeesDetailVo> findByExample(@Param(Constants.WRAPPER) QueryWrapper<EmEmployeesDetailVo> queryWrapper, Page page);
void deleteBatchIds(@Param("ids") List<Long> ids);
@Select("update em_employees set password = #{password} where username = #{username}")
void updatePass(@Param("username") String username, @Param("password") String password);
}

View File

@ -40,11 +40,4 @@ public interface CnCustomerService extends IService<CnCustomer> {
CnCustomer findByPhone(String phone);
CnCustomer findByUserName(String username);
/**
* 修改密码
* @param username 用户名
* @param encryptPassword 密码
*/
void updatePass(String username, String encryptPassword);
}

View File

@ -108,18 +108,4 @@ public interface EmEmployeesService extends IService<EmEmployees> {
* @return List<EmEmployees>
*/
List<EmEmployees> obtainEmployeesByIds(List<Long> orderInitiatorIds);
/**
* 用户名查询飞行员
* @param currentUsername
* @return
*/
EmEmployees findByUserName(String currentUsername);
/**
* 修改密码
* @param username 用户名
* @param encryptPassword 密码
*/
void updatePass(String username, String encryptPassword);
}

View File

@ -1,7 +1,6 @@
package com.aircraft.modules.system.service.impl;
import com.aircraft.base.BaseEntity;
import com.aircraft.modules.security.service.UserCacheManager;
import com.aircraft.modules.system.domain.CnCustomer;
import com.aircraft.modules.system.mapper.CnCustomerMapper;
import com.aircraft.modules.system.service.CnCustomerService;
@ -11,7 +10,6 @@ import com.aircraft.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@ -24,12 +22,9 @@ import java.util.List;
* @author cli
* @since 2025-07-09
*/
@RequiredArgsConstructor
@Service
public class CnCustomerServiceImpl extends ServiceImpl<CnCustomerMapper, CnCustomer> implements CnCustomerService {
private final UserCacheManager userCacheManager;
@Override
public List<CnCustomer> list(CnCustomer example) {
return this.list(buildWrapper(example));
@ -58,12 +53,6 @@ public class CnCustomerServiceImpl extends ServiceImpl<CnCustomerMapper, CnCusto
return this.baseMapper.selectOne(queryWrapper);
}
@Override
public void updatePass(String username, String encryptPassword) {
this.baseMapper.updatePass(username, encryptPassword);
userCacheManager.cleanCustomerCache(username);
}
/**
* 构建查询
*

View File

@ -16,7 +16,6 @@
package com.aircraft.modules.system.service.impl;
import com.aircraft.base.BaseEntity;
import com.aircraft.modules.security.service.UserCacheManager;
import com.aircraft.modules.system.domain.EmEmployees;
import com.aircraft.modules.system.domain.vo.EmEmployeesDetailVo;
import com.aircraft.modules.system.domain.vo.EmEmployeesVo;
@ -54,7 +53,6 @@ public class EmEmployeesServiceImpl extends ServiceImpl<EmEmployeesMapper, EmEmp
private final EmAreaService areaService;
private final EmScenicService scenicService;
private final PasswordEncoder passwordEncoder;
private final UserCacheManager userCacheManager;
@Override
public PageResult<EmEmployees> queryAll(EmEmployeesQueryCriteria criteria, Page<Object> page){
@ -94,21 +92,6 @@ public class EmEmployeesServiceImpl extends ServiceImpl<EmEmployeesMapper, EmEmp
return this.list(Wrappers.lambdaQuery(EmEmployees.class).in(EmEmployees::getId,orderInitiatorIds));
}
@Override
public EmEmployees findByUserName(String currentUsername) {
QueryWrapper<EmEmployees> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.eq(EmEmployees::getUsername,currentUsername)
.eq(EmEmployees::getDelFlag,0);
return this.emEmployeesMapper.selectOne(queryWrapper);
}
@Override
public void updatePass(String username, String encryptPassword) {
emEmployeesMapper.updatePass(username, encryptPassword);
userCacheManager.cleanEmployeesCache(username);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(EmEmployees resources) {