新增生成规则api

This commit is contained in:
Qi 2025-04-28 22:03:07 +08:00
parent f9ae3fd1db
commit 88426ef459
3 changed files with 48 additions and 2 deletions

View File

@ -85,6 +85,20 @@ public class CeesUserController extends JeecgController<CeesUser, ICeesUserServi
return Result.OK(); return Result.OK();
} }
/**
* 生成规则相关api
* @return
*/
@GetMapping("/getGenerativeRules")
public Result<?> getGenerativeRules() {
return ceesUserService.getGenerativeRules();
}
@GetMapping("/updateGenerateRule")
public Result<?> updateGenerateRule(@RequestParam(name = "id") Long id,@RequestParam(name = "groupType") Integer groupType,@RequestParam(name = "majorId") Integer majorId){
return ceesUserService.updateGenerateRule(id, groupType, majorId);
// return null;
}
/** /**
* 编辑 * 编辑
* *

View File

@ -23,4 +23,8 @@ public interface ICeesUserService extends IService<CeesUser> {
Result<?> getGroupName(String groupId); Result<?> getGroupName(String groupId);
void createAccount(CreateAccountDto createAccountDto); void createAccount(CreateAccountDto createAccountDto);
Result<?> getGenerativeRules();
Result<?> updateGenerateRule(Long id, Integer groupType, Integer majorId);
} }

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -257,6 +258,8 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
/** /**
* @param createAccountDto * @param createAccountDto
* @param groupType
* @param majorId
* @return * @return
*/ */
@Override @Override
@ -270,7 +273,7 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
} }
// 获取生成规则 // 获取生成规则
CeesGenerativeRules rules = getGenerativeRules(); CeesGenerativeRules rules = GetGenerativeRules();
if (rules == null) { if (rules == null) {
throw new IllegalArgumentException("找不到对应的账号生成规则"); throw new IllegalArgumentException("找不到对应的账号生成规则");
} }
@ -314,8 +317,33 @@ public class CeesUserServiceImpl extends ServiceImpl<CeesUserMapper, CeesUser> i
userMIDList.clear(); userMIDList.clear();
} }
// 获取生成规则---用户前端获取rule
public Result<?> getGenerativeRules() {
LambdaQueryWrapper<CeesGenerativeRules> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CeesGenerativeRules::getIs_default, "1");
JSONObject result = new JSONObject();
result.put("GenerativeRules",ceesGenerativeRulesMapper.selectOne(queryWrapper));
return Result.ok(result);
}
@Override
public Result<?> updateGenerateRule(Long id, Integer groupType, Integer majorId) {
LambdaUpdateWrapper<CeesGenerativeRules> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(CeesGenerativeRules::getId, id)
.set(CeesGenerativeRules::getGroupType, groupType)
.set(CeesGenerativeRules::getMajorId, majorId);
// 使用 update 方法进行更新
int result = ceesGenerativeRulesMapper.update(null, updateWrapper);
if (result > 0) {
return Result.ok("更新成功");
} else {
return Result.error("更新失败");
}
}
// 获取生成规则 // 获取生成规则
private CeesGenerativeRules getGenerativeRules() { private CeesGenerativeRules GetGenerativeRules() {
LambdaQueryWrapper<CeesGenerativeRules> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CeesGenerativeRules> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CeesGenerativeRules::getIs_default, "1"); queryWrapper.eq(CeesGenerativeRules::getIs_default, "1");
return ceesGenerativeRulesMapper.selectOne(queryWrapper); return ceesGenerativeRulesMapper.selectOne(queryWrapper);