You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.6 KiB
101 lines
3.6 KiB
package com.hai.service.impl;
|
|
|
|
import com.hai.common.utils.MD5Util;
|
|
import com.hai.dao.HighAgentMapper;
|
|
import com.hai.entity.HighAgent;
|
|
import com.hai.entity.HighAgentExample;
|
|
import com.hai.entity.SecUser;
|
|
import com.hai.model.HighAgentModel;
|
|
import com.hai.service.HighAgentService;
|
|
import com.hai.service.SecUserService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @Auther: 袁野
|
|
* @Description:
|
|
* @Date: 2021/3/14 20:47
|
|
*/
|
|
@Service("highAgentService")
|
|
public class HighAgentServiceImpl implements HighAgentService {
|
|
|
|
@Resource
|
|
private HighAgentMapper highAgentMapper;
|
|
|
|
@Resource
|
|
private SecUserService secUserService;
|
|
|
|
@Override
|
|
public List<HighAgent> getListAgentMsg(Map<String, String> map) throws Exception {
|
|
|
|
HighAgentExample example = new HighAgentExample();
|
|
HighAgentExample.Criteria criteria = example.createCriteria();
|
|
|
|
if (StringUtils.isNotBlank(map.get("agentName"))) {
|
|
criteria.andAgentNameLike("%" + map.get("agentName") + "%");
|
|
}
|
|
if (StringUtils.isNotBlank(map.get("agentPhone"))) {
|
|
criteria.andAgentPhoneEqualTo( map.get("agentPhone"));
|
|
}
|
|
if (StringUtils.isNotBlank(map.get("status"))) {
|
|
criteria.andStatusEqualTo(Integer.valueOf(map.get("status")));
|
|
}
|
|
|
|
return highAgentMapper.selectByExample(example);
|
|
}
|
|
|
|
@Override
|
|
public HighAgent findByAgentMsgId(Long agentMsgId) {
|
|
return highAgentMapper.selectByPrimaryKey(agentMsgId);
|
|
}
|
|
|
|
@Override
|
|
public Boolean findByAgentName(String agentName) {
|
|
HighAgentExample example = new HighAgentExample();
|
|
HighAgentExample.Criteria criteria = example.createCriteria();
|
|
|
|
criteria.andAgentNameEqualTo(agentName);
|
|
|
|
return highAgentMapper.selectByExample(example).size() != 0;
|
|
}
|
|
|
|
@Override
|
|
public void updateAgentMsg(HighAgentModel highAgentModel) throws Exception {
|
|
highAgentMapper.updateByPrimaryKey(highAgentModel);
|
|
// 查询主账号
|
|
SecUser mainAccount = secUserService.getMainAccount(4, highAgentModel.getId());
|
|
if (mainAccount != null) {
|
|
String userPass = MD5Util.encode(highAgentModel.getSecUser().getPassword().getBytes());
|
|
if (!mainAccount.getPassword().equals(userPass)) {
|
|
mainAccount.setPassword(userPass);
|
|
}
|
|
if (highAgentModel.getStatus() == 0) {
|
|
mainAccount.setStatus(0);
|
|
}
|
|
mainAccount.setTelephone(highAgentModel.getSecUser().getLoginName());
|
|
secUserService.updateUser(mainAccount);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void insertAgentMsg(HighAgentModel highAgentModel) throws Exception {
|
|
highAgentMapper.insert(highAgentModel);
|
|
|
|
highAgentModel.getSecUser().setUserName(highAgentModel.getAgentName());
|
|
highAgentModel.getSecUser().setLoginName(highAgentModel.getSecUser().getLoginName());
|
|
highAgentModel.getSecUser().setPassword(MD5Util.encode(highAgentModel.getSecUser().getPassword().getBytes()));
|
|
highAgentModel.getSecUser().setAdminFlag(1);
|
|
highAgentModel.getSecUser().setStatus(1);
|
|
highAgentModel.getSecUser().setRoleId(6L);
|
|
highAgentModel.getSecUser().setObjectType(4);
|
|
highAgentModel.getSecUser().setObjectId(highAgentModel.getId());
|
|
highAgentModel.getSecUser().setCreateTime(new Date());
|
|
highAgentModel.getSecUser().setUpdateTime(new Date());
|
|
secUserService.addUser(highAgentModel.getSecUser());
|
|
}
|
|
}
|
|
|