admin
2021-05-06 42f05d2b835ed1ee41ca32cf76fe11849a890cb4
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
package com.ks.goldcorn.service;
 
import com.ks.goldcorn.exception.GoldRecordException;
import com.ks.goldcorn.mapper.GoldCornRecordMapper;
import com.ks.goldcorn.pojo.DO.GoldCornRecord;
import com.ks.goldcorn.query.RecordQuery;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Component
public class GoldCornRecordManager {
 
    @Resource
    private GoldCornRecordMapper goldCornRecordMapper;
 
 
    @Transactional
    public void addRecord(GoldCornRecord record) throws GoldRecordException {
        if (record == null || record.getAppId() == null || record.getGoldCorn() == null || record.getSourceCode() == null || record.getType() == null) {
            throw new GoldRecordException(GoldRecordException.CODE_PARAMS_NOT_ENOUGH, "参数不完整");
        }
        if (record.getCreateTime() == null) {
            record.setCreateTime(new Date());
        }
        goldCornRecordMapper.insertSelective(record);
    }
 
 
    /**
     * 查询列表
     *
     * @param query
     * @return
     */
    public List<GoldCornRecord> list(RecordQuery query) {
        return goldCornRecordMapper.list(query);
    }
 
    /**
     * 计数
     *
     * @param query
     * @return
     */
    public long count(RecordQuery query) {
        return goldCornRecordMapper.count(query);
    }
 
}