白蚁计划
parent
ea8459209f
commit
22f6fbc165
|
|
@ -13,6 +13,8 @@ import com.gunshi.project.hsz.service.ByPlanService;
|
||||||
import com.gunshi.project.hsz.service.FileAssociationsService;
|
import com.gunshi.project.hsz.service.FileAssociationsService;
|
||||||
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
||||||
import com.gunshi.project.hsz.common.validate.markers.Update;
|
import com.gunshi.project.hsz.common.validate.markers.Update;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
@ -41,7 +43,8 @@ public class ByPlanController extends AbstractCommonFileController{
|
||||||
private ByPlanDetailService byPlanDetailService;
|
private ByPlanDetailService byPlanDetailService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
@Operation(summary = "新增")
|
@Operation(summary = "新增")
|
||||||
@PostMapping("/insert")
|
@PostMapping("/insert")
|
||||||
|
|
@ -53,6 +56,10 @@ public class ByPlanController extends AbstractCommonFileController{
|
||||||
throw new IllegalArgumentException("该计划编号已存在");
|
throw new IllegalArgumentException("该计划编号已存在");
|
||||||
}
|
}
|
||||||
dto.setId(IdWorker.getId());
|
dto.setId(IdWorker.getId());
|
||||||
|
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(dto.getUserId()));
|
||||||
|
if(sysUser != null){
|
||||||
|
dto.setUserName(sysUser.getNickName());
|
||||||
|
}
|
||||||
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
||||||
if(byPlanDetail == null || byPlanDetail.isEmpty()){
|
if(byPlanDetail == null || byPlanDetail.isEmpty()){
|
||||||
throw new IllegalArgumentException("防止部位至少需要一条数据");
|
throw new IllegalArgumentException("防止部位至少需要一条数据");
|
||||||
|
|
@ -71,7 +78,10 @@ public class ByPlanController extends AbstractCommonFileController{
|
||||||
@Operation(summary = "修改")
|
@Operation(summary = "修改")
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public R<ByPlan> update(@Validated(Update.class) @RequestBody ByPlan dto) {
|
public R<ByPlan> update(@Validated(Update.class) @RequestBody ByPlan dto) {
|
||||||
|
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(dto.getUserId()));
|
||||||
|
if(sysUser != null){
|
||||||
|
dto.setUserName(sysUser.getNickName());
|
||||||
|
}
|
||||||
boolean flag = byPlanService.update(dto);
|
boolean flag = byPlanService.update(dto);
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class ByPlan {
|
||||||
@Schema(description = "用户id")
|
@Schema(description = "用户id")
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
@TableField(value = "user_name")
|
@TableField(exist = false)
|
||||||
@Schema(description = "用户名称")
|
@Schema(description = "用户名称")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,6 @@ public class ByPlanService extends ServiceImpl<ByPlanMapper, ByPlan> {
|
||||||
if(Objects.isNull(one)){
|
if(Objects.isNull(one)){
|
||||||
throw new RuntimeException("该计划不存在,请检查");
|
throw new RuntimeException("该计划不存在,请检查");
|
||||||
}
|
}
|
||||||
if(dto.getUserId() != null){
|
|
||||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(dto.getUserId()));
|
|
||||||
if(sysUser != null){
|
|
||||||
dto.setUserName(sysUser.getNickName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean save = updateById(dto);
|
boolean save = updateById(dto);
|
||||||
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
||||||
if(byPlanDetail == null || byPlanDetail.isEmpty()){
|
if(byPlanDetail == null || byPlanDetail.isEmpty()){
|
||||||
|
|
@ -94,7 +88,7 @@ public class ByPlanService extends ServiceImpl<ByPlanMapper, ByPlan> {
|
||||||
if(entity.getUserId() != null){
|
if(entity.getUserId() != null){
|
||||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(entity.getUserId()));
|
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(entity.getUserId()));
|
||||||
if(sysUser != null){
|
if(sysUser != null){
|
||||||
entity.setUserName(sysUser.getUserName());
|
entity.setUserName(sysUser.getNickName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -104,12 +98,6 @@ public class ByPlanService extends ServiceImpl<ByPlanMapper, ByPlan> {
|
||||||
public boolean saveData(ByPlan dto) {
|
public boolean saveData(ByPlan dto) {
|
||||||
dto.setId(IdWorker.getId());
|
dto.setId(IdWorker.getId());
|
||||||
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
List<ByPlanDetail> byPlanDetail = dto.getByPlanDetail();
|
||||||
if(dto.getUserId() != null){
|
|
||||||
SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(dto.getUserId()));
|
|
||||||
if(sysUser != null){
|
|
||||||
dto.setUserName(sysUser.getNickName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean save = save(dto);
|
boolean save = save(dto);
|
||||||
byPlanDetail.forEach(detail -> {
|
byPlanDetail.forEach(detail -> {
|
||||||
detail.setId(IdWorker.getId());
|
detail.setId(IdWorker.getId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue