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
package cn.wisenergy.service.Manager;
import cn.wisenergy.mapper.AntiFakeMapper;
import cn.wisenergy.mapper.ProductMapper;
import cn.wisenergy.model.app.AntiFake;
import cn.wisenergy.model.app.ProductInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* @author 86187
*/
@Component
public class AntiFakeManger {
@Autowired
private AntiFakeMapper antiFakeMapper;
@Autowired
private ProductMapper productMapper;
@Transactional(rollbackFor = Exception.class)
public Boolean updateAntiFake(List<Long> array) {
//修改二维码使用状态
int updateUseStatus = antiFakeMapper.updateUseStatus(array);
return updateUseStatus == array.size();
}
/**
* 保存二维码信息和产品认证信息
*
* @param list 二维码信息
* @param productInfo 产品认证信息
* @return true of false
*/
@Transactional(rollbackFor = Exception.class)
public Boolean addAntiFakeAndProductInfo(List<AntiFake> list, ProductInfo productInfo) {
if (!CollectionUtils.isEmpty(list)) {
int count = antiFakeMapper.creates(list);
if (count != list.size()) {
return false;
}
}
if (null != productInfo) {
int count = productMapper.add(productInfo);
return count != 0;
}
return true;
}
}