fix: 优化逻辑
This commit is contained in:
parent
8ed2545759
commit
459fff4fc5
@ -27,11 +27,17 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||||||
|
|
||||||
// 自动填充更新时间
|
// 自动填充更新时间
|
||||||
this.strictInsertFill(metaObject, "updatedAt", Date.class, now);
|
this.strictInsertFill(metaObject, "updatedAt", Date.class, now);
|
||||||
// 自动填充更新时间
|
try {
|
||||||
this.strictInsertFill(metaObject, "createdBy", String.class, SecurityUtils.getUserId());
|
String userId = SecurityUtils.getUserId();
|
||||||
|
// 自动填充更新时间
|
||||||
|
this.strictInsertFill(metaObject, "createdBy", String.class, userId );
|
||||||
|
|
||||||
|
// 自动填充更新时间
|
||||||
|
this.strictInsertFill(metaObject, "updatedBy", String.class, userId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// 自动填充更新时间
|
|
||||||
this.strictInsertFill(metaObject, "updatedBy", String.class, SecurityUtils.getUserId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +47,13 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||||||
public void updateFill(MetaObject metaObject) {
|
public void updateFill(MetaObject metaObject) {
|
||||||
// 自动填充更新时间
|
// 自动填充更新时间
|
||||||
this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date());
|
this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date());
|
||||||
// 自动填充更新人
|
try {
|
||||||
this.strictInsertFill(metaObject, "updatedBy", String.class, SecurityUtils.getUserId());
|
String userId = SecurityUtils.getUserId();
|
||||||
|
// 自动填充更新人
|
||||||
|
this.strictInsertFill(metaObject, "updatedBy", String.class, userId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,8 +67,9 @@ public class SdHycdDicController {
|
|||||||
public ResponseResult selectForDropdown(
|
public ResponseResult selectForDropdown(
|
||||||
@RequestParam(required = false) String hynm,
|
@RequestParam(required = false) String hynm,
|
||||||
@RequestParam(required = false) Integer grd,
|
@RequestParam(required = false) Integer grd,
|
||||||
@RequestParam(required = false) Integer lx) {
|
@RequestParam(required = false) Integer lx,
|
||||||
return ResponseResult.successData(hycdDicService.selectForDropdown(hynm, grd,lx));
|
@RequestParam(required = false) String phycd) {
|
||||||
|
return ResponseResult.successData(hycdDicService.selectForDropdown(hynm, grd,lx,phycd));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/regDropdown")
|
@GetMapping("/regDropdown")
|
||||||
@ -76,8 +77,9 @@ public class SdHycdDicController {
|
|||||||
public ResponseResult regDropdown(
|
public ResponseResult regDropdown(
|
||||||
@RequestParam(required = false) String hynm,
|
@RequestParam(required = false) String hynm,
|
||||||
@RequestParam(required = false) Integer grd,
|
@RequestParam(required = false) Integer grd,
|
||||||
@RequestParam(required = false) Integer lx) {
|
@RequestParam(required = false) Integer lx,
|
||||||
return ResponseResult.successData(hycdDicService.regDropdown(hynm, grd,lx));
|
@RequestParam(required = false) String phycd) {
|
||||||
|
return ResponseResult.successData(hycdDicService.regDropdown(hynm, grd,lx,phycd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public interface ISdHycdDicService extends IService<SdHycdDic> {
|
|||||||
/**
|
/**
|
||||||
* 下拉框列表查询(支持名称和级别过滤)
|
* 下拉框列表查询(支持名称和级别过滤)
|
||||||
*/
|
*/
|
||||||
List<SdHycdDic> selectForDropdown(String hynm, Integer grd,Integer lx);
|
List<SdHycdDic> selectForDropdown(String hynm, Integer grd,Integer lx,String phycd);
|
||||||
|
|
||||||
List<SdHycdDic> regDropdown(String hynm, Integer grd,Integer lx);
|
List<SdHycdDic> regDropdown(String hynm, Integer grd,Integer lx,String phycd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,9 +58,10 @@ public class SdHycdDicServiceImpl extends ServiceImpl<SdHycdDicMapper, SdHycdDic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SdHycdDic> selectForDropdown(String hynm, Integer grd, Integer lx) {
|
public List<SdHycdDic> selectForDropdown(String hynm, Integer grd, Integer lx,String phycd) {
|
||||||
return this.lambdaQuery()
|
return this.lambdaQuery()
|
||||||
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
||||||
|
.eq(phycd != null, SdHycdDic::getPhycd, phycd)
|
||||||
.eq(grd != null, SdHycdDic::getGrd, grd)
|
.eq(grd != null, SdHycdDic::getGrd, grd)
|
||||||
.eq(lx != null, SdHycdDic::getLx, lx)
|
.eq(lx != null, SdHycdDic::getLx, lx)
|
||||||
.orderByAsc(SdHycdDic::getOrderIndex)
|
.orderByAsc(SdHycdDic::getOrderIndex)
|
||||||
@ -68,9 +69,10 @@ public class SdHycdDicServiceImpl extends ServiceImpl<SdHycdDicMapper, SdHycdDic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SdHycdDic> regDropdown(String hynm, Integer grd,Integer lx) {
|
public List<SdHycdDic> regDropdown(String hynm, Integer grd,Integer lx,String phycd) {
|
||||||
return this.lambdaQuery()
|
return this.lambdaQuery()
|
||||||
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
.like(hynm != null && !hynm.isEmpty(), SdHycdDic::getHynm, hynm)
|
||||||
|
.eq(phycd != null, SdHycdDic::getPhycd, phycd)
|
||||||
.eq(grd != null, SdHycdDic::getGrd, grd)
|
.eq(grd != null, SdHycdDic::getGrd, grd)
|
||||||
.eq(lx != null, SdHycdDic::getLx, lx)
|
.eq(lx != null, SdHycdDic::getLx, lx)
|
||||||
.orderByAsc(SdHycdDic::getOrderIndex)
|
.orderByAsc(SdHycdDic::getOrderIndex)
|
||||||
|
|||||||
@ -4,6 +4,11 @@ import cn.hutool.json.JSONUtil;
|
|||||||
import cn.hutool.jwt.JWTUtil;
|
import cn.hutool.jwt.JWTUtil;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.config.WebConfig;
|
import com.yfd.platform.config.WebConfig;
|
||||||
|
import com.yfd.platform.data.domain.SysUserDataScope;
|
||||||
|
import com.yfd.platform.data.service.ISysUserDataScopeService;
|
||||||
|
import com.yfd.platform.env.domain.SdEngInfoBH;
|
||||||
|
import com.yfd.platform.env.service.ISdEngInfoBHService;
|
||||||
|
import com.yfd.platform.env.service.ISdHbrvDicService;
|
||||||
import com.yfd.platform.system.domain.*;
|
import com.yfd.platform.system.domain.*;
|
||||||
import com.yfd.platform.system.mapper.SysMenuMapper;
|
import com.yfd.platform.system.mapper.SysMenuMapper;
|
||||||
import com.yfd.platform.system.service.ISmsVerifyCodeService;
|
import com.yfd.platform.system.service.ISmsVerifyCodeService;
|
||||||
@ -21,10 +26,12 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -51,6 +58,15 @@ public class SmsVerifyCodeController {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysMenuMapper sysMenuMapper;
|
private SysMenuMapper sysMenuMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISysUserDataScopeService sysUserDataScopeService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISdEngInfoBHService engInfoBHService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISdHbrvDicService hbrvDicService;
|
||||||
|
|
||||||
@Value("${rsa.private_key}")
|
@Value("${rsa.private_key}")
|
||||||
private String privateKey;
|
private String privateKey;
|
||||||
|
|
||||||
@ -113,6 +129,7 @@ public class SmsVerifyCodeController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@Operation(summary = "注册用户")
|
@Operation(summary = "注册用户")
|
||||||
|
@Transactional
|
||||||
public ResponseResult register(@RequestBody SmsVerifyCodeRequest smsVerifyCodeRequest) {
|
public ResponseResult register(@RequestBody SmsVerifyCodeRequest smsVerifyCodeRequest) {
|
||||||
String code = smsVerifyCodeRequest.getCode();
|
String code = smsVerifyCodeRequest.getCode();
|
||||||
if (smsVerifyCodeRequest.getPhone() == null || smsVerifyCodeRequest.getPhone().isEmpty()) {
|
if (smsVerifyCodeRequest.getPhone() == null || smsVerifyCodeRequest.getPhone().isEmpty()) {
|
||||||
@ -158,7 +175,10 @@ public class SmsVerifyCodeController {
|
|||||||
user.setCompanyCode(smsVerifyCodeRequest.getCompanyCode());
|
user.setCompanyCode(smsVerifyCodeRequest.getCompanyCode());
|
||||||
boolean success = userService.save(user);
|
boolean success = userService.save(user);
|
||||||
// 给注册用户加上默认权限
|
// 给注册用户加上默认权限
|
||||||
this.addDefaultRole(smsVerifyCodeRequest);
|
SysUser savedUser = userService.getUserByPhone(smsVerifyCodeRequest.getPhone());
|
||||||
|
if (savedUser != null) {
|
||||||
|
this.addDefaultRole(savedUser.getId(), smsVerifyCodeRequest);
|
||||||
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
} else {
|
} else {
|
||||||
@ -166,11 +186,100 @@ public class SmsVerifyCodeController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addDefaultRole(SmsVerifyCodeRequest smsVerifyCodeRequest) {
|
private boolean addDefaultRole(String userId, SmsVerifyCodeRequest smsVerifyCodeRequest) {
|
||||||
|
if (userId == null || userId.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String stationCode = smsVerifyCodeRequest.getStationCode();
|
String stationCode = smsVerifyCodeRequest.getStationCode();
|
||||||
String hbrvcdCode = smsVerifyCodeRequest.getHbrvcdCode();
|
String hbrvcdCode = smsVerifyCodeRequest.getHbrvcdCode();
|
||||||
|
|
||||||
|
Set<String> selectedStationCodes = new HashSet<>();
|
||||||
|
if (StringUtils.isNotEmpty(stationCode)) {
|
||||||
|
selectedStationCodes.addAll(Arrays.asList(stationCode.split(",")));
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> selectedBasinCodes = new HashSet<>();
|
||||||
|
if (StringUtils.isNotEmpty(hbrvcdCode)) {
|
||||||
|
selectedBasinCodes.addAll(Arrays.asList(hbrvcdCode.split(",")));
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> addedStationCodes = new HashSet<>();
|
||||||
|
|
||||||
|
for (String basinCode : selectedBasinCodes) {
|
||||||
|
if (StringUtils.isEmpty(basinCode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SdEngInfoBH> allStationsInBasin = engInfoBHService.lambdaQuery()
|
||||||
|
.eq(SdEngInfoBH::getHbrvcd, basinCode)
|
||||||
|
.list();
|
||||||
|
|
||||||
|
if (allStationsInBasin == null || allStationsInBasin.isEmpty()) {
|
||||||
|
SysUserDataScope scope = new SysUserDataScope();
|
||||||
|
scope.setUserId(userId);
|
||||||
|
scope.setOrgType("HBRVCD");
|
||||||
|
scope.setOrgId(basinCode);
|
||||||
|
scope.setStatus(1);
|
||||||
|
scope.setPermissionType("READ");
|
||||||
|
sysUserDataScopeService.addDataScope(scope);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> allStationCodesInBasin = allStationsInBasin.stream()
|
||||||
|
.map(SdEngInfoBH::getStcd)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
boolean allStationsSelected = allStationCodesInBasin.containsAll(selectedStationCodes)
|
||||||
|
&& selectedStationCodes.containsAll(allStationCodesInBasin);
|
||||||
|
|
||||||
|
if (allStationsSelected) {
|
||||||
|
SysUserDataScope scope = new SysUserDataScope();
|
||||||
|
scope.setUserId(userId);
|
||||||
|
scope.setOrgType("HBRVCD");
|
||||||
|
scope.setOrgId(basinCode);
|
||||||
|
scope.setStatus(1);
|
||||||
|
scope.setPermissionType("READ");
|
||||||
|
sysUserDataScopeService.addDataScope(scope);
|
||||||
|
addedStationCodes.add(basinCode);
|
||||||
|
} else {
|
||||||
|
Set<String> stationsInBasinAndSelected = allStationCodesInBasin.stream()
|
||||||
|
.filter(selectedStationCodes::contains)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
for (String stationCd : stationsInBasinAndSelected) {
|
||||||
|
SysUserDataScope scope = new SysUserDataScope();
|
||||||
|
scope.setUserId(userId);
|
||||||
|
scope.setOrgType("STATION");
|
||||||
|
scope.setOrgId(stationCd);
|
||||||
|
scope.setStatus(1);
|
||||||
|
scope.setPermissionType("READ");
|
||||||
|
sysUserDataScopeService.addDataScope(scope);
|
||||||
|
addedStationCodes.add(stationCd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> standaloneStations = selectedStationCodes.stream()
|
||||||
|
.filter(code -> !addedStationCodes.contains(code))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
for (String stationCd : standaloneStations) {
|
||||||
|
if (StringUtils.isEmpty(stationCd)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SysUserDataScope scope = new SysUserDataScope();
|
||||||
|
scope.setUserId(userId);
|
||||||
|
scope.setOrgType("STATION");
|
||||||
|
scope.setOrgId(stationCd);
|
||||||
|
scope.setStatus(1);
|
||||||
|
scope.setPermissionType("READ");
|
||||||
|
sysUserDataScopeService.addDataScope(scope);
|
||||||
|
}
|
||||||
|
SysUser user = new SysUser();
|
||||||
|
user.setId(userId);
|
||||||
|
userService.updateUserRoles( user,"c13481a486c9ee559cf305284df4d207");
|
||||||
|
// 加上角色权限
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,7 @@ public class UserController {
|
|||||||
return ResponseResult.successData(reslut);
|
return ResponseResult.successData(reslut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/queryUsers")
|
@GetMapping("/queryUsers")
|
||||||
@Operation(summary = "查询用户信息")
|
@Operation(summary = "查询用户信息")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.system.domain.LoginUser;
|
import com.yfd.platform.system.domain.LoginUser;
|
||||||
import com.yfd.platform.system.domain.SysUser;
|
import com.yfd.platform.system.domain.SysUser;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -57,6 +58,9 @@ public interface IUserService extends IService<SysUser> {
|
|||||||
List<Map> list(String total, String size, String orgid, String username,
|
List<Map> list(String total, String size, String orgid, String username,
|
||||||
String mobile, String status);
|
String mobile, String status);
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
Map updateUserRoles(SysUser sysUser, String roleids);
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
* 用途说明:根据ID查询用户详情
|
* 用途说明:根据ID查询用户详情
|
||||||
* 参数说明
|
* 参数说明
|
||||||
|
|||||||
@ -9,20 +9,16 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.yfd.platform.config.FileProperties;
|
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.system.domain.LoginUser;
|
import com.yfd.platform.system.domain.LoginUser;
|
||||||
import com.yfd.platform.system.domain.SysOrganization;
|
|
||||||
import com.yfd.platform.system.domain.SysRole;
|
import com.yfd.platform.system.domain.SysRole;
|
||||||
import com.yfd.platform.system.domain.SysUser;
|
import com.yfd.platform.system.domain.SysUser;
|
||||||
import com.yfd.platform.system.mapper.SysOrganizationMapper;
|
|
||||||
import com.yfd.platform.system.mapper.SysRoleMapper;
|
import com.yfd.platform.system.mapper.SysRoleMapper;
|
||||||
import com.yfd.platform.system.mapper.SysUserMapper;
|
import com.yfd.platform.system.mapper.SysUserMapper;
|
||||||
import com.yfd.platform.system.service.IUserService;
|
import com.yfd.platform.system.service.IUserService;
|
||||||
import com.yfd.platform.utils.FileUtil;
|
import com.yfd.platform.utils.FileUtil;
|
||||||
import com.yfd.platform.utils.SecurityUtils;
|
import com.yfd.platform.utils.SecurityUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import com.yfd.platform.config.FileSpaceProperties;
|
import com.yfd.platform.config.FileSpaceProperties;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
@ -33,8 +29,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -272,6 +266,46 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public Map updateUserRoles(SysUser sysUser, String roleids) {
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
||||||
|
sysUser.setLastmodifydate(currentTime);
|
||||||
|
|
||||||
|
// 更新用户信息
|
||||||
|
boolean ok = this.updateById(sysUser);
|
||||||
|
if (!ok) {
|
||||||
|
result.put("status", "error");
|
||||||
|
result.put("msg", "用户信息修改失败!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理角色分配
|
||||||
|
String userId = sysUser.getId();
|
||||||
|
if (StrUtil.isNotEmpty(roleids)) {
|
||||||
|
handleUserRoles(userId, roleids);
|
||||||
|
} else {
|
||||||
|
// 清空所有角色
|
||||||
|
sysUserMapper.delRoleUsersByUserid(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.put("status", "sucess");
|
||||||
|
result.put("msg", "用户信息修改成功!");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新用户信息失败", e);
|
||||||
|
result.put("status", "error");
|
||||||
|
result.put("msg", "操作失败:" + e.getMessage());
|
||||||
|
throw e; // 抛出异常,触发事务回滚
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理用户角色分配(增量更新)
|
* 处理用户角色分配(增量更新)
|
||||||
* @param userId 用户 ID
|
* @param userId 用户 ID
|
||||||
@ -284,7 +318,6 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
|
|||||||
|
|
||||||
// 解析新角色列表
|
// 解析新角色列表
|
||||||
String[] newRoles = roleIds.split(",");
|
String[] newRoles = roleIds.split(",");
|
||||||
Set<String> newRoleSet = new HashSet<>(Arrays.asList(newRoles));
|
|
||||||
|
|
||||||
// 需要新增的角色(新角色 - 当前角色)
|
// 需要新增的角色(新角色 - 当前角色)
|
||||||
for (String roleId : newRoles) {
|
for (String roleId : newRoles) {
|
||||||
@ -298,9 +331,6 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme
|
|||||||
sysUserMapper.delInRoleUsersByUserid(userId, newRoles);
|
sysUserMapper.delInRoleUsersByUserid(userId, newRoles);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... existing code ...
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map getOneById(String id) {
|
public Map getOneById(String id) {
|
||||||
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: devtw
|
active: prod
|
||||||
|
|
||||||
jasypt:
|
jasypt:
|
||||||
encryptor:
|
encryptor:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user