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);
|
}
|
|
}
|