package com.gkhy.system.service.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.common.enums.DeleteFlagEnum;
|
import com.gkhy.common.exception.ServiceException;
|
import com.gkhy.common.utils.SecurityUtils;
|
import com.gkhy.system.domain.SysExpertInfo;
|
import com.gkhy.system.domain.vo.request.SysExpertInfoRoundReq;
|
import com.gkhy.system.domain.vo.request.SysExpertSearchReqDto;
|
import com.gkhy.system.domain.vo.response.ProjectExpertSectionResp;
|
import com.gkhy.system.domain.vo.response.SysExpertSearchRep;
|
import com.gkhy.system.mapper.SysExpertInfoMapper;
|
import com.gkhy.system.service.SysExpertInfoService;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
/**
|
* <p>
|
* 系统专家信息表 服务实现类
|
* </p>
|
*
|
* @author kzy
|
* @since 2023-11-27 16:33:33
|
*/
|
@Service
|
public class SysExpertInfoServiceImpl extends ServiceImpl<SysExpertInfoMapper, SysExpertInfo> implements SysExpertInfoService {
|
|
@Override
|
public List<SysExpertInfo> exportInfoList(SysExpertInfo expertInfo) {
|
//todo 验证是否是管理不是管理只能看本部门
|
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
|
expertInfo.setDeptId(SecurityUtils.getDeptId());
|
}
|
return baseMapper.expertInfoList(expertInfo);
|
}
|
|
@Override
|
public int addExpertInfo(SysExpertInfo expertInfo) {
|
if(!checkIdCardUnique(new SysExpertInfo().setIdCard(expertInfo.getIdCard()))){
|
throw new ServiceException("该业务处室申请数据已存在");
|
}
|
expertInfo.setCreateBy(expertInfo.getName());
|
boolean b=save(expertInfo);
|
if(!b){
|
throw new ServiceException("新增专家信息失败");
|
}
|
return 1;
|
}
|
|
@Override
|
public int modExpertInfo(SysExpertInfo expertInfo) {
|
if(!checkIdCardUnique(expertInfo)){
|
throw new ServiceException("该业务处室申请数据已存在");
|
}
|
expertInfo.setUpdateBy(SecurityUtils.getUsername());
|
boolean b=updateById(expertInfo);
|
if(!b){
|
throw new ServiceException("修改专家信息失败");
|
}
|
return 1;
|
}
|
|
@Override
|
public int delExpertInfo(Long expertId) {
|
SysExpertInfo expertInfo = new SysExpertInfo();
|
expertInfo.setId(expertId);
|
expertInfo.setDelFlag(DeleteFlagEnum.DELETED.getCode());
|
expertInfo.setUpdateBy(SecurityUtils.getUsername());
|
boolean b= updateById(expertInfo);
|
if(!b){
|
throw new ServiceException("删除专家信息失败");
|
}
|
return 1;
|
}
|
|
@Override
|
public int delExpertInfoBatch(Long[] expertIds) {
|
return baseMapper.deleteBatchByIds(expertIds);
|
}
|
|
@Override
|
public SysExpertInfo exportInfoDetail(Long expertId) {
|
return baseMapper.getExpertInfoById(expertId);
|
}
|
|
|
|
public SysExpertInfo checkExpertInfoDataScope(Long expertId) {
|
if(expertId==null){
|
throw new ServiceException("专家id为空!");
|
}
|
SysExpertInfo expertInfo = baseMapper.getExpertInfoById(expertId);
|
if (ObjectUtil.isNull(expertInfo))
|
{
|
throw new ServiceException("专家数据不存在!");
|
}
|
return expertInfo;
|
}
|
|
@Override
|
public boolean changeApprove(SysExpertInfo expertInfo) {
|
checkExpertInfoDataScope(expertInfo.getId());
|
//SysExpertInfo se=new SysExpertInfo().setId(expertInfo.getId()).setState(expertInfo.getState());
|
expertInfo.setUpdateBy(SecurityUtils.getUsername());
|
// se.setUpdateBy(SecurityUtils.getUsername());
|
return updateById(expertInfo);
|
}
|
|
@Override
|
public SysExpertSearchRep queryApprove(SysExpertSearchReqDto expertInfo) {
|
SysExpertSearchRep sysExpertSearchRep = baseMapper.queryApprove(expertInfo);
|
if (null == sysExpertSearchRep){
|
throw new ServiceException("申请记录不存!");
|
}
|
return sysExpertSearchRep;
|
}
|
|
@Override
|
public List<ProjectExpertSectionResp> getExpertRound(SysExpertInfoRoundReq req) {
|
req.setDeptId(SecurityUtils.getDeptId());
|
return baseMapper.getExpertRound(req);
|
}
|
|
public boolean checkIdCardUnique(SysExpertInfo expertInfo){
|
Long expertId = expertInfo.getId()==null? -1L : expertInfo.getId();
|
SysExpertInfo info = baseMapper.checkIdcardUnique(expertInfo.getIdCard(),expertInfo.getDeptId());
|
if (info!=null && info.getId().longValue() != expertId.longValue())
|
{
|
return false;
|
}
|
return true;
|
}
|
}
|