提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
潘 |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
6 |
import com.iailab.framework.common.util.collection.CollectionUtils; |
|
7 |
import com.iailab.module.model.mcs.pre.dao.MmItemTypeDao; |
|
8 |
import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; |
|
9 |
import com.iailab.module.model.mcs.pre.service.MmItemTypeService; |
|
10 |
import com.iailab.module.model.mcs.pre.vo.MmItemTypePageReqVO; |
|
11 |
import org.apache.commons.lang3.StringUtils; |
|
12 |
import org.springframework.stereotype.Service; |
|
13 |
import org.springframework.transaction.annotation.Transactional; |
|
14 |
|
|
15 |
import java.util.Arrays; |
|
16 |
import java.util.List; |
|
17 |
import java.util.Map; |
|
18 |
import java.util.UUID; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author PanZhibao |
|
22 |
* @date 2021年04月23日 15:29 |
|
23 |
*/ |
|
24 |
@Service("mmItemTypeService") |
|
25 |
public class MmItemTypeImpl extends BaseServiceImpl<MmItemTypeDao, MmItemTypeEntity> implements MmItemTypeService { |
|
26 |
|
|
27 |
@Override |
|
28 |
public PageResult<MmItemTypeEntity> page(MmItemTypePageReqVO reqVO) { |
|
29 |
return baseDao.selectPage(reqVO); |
|
30 |
} |
|
31 |
|
|
32 |
private QueryWrapper<MmItemTypeEntity> getWrapper(Map<String, Object> params) { |
|
33 |
String itemtypename = (String)params.get("itemtypename"); |
|
34 |
|
|
35 |
QueryWrapper<MmItemTypeEntity> wrapper = new QueryWrapper<>(); |
|
36 |
wrapper.like(StringUtils.isNotBlank(itemtypename),"itemtypename", itemtypename); |
|
37 |
|
|
38 |
return wrapper; |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
@Transactional(rollbackFor = Exception.class) |
|
43 |
public void saveItemType(MmItemTypeEntity itemType) { |
|
44 |
itemType.setId(UUID.randomUUID().toString()); |
|
45 |
baseDao.insert(itemType); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
@Transactional(rollbackFor = Exception.class) |
|
50 |
public void update(MmItemTypeEntity itemType) { |
|
51 |
baseDao.updateById(itemType); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
@Transactional(rollbackFor = Exception.class) |
|
56 |
public void deleteBatch(String[] moduleIds) { |
|
57 |
baseDao.deleteBatchIds(Arrays.asList(moduleIds)); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public int check(MmItemTypeEntity itemType) { |
|
62 |
String id = itemType.getId(); |
|
63 |
String itemtypename = itemType.getItemtypename(); |
|
64 |
QueryWrapper<MmItemTypeEntity> moduleWrapper = new QueryWrapper<>(); |
|
65 |
moduleWrapper.ne(StringUtils.isNotBlank(id), "id", id); |
|
66 |
moduleWrapper.and(wrapper -> wrapper.eq("itemtypename",itemtypename)); |
|
67 |
List<MmItemTypeEntity> list = baseDao.selectList(moduleWrapper); |
|
68 |
return list.size(); |
|
69 |
} |
|
70 |
|
|
71 |
public MmItemTypeEntity getById(String itemtypeid) { |
|
72 |
MmItemTypeEntity entity = baseDao.selectById(itemtypeid); |
|
73 |
return entity; |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public MmItemTypeEntity getItemTypeByItemId(String itemId) { |
|
78 |
List<MmItemTypeEntity> list = baseDao.getItemTypeByItemId(itemId); |
|
79 |
if (CollectionUtils.isAnyEmpty(list)) { |
|
80 |
return null; |
|
81 |
} |
|
82 |
return list.get(0); |
|
83 |
} |
|
84 |
} |