yuxc
2024-12-25 b6332f2cd592dad7de703a85c60a50f2d9d34e75
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package com.vci.web.dao.impl;
 
import com.vci.constant.VciFileBtmTypeConstant;
import com.vci.model.VciFileDocClassifyDO;
import com.vci.starter.web.constant.QueryOptionConstant;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
import com.vci.web.dao.VciFileDocClassifyDaoI;
import com.vci.web.service.WebBoServiceI;
import com.vci.web.util.WebUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;
 
import java.util.*;
 
/**
 * 文档的类型
 * @author weidy
 * @date 2021/3/11
 */
@Repository
public class VciFileDocClassifyDaoImpl implements VciFileDocClassifyDaoI {
 
    /**
     * 业务数据对象的服务
     */
    @Autowired
    private WebBoServiceI boService;
 
    /**
     * 使用主键删除
     *
     * @param oid 数据主键
     * @return 执行结果
     */
    @Override
    public int deleteByPrimaryKey(String oid) {
        VciBaseUtil.alertNotNull(oid,"文档类型的主键");
        boService.deleteByCondition(VciFileBtmTypeConstant.FILE_DOC_CLASSIFY, WebUtil.getOidQuery(oid));
        return StringUtils.countMatches(oid,",") + 1;
    }
 
    /**
     * 添加数据
     *
     * @param record 文档的类型数据对象
     * @return 执行结果
     */
    @Override
    public int insert(VciFileDocClassifyDO record) {
        VciBaseUtil.alertNotNull(record,"要添加的内容");
        if(StringUtils.isBlank(record.getOid())){
            record.setOid(VciBaseUtil.getPk());
        }
        boService.addSave(record);
        return 1;
    }
 
    /**
     * 根据主键查询
     *
     * @param oid 数据主键
     * @return 数据对象
     */
    @Override
    public VciFileDocClassifyDO selectByPrimaryKey(String oid) {
        return boService.selectByOid(oid, VciFileDocClassifyDO.class);
    }
 
    /**
     * 根据主键批量获取对象
     *
     * @param oids 主键,包含单引号,但是不能超过1000
     * @return 数据对象列表
     */
    @Override
    public List<VciFileDocClassifyDO> selectByPrimaryKeys(String oids) {
        return boService.selectByOidCollection(VciBaseUtil.str2List(oids),VciFileDocClassifyDO.class);
    }
 
    /**
     * 根据主键批量查询对象
     *
     * @param oids 对象主键,使用逗号分隔,但是不能超过1000
     * @return 业务对象
     */
    @Override
    public List<VciFileDocClassifyDO> selectByPrimaryKeyCollection(Collection<String> oids) {
        return boService.selectByOidCollection(oids,VciFileDocClassifyDO.class);
    }
 
    /**
     * 查询所有分类
     *
     * @return 查询结果
     */
    @Override
    public List<VciFileDocClassifyDO> selectAll() {
        return boService.queryObject(VciFileDocClassifyDO.class,null);
    }
 
    /**
     * 更新物料、工具基本分类
     *
     * @param record 物料、工具基本分类数据对象
     * @return 执行结果
     */
    @Override
    public int updateByPrimaryKey(VciFileDocClassifyDO record) {
        VciBaseUtil.alertNotNull(record,"要修改的内容",record.getOid(),"主键");
        boService.editSave(record);
        return 1;
    }
 
    /**
     * 根据查询条件查询数据
     *
     * @param wrapper 查询条件,包括分页,排序
     * @return 数据对象列表
     */
    @Override
    public List<VciFileDocClassifyDO> selectByWrapper(VciQueryWrapperForDO wrapper) {
        return boService.selectByQueryWrapper(wrapper,VciFileDocClassifyDO.class);
    }
 
    /**
     * 根据查询条件来查询总数
     *
     * @param wrapper 查询条件
     * @return 总数
     */
    @Override
    public Long countByWrapper(VciQueryWrapperForDO wrapper) {
        return Long.valueOf(boService.countByQueryWrapper(wrapper,VciFileDocClassifyDO.class));
    }
 
    /**
     * 根据主键获取名称
     *
     * @param oid 主键
     * @return 中文名称
     */
    @Override
    public String selectNameByOid(String oid) {
        VciFileDocClassifyDO fileObjectDO = selectByPrimaryKey(oid);
        return fileObjectDO!=null?fileObjectDO.getName():"";
    }
 
    /**
     * 批量删除对象
     *
     * @param oids 对象的主键集合
     * @return 受印象的行数
     */
    @Override
    public long batchDeleteByOids(Collection<String> oids) {
        VciBaseUtil.switchCollectionForOracleIn(oids).forEach(oidList->{
            Map<String,String> conditionMap = new HashMap<>();
            conditionMap.put("oid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(oidList.toArray(new String[0])) + ")");
            boService.deleteByCondition(VciFileBtmTypeConstant.FILE_DOC_CLASSIFY,conditionMap);
        });
        return oids.size();
    }
 
    /**
     * 使用编号查询
     *
     * @param ids 编号
     * @return 查询结果
     */
    @Override
    public List<VciFileDocClassifyDO> selectByIdCollection(Collection<String> ids) {
        VciBaseUtil.alertNotNull(ids,"文档类型的编号");
        List<VciFileDocClassifyDO> doList = new ArrayList<>();
        VciBaseUtil.switchCollectionForOracleIn(ids).stream().forEach(idList-> {
            Map<String, String> conditionMap = new HashMap<>();
            conditionMap.put("id", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(idList.toArray(new String[0])) + ")");
            List<VciFileDocClassifyDO> tempDOs = boService.queryObject(VciFileDocClassifyDO.class, conditionMap);
            if(!CollectionUtils.isEmpty(tempDOs)){
                doList.addAll(tempDOs);
            }
        });
        return doList;
    }
 
    /**
     * 使用编号查询对象
     *
     * @param id 编号
     * @return 数据对象
     */
    @Override
    public VciFileDocClassifyDO selectById(String id) {
        VciBaseUtil.alertNotNull(id,"编号");
        Map<String, String> conditionMap = new HashMap<>();
        conditionMap.put("id", id);
        List<VciFileDocClassifyDO> classifyDOS = boService.queryObject(VciFileDocClassifyDO.class, conditionMap);
        if(!CollectionUtils.isEmpty(classifyDOS)){
            return classifyDOS.get(0);
        }
        return null;
    }
}