152 lines
5.0 KiB
Plaintext
152 lines
5.0 KiB
Plaintext
|
|
package com.sercurityControl.proteam.service.impl;
|
||
|
|
|
||
|
|
import com.securityControl.common.security.utils.SecurityUtils;
|
||
|
|
import com.sercurityControl.proteam.domain.vo.ReturnCodeEntity;
|
||
|
|
import com.sercurityControl.proteam.domain.vo.SupeConsUserVo;
|
||
|
|
import com.sercurityControl.proteam.mapper.ManageMapper;
|
||
|
|
import com.sercurityControl.proteam.service.ManageService;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 主要管理
|
||
|
|
*/
|
||
|
|
@Service
|
||
|
|
@Slf4j
|
||
|
|
public class ManageServiceImpl implements ManageService {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private ManageMapper mapper;
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public List<SupeConsUserVo> getPageInfo(SupeConsUserVo supeConsUserVo) {
|
||
|
|
List<SupeConsUserVo> list = new ArrayList<>();
|
||
|
|
try {
|
||
|
|
list = mapper.getPageInfo(supeConsUserVo);
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return list;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public ReturnCodeEntity insertData(SupeConsUserVo supeConsUserVo) {
|
||
|
|
ReturnCodeEntity returnCodeEntity = new ReturnCodeEntity();
|
||
|
|
try {
|
||
|
|
supeConsUserVo.setCreateUser(SecurityUtils.getUserId().toString());
|
||
|
|
Integer num = mapper.getNumbyName(supeConsUserVo);
|
||
|
|
if (num > 0) {
|
||
|
|
returnCodeEntity.setMsg("该单位已存在");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
Integer num2 = mapper.insertData(supeConsUserVo);
|
||
|
|
if (num2 > 0) {
|
||
|
|
returnCodeEntity.setMsg("添加成功");
|
||
|
|
returnCodeEntity.setCode("200");
|
||
|
|
return returnCodeEntity;
|
||
|
|
} else {
|
||
|
|
returnCodeEntity.setMsg("添加失败,请联系管理员");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
} catch (Exception e) {
|
||
|
|
returnCodeEntity.setMsg("网络异常,请联系管理员");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public ReturnCodeEntity updateData(SupeConsUserVo supeConsUserVo) {
|
||
|
|
ReturnCodeEntity returnCodeEntity = new ReturnCodeEntity();
|
||
|
|
try {
|
||
|
|
supeConsUserVo.setUpdateUser(SecurityUtils.getUserId().toString());
|
||
|
|
Integer num = mapper.getNumbyName(supeConsUserVo);
|
||
|
|
if (num > 0) {
|
||
|
|
returnCodeEntity.setMsg("该单位已存在");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
Integer num2 = mapper.updateData(supeConsUserVo);
|
||
|
|
if (num2 > 0) {
|
||
|
|
returnCodeEntity.setMsg("修改成功");
|
||
|
|
returnCodeEntity.setCode("200");
|
||
|
|
return returnCodeEntity;
|
||
|
|
} else {
|
||
|
|
returnCodeEntity.setMsg("修改失败,请联系管理员");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
} catch (Exception e) {
|
||
|
|
returnCodeEntity.setMsg("网络异常,请联系管理员");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 删除数据
|
||
|
|
*
|
||
|
|
* @param keyId
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public ReturnCodeEntity deleteData(String keyId) {
|
||
|
|
ReturnCodeEntity returnCodeEntity = new ReturnCodeEntity();
|
||
|
|
try {
|
||
|
|
Integer num2 = mapper.deleteData(keyId);
|
||
|
|
if (num2 > 0) {
|
||
|
|
returnCodeEntity.setMsg("删除成功");
|
||
|
|
returnCodeEntity.setCode("200");
|
||
|
|
return returnCodeEntity;
|
||
|
|
} else {
|
||
|
|
returnCodeEntity.setMsg("删除失败,请联系管理员");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
} catch (Exception e) {
|
||
|
|
returnCodeEntity.setMsg("网络异常,请联系管理员");
|
||
|
|
returnCodeEntity.setCode("201");
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return returnCodeEntity;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param keyId
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public SupeConsUserVo getDataDetail(String keyId) {
|
||
|
|
try {
|
||
|
|
SupeConsUserVo vo = mapper.getDataDetail(keyId);
|
||
|
|
return vo;
|
||
|
|
} catch (Exception e) {
|
||
|
|
log.error(e.toString(), e);
|
||
|
|
}
|
||
|
|
return new SupeConsUserVo();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void addSuperConsData(List<SupeConsUserVo> list) {
|
||
|
|
list.forEach(item -> {
|
||
|
|
SupeConsUserVo vo = mapper.unitIsExist(item);
|
||
|
|
if(vo == null){
|
||
|
|
// 新增单位信息
|
||
|
|
mapper.addSuperConsData(item,1);
|
||
|
|
}else{
|
||
|
|
// 更换单位信息
|
||
|
|
item.setId(vo.getId());
|
||
|
|
mapper.addSuperConsData(item,2);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|