租户管理支持乐观锁

This commit is contained in:
dataprince 2024-01-19 21:34:11 +08:00
parent ee8f101807
commit b0204c224c
5 changed files with 15 additions and 22 deletions

View File

@ -58,9 +58,10 @@ server:
# 日志配置 # 日志配置
logging: logging:
level: level:
com.ruoyi: debug com.ruoyi: @logging.level@
org.springframework: warn org.springframework: warn
tech.powerjob.worker.background: warn tech.powerjob.worker.background: warn
org.mybatis.spring.mapper: error
config: classpath:logback.xml config: classpath:logback.xml
# 用户配置 # 用户配置

View File

@ -43,20 +43,20 @@ public interface ISysTenantPackageService extends IBaseService<SysTenantPackage>
/** /**
* 新增租户套餐 * 新增租户套餐
*/ */
Boolean insert(SysTenantPackageBo sysTenantPackageBo); boolean insert(SysTenantPackageBo sysTenantPackageBo);
/** /**
* 修改租户套餐 * 修改租户套餐
*/ */
Boolean update(SysTenantPackageBo sysTenantPackageBo); boolean update(SysTenantPackageBo sysTenantPackageBo);
/** /**
* 修改套餐状态 * 修改套餐状态
*/ */
Boolean updatePackageStatus(SysTenantPackageBo sysTenantPackageBo); boolean updatePackageStatus(SysTenantPackageBo sysTenantPackageBo);
/** /**
* 校验并批量删除租户套餐信息 * 校验并批量删除租户套餐信息
*/ */
Boolean deleteByIds(Long[] packageIds, Boolean isValid); boolean deleteByIds(Long[] packageIds, Boolean isValid);
} }

View File

@ -364,11 +364,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
*/ */
@Override @Override
public boolean deleteDeptById(Long deptId) { public boolean deleteDeptById(Long deptId) {
//update sys_dept set del_flag = '1' where dept_id = #{deptId} return this.removeById(deptId);
SysDept sysDept = new SysDept();
sysDept.setDeptId(deptId);
sysDept.setDelFlag(1);
return this.updateById(sysDept);
} }
/** /**

View File

@ -104,7 +104,7 @@ public class SysTenantPackageServiceImpl extends BaseServiceImpl<SysTenantPackag
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean insert(SysTenantPackageBo sysTenantPackageBo) { public boolean insert(SysTenantPackageBo sysTenantPackageBo) {
SysTenantPackage sysTenantPackage = MapstructUtils.convert(sysTenantPackageBo, SysTenantPackage.class); SysTenantPackage sysTenantPackage = MapstructUtils.convert(sysTenantPackageBo, SysTenantPackage.class);
if(ObjectUtil.isNull(sysTenantPackage)){ if(ObjectUtil.isNull(sysTenantPackage)){
return true; return true;
@ -132,7 +132,7 @@ public class SysTenantPackageServiceImpl extends BaseServiceImpl<SysTenantPackag
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean update(SysTenantPackageBo sysTenantPackageBo) { public boolean update(SysTenantPackageBo sysTenantPackageBo) {
SysTenantPackage sysTenantPackage = MapstructUtils.convert(sysTenantPackageBo, SysTenantPackage.class); SysTenantPackage sysTenantPackage = MapstructUtils.convert(sysTenantPackageBo, SysTenantPackage.class);
if(ObjectUtil.isNull(sysTenantPackage)){ if(ObjectUtil.isNull(sysTenantPackage)){
return true; return true;
@ -160,16 +160,15 @@ public class SysTenantPackageServiceImpl extends BaseServiceImpl<SysTenantPackag
* @return 结果 * @return 结果
*/ */
@Override @Override
public Boolean updatePackageStatus(SysTenantPackageBo sysTenantPackageBo) { public boolean updatePackageStatus(SysTenantPackageBo sysTenantPackageBo) {
SysTenantPackage sysTenantPackage = UpdateEntity.of(SysTenantPackage.class, sysTenantPackageBo.getPackageId()); SysTenantPackage sysTenantPackage = MapstructUtils.convert(sysTenantPackageBo,SysTenantPackage.class);
Long loginUserId = LoginHelper.getUserId(); Long loginUserId = LoginHelper.getUserId();
Date createTime = new Date(); Date createTime = new Date();
sysTenantPackage.setUpdateBy(loginUserId); sysTenantPackage.setUpdateBy(loginUserId);
sysTenantPackage.setUpdateTime(createTime); sysTenantPackage.setUpdateTime(createTime);
sysTenantPackage.setStatus(sysTenantPackageBo.getStatus()); return this.updateById(sysTenantPackage);
return tenantPackageMapper.update(sysTenantPackage) > 0;
} }
/** /**
@ -177,7 +176,7 @@ public class SysTenantPackageServiceImpl extends BaseServiceImpl<SysTenantPackag
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean deleteByIds(Long[] packageIds, Boolean isValid) { public boolean deleteByIds(Long[] packageIds, Boolean isValid) {
if(isValid){ if(isValid){
boolean exists = tenantMapper.selectCountByQuery(query().where(SYS_TENANT.PACKAGE_ID.in(List.of(packageIds)))) >0; boolean exists = tenantMapper.selectCountByQuery(query().where(SYS_TENANT.PACKAGE_ID.in(List.of(packageIds)))) >0;
if (exists) { if (exists) {

View File

@ -335,16 +335,13 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
@Override @Override
public boolean updateTenantStatus(SysTenantBo sysTenantBo) { public boolean updateTenantStatus(SysTenantBo sysTenantBo) {
return TenantHelper.ignore(() -> { return TenantHelper.ignore(() -> {
SysTenant sysTenant = UpdateEntity.of(SysTenant.class, sysTenantBo.getTenantId()); SysTenant sysTenant = MapstructUtils.convert(sysTenantBo, SysTenant.class);
Long loginUserId = LoginHelper.getUserId(); Long loginUserId = LoginHelper.getUserId();
Date createTime = new Date(); Date createTime = new Date();
sysTenant.setUpdateBy(loginUserId); sysTenant.setUpdateBy(loginUserId);
sysTenant.setUpdateTime(createTime); sysTenant.setUpdateTime(createTime);
sysTenant.setStatus(sysTenantBo.getStatus()); return this.updateById(sysTenant);
return tenantMapper.update(sysTenant) > 0;
}); });
} }