代码校验

This commit is contained in:
zhangheng 2024-03-06 13:53:37 +08:00
parent 73e53d1df7
commit 4552919c34
3 changed files with 17 additions and 10 deletions

View File

@ -99,7 +99,7 @@ public class AgencyController extends BaseController {
@Log(title = "机构信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Agency agency) {
return toAjax(agencyService.updateAgency(agency));
return agencyService.updateAgency(agency);
}
/**

View File

@ -61,7 +61,7 @@ public interface IAgencyService {
* @param agency 机构信息
* @return 结果
*/
int updateAgency(Agency agency);
AjaxResult updateAgency(Agency agency);
/**
* 批量删除机构信息

View File

@ -4,7 +4,6 @@ import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.DateUtils;
import com.xinelu.common.utils.SecurityUtils;
import com.xinelu.common.utils.StringUtils;
import com.xinelu.common.utils.bean.BeanUtils;
import com.xinelu.common.utils.regex.RegexUtil;
import com.xinelu.manage.domain.agency.Agency;
@ -16,14 +15,12 @@ import com.xinelu.manage.vo.agency.AgencyVO;
import com.xinelu.manage.vo.sysarea.SysAreaVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@ -126,10 +123,20 @@ public class AgencyServiceImpl implements IAgencyService {
* @return 结果
*/
@Override
public int updateAgency(Agency agency) {
public AjaxResult updateAgency(Agency agency) {
if (Objects.isNull(agency.getId())) {
return AjaxResult.error("请选择机构信息!");
}
Agency dataAgency = agencyMapper.selectAgencyById(agency.getId());
if (StringUtils.isNotBlank(dataAgency.getAgencyName()) && !agency.getAgencyName().equals(dataAgency.getAgencyName())) {
int i = agencyMapper.selectAgencyNameByAgencyNameInt(agency.getAgencyName());
if (i > 0) {
throw new ServiceException("该名称" + agency.getAgencyName() + "以重复!");
}
}
agency.setUpdateTime(DateUtils.getNowDate());
agency.setUpdateBy(SecurityUtils.getUsername());
return agencyMapper.updateAgencyById(agency);
return AjaxResult.success(agencyMapper.updateAgencyById(agency));
}
/**
@ -251,7 +258,7 @@ public class AgencyServiceImpl implements IAgencyService {
Iterator<AgencyVO> it = list.iterator();
while (it.hasNext()) {
AgencyVO n = (AgencyVO) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) {
if (Objects.nonNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) {
tlist.add(n);
}
}