|
|
@@ -19,6 +19,7 @@ import com.ruoyi.clock.domain.Agent;
|
|
|
import com.ruoyi.clock.mapper.AgentMapper;
|
|
|
import com.ruoyi.clock.service.IAgentService;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Collection;
|
|
|
@@ -66,8 +67,8 @@ public class AgentServiceImpl implements IAgentService {
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getAgentName()), Agent::getAgentName, bo.getAgentName());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getServiceArea()), Agent::getServiceArea, bo.getServiceArea());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), Agent::getAddress, bo.getAddress());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getContact()), Agent::getContact, bo.getContact());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), Agent::getPhonenumber, bo.getPhonenumber());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getContact()), Agent::getContact, bo.getContact());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getPhonenumber()), Agent::getPhonenumber, bo.getPhonenumber());
|
|
|
return lqw;
|
|
|
}
|
|
|
|
|
|
@@ -92,7 +93,7 @@ public class AgentServiceImpl implements IAgentService {
|
|
|
public Agent loadById(Long agentId, Boolean tw){
|
|
|
Agent info = this.baseMapper.selectById(agentId);
|
|
|
if(ObjectUtil.isEmpty(info) && tw){
|
|
|
- throw new ServiceException(AgentExceptionEnum.Agent_IS_NOT_EXISTS);
|
|
|
+ throw new ServiceException(AgentExceptionEnum.AGENT_IS_NOT_EXISTS);
|
|
|
}
|
|
|
return info;
|
|
|
}
|
|
|
@@ -105,8 +106,8 @@ public class AgentServiceImpl implements IAgentService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean insertByBo(AgentBo bo) {
|
|
|
+ validEntityBeforeSave(bo);
|
|
|
Agent add = BeanUtil.toBean(bo, Agent.class);
|
|
|
- validEntityBeforeSave(add);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setAgentId(add.getAgentId());
|
|
|
@@ -122,19 +123,29 @@ public class AgentServiceImpl implements IAgentService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean updateByBo(AgentBo bo) {
|
|
|
+ validEntityBeforeSave(bo);
|
|
|
Agent agent = baseMapper.selectById(bo.getAgentId());
|
|
|
Agent update = BeanCopyUtils.copy(bo, agent);
|
|
|
- validEntityBeforeSave(update);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*
|
|
|
- * @param entity 实体类数据
|
|
|
+ * @param bo 实体类数据
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(Agent entity){
|
|
|
+ private void validEntityBeforeSave(AgentBo bo){
|
|
|
+ String agentName = bo.getAgentName();
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ Agent agent = getAgentByName(agentName);
|
|
|
+ if(ObjectUtil.isNotNull(agent)&& !agent.getAgentId().equals(bo.getAgentId())){
|
|
|
+ throw new ServiceException(AgentExceptionEnum.AGENT_REPEAT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Agent getAgentByName(String agentName) {
|
|
|
+ return baseMapper.selectOne(new LambdaQueryWrapper<Agent>().eq(Agent::getAgentName,agentName)
|
|
|
+ .last("limit 1"));
|
|
|
}
|
|
|
|
|
|
/**
|