分组新增:角色对应的新增逻辑
This commit is contained in:
parent
e0d11a649d
commit
cc590c7b79
|
@ -7,10 +7,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.aspect.annotation.PermissionData;
|
import org.jeecg.common.aspect.annotation.PermissionData;
|
||||||
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.modules.entity.CeesGroup;
|
import org.jeecg.modules.entity.CeesGroup;
|
||||||
import org.jeecg.modules.entity.CeesWaiTeacher;
|
import org.jeecg.modules.entity.CeesWaiTeacher;
|
||||||
import org.jeecg.modules.entity.dto.UpdateGroupUserDto;
|
import org.jeecg.modules.entity.dto.UpdateGroupUserDto;
|
||||||
|
@ -41,6 +44,8 @@ public class CeesGroupController extends JeecgController<CeesGroup, ICeesGroupSe
|
||||||
private ICeesGroupService ceesGroupService;
|
private ICeesGroupService ceesGroupService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CeesWaiTeacherMapper ceesWaiTeacherMapper;
|
private CeesWaiTeacherMapper ceesWaiTeacherMapper;
|
||||||
|
@Autowired
|
||||||
|
private ISysBaseAPI sysBaseAPI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
|
@ -97,6 +102,21 @@ public class CeesGroupController extends JeecgController<CeesGroup, ICeesGroupSe
|
||||||
@ApiOperation(value = "分组表-添加", notes = "分组表-添加")
|
@ApiOperation(value = "分组表-添加", notes = "分组表-添加")
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public Result<String> add(@RequestBody CeesGroup ceesGroup) {
|
public Result<String> add(@RequestBody CeesGroup ceesGroup) {
|
||||||
|
if(ceesGroup.getMajorId() == null){
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
String username = sysUser.getUsername();
|
||||||
|
// 获取角色编码列表
|
||||||
|
List<String> roleCodes =sysBaseAPI.getRolesByUsername(username);
|
||||||
|
if (roleCodes.size() == 1) {
|
||||||
|
try {
|
||||||
|
Integer majorId = Integer.parseInt(roleCodes.get(0));
|
||||||
|
ceesGroup.setMajorId(majorId);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 处理异常,说明角色不是纯数字
|
||||||
|
log.warn("角色编码无法转换为数字: {}", roleCodes.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ceesGroupService.save(ceesGroup);
|
ceesGroupService.save(ceesGroup);
|
||||||
return Result.OK("添加成功!");
|
return Result.OK("添加成功!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue