xiejun
2023-09-21 52ffefd06e59cbd56c1a919972866592379cfed2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.vci.ubcs.code.service.impl;
 
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.vci.ubcs.code.entity.CodeReferConfig;
import com.vci.ubcs.code.entity.CodeResembleRule;
import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus;
import com.vci.ubcs.code.mapper.CodeReferConfigMapper;
import com.vci.ubcs.code.mapper.CodeResembleRuleMapper;
import com.vci.ubcs.code.service.ICodeResembleRuleService;
import com.vci.ubcs.code.vo.pagemodel.CodeResembleRuleVO;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
 
import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST;
 
/**
 * 相似查询规则服务
 * @author weidy
 * @date 2022-04-10
 */
@Service
public class CodeResembleRuleServiceImpl extends MPJBaseServiceImpl<CodeResembleRuleMapper, CodeResembleRule> implements ICodeResembleRuleService {
    @Override
    public CodeResembleRuleVO getObjectByOid(String oid) {
        return codeResembleRuleDO2VO(selectByOid(oid));
    }
 
    /**
     * 主键查询数据对象
     * @param oid 主键
     * @return  数据对象
     * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常
     */
    private CodeResembleRule selectByOid(String oid) throws VciBaseException {
        VciBaseUtil.alertNotNull(oid,"主键");
        CodeResembleRule codeResembleRuleDO = baseMapper.selectById(oid.trim());
//        CodeResembleRule codeResembleRuleDO = codeResembleRuleMapper.selectByPrimaryKey(oid.trim());
        if(codeResembleRuleDO == null || StringUtils.isBlank(codeResembleRuleDO.getOid())){
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
        return codeResembleRuleDO;
    }
 
 
    /**
     * 数据对象转换为显示对象
     * @param  codeResembleRuleDO 数据对象
     * @return 显示对象
     * @throws VciBaseException 拷贝属性出错的时候会抛出异常
     */
    @Override
    public  CodeResembleRuleVO codeResembleRuleDO2VO(CodeResembleRule codeResembleRuleDO) throws VciBaseException{
        CodeResembleRuleVO vo = new CodeResembleRuleVO();
        if(codeResembleRuleDO != null){
            BeanUtilForVCI.copyPropertiesIgnoreCase(codeResembleRuleDO,vo);
            //如果有lcstatus的类的话
            vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus()));
 
        }
        return vo;
    }
}