嗨森逛服务
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.
hai-server/hai-service/src/main/java/com/hai/service/impl/HighAgentServiceImpl.java

102 lines
3.6 KiB

4 years ago
package com.hai.service.impl;
4 years ago
import com.hai.common.utils.MD5Util;
4 years ago
import com.hai.dao.HighAgentMapper;
import com.hai.entity.HighAgent;
import com.hai.entity.HighAgentExample;
4 years ago
import com.hai.entity.SecUser;
4 years ago
import com.hai.model.HighAgentModel;
4 years ago
import com.hai.service.HighAgentService;
4 years ago
import com.hai.service.SecUserService;
4 years ago
import org.apache.commons.lang3.StringUtils;
4 years ago
import org.springframework.stereotype.Service;
4 years ago
import javax.annotation.Resource;
4 years ago
import java.util.Date;
4 years ago
import java.util.List;
import java.util.Map;
4 years ago
/**
* @Auther: 袁野
* @Description:
* @Date: 2021/3/14 20:47
*/
@Service("highAgentService")
4 years ago
public class HighAgentServiceImpl implements HighAgentService {
@Resource
private HighAgentMapper highAgentMapper;
4 years ago
@Resource
private SecUserService secUserService;
4 years ago
@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") + "%");
}
4 years ago
if (StringUtils.isNotBlank(map.get("agentPhone"))) {
criteria.andAgentPhoneEqualTo( map.get("agentPhone"));
}
if (StringUtils.isNotBlank(map.get("status"))) {
criteria.andStatusEqualTo(Integer.valueOf(map.get("status")));
}
4 years ago
return highAgentMapper.selectByExample(example);
}
@Override
public HighAgent findByAgentMsgId(Long agentMsgId) {
return highAgentMapper.selectByPrimaryKey(agentMsgId);
}
@Override
4 years ago
public Boolean findByAgentName(String agentName) {
HighAgentExample example = new HighAgentExample();
HighAgentExample.Criteria criteria = example.createCriteria();
4 years ago
4 years ago
criteria.andAgentNameEqualTo(agentName);
4 years ago
return highAgentMapper.selectByExample(example).size() != 0;
4 years ago
}
@Override
4 years ago
public void updateAgentMsg(HighAgentModel highAgentModel) throws Exception {
4 years ago
highAgentMapper.updateByPrimaryKey(highAgentModel);
4 years ago
// 查询主账号
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);
}
4 years ago
}
4 years ago
4 years ago
@Override
4 years ago
public void insertAgentMsg(HighAgentModel highAgentModel) throws Exception {
highAgentMapper.insert(highAgentModel);
highAgentModel.getSecUser().setUserName(highAgentModel.getAgentName());
4 years ago
highAgentModel.getSecUser().setLoginName(highAgentModel.getSecUser().getLoginName());
4 years ago
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());
4 years ago
}
}