提交 | 用户 | 时间
|
449017
|
1 |
package com.iailab.module.model.mpk.service.impl; |
D |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
5 |
import com.iailab.framework.common.page.PageData; |
|
6 |
import com.iailab.framework.common.service.impl.CrudServiceImpl; |
|
7 |
import com.iailab.framework.common.util.object.ConvertUtils; |
|
8 |
import com.iailab.module.model.mpk.dao.GeneratorCodeHistoryDao; |
|
9 |
import com.iailab.module.model.mpk.dto.GeneratorCodeHistoryDTO; |
|
10 |
import com.iailab.module.model.mpk.entity.GeneratorCodeHistoryEntity; |
|
11 |
import com.iailab.module.model.mpk.service.GeneratorCodeHistoryService; |
|
12 |
import org.apache.commons.io.FileUtils; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.springframework.stereotype.Service; |
|
15 |
|
|
16 |
import java.io.File; |
|
17 |
import java.io.IOException; |
|
18 |
import java.util.Map; |
|
19 |
|
|
20 |
/** |
|
21 |
* @description: 生成代码记录表 |
|
22 |
* @author: dzd |
|
23 |
* @date: 2024/8/20 11:49 |
|
24 |
**/ |
|
25 |
|
|
26 |
@Service |
|
27 |
public class GeneratorCodeHistoryServiceImpl extends CrudServiceImpl<GeneratorCodeHistoryDao, GeneratorCodeHistoryEntity, GeneratorCodeHistoryDTO> implements GeneratorCodeHistoryService { |
|
28 |
|
|
29 |
@Override |
|
30 |
public PageData<GeneratorCodeHistoryDTO> page(Map<String, Object> params) { |
|
31 |
IPage<GeneratorCodeHistoryEntity> page = baseDao.selectPage( |
|
32 |
getPage(params, "create_time", false), |
|
33 |
getWrapper(params) |
|
34 |
); |
|
35 |
|
|
36 |
return getPageData(page, GeneratorCodeHistoryDTO.class); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public GeneratorCodeHistoryDTO get(String id) { |
|
41 |
GeneratorCodeHistoryEntity entity = baseDao.selectById(id); |
|
42 |
|
|
43 |
return ConvertUtils.sourceToTarget(entity, GeneratorCodeHistoryDTO.class); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public byte[] download(GeneratorCodeHistoryDTO dto) throws IOException { |
|
48 |
File file = new File(dto.getFilePath()); |
|
49 |
if (!file.exists()) { |
|
50 |
log.error("文件不存在,路径:" + dto.getFilePath()); |
|
51 |
} |
|
52 |
return FileUtils.readFileToByteArray(file); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public void deleteByMap(Map<String, Object> map) { |
|
57 |
baseDao.delete(getWrapper(map)); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public QueryWrapper<GeneratorCodeHistoryEntity> getWrapper(Map<String, Object> params){ |
|
62 |
String id = (String)params.get("id"); |
|
63 |
String mdkId = (String)params.get("mdkId"); |
|
64 |
String startTime = (String)params.get("startTime"); |
|
65 |
String endTime = (String)params.get("endTime"); |
|
66 |
|
|
67 |
QueryWrapper<GeneratorCodeHistoryEntity> wrapper = new QueryWrapper<>(); |
|
68 |
wrapper.eq(StringUtils.isNotBlank(id), "id", id); |
|
69 |
wrapper.eq(StringUtils.isNotBlank(mdkId), "mdk_id", mdkId); |
|
70 |
wrapper.ge(StringUtils.isNotBlank(startTime), "create_time", startTime); |
|
71 |
wrapper.le(StringUtils.isNotBlank(endTime), "create_time", endTime); |
|
72 |
|
|
73 |
return wrapper; |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
} |