package com.yeshi.makemoney.app.service.impl.goldcorn;
|
|
import java.lang.Exception;
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
|
import java.util.Date;
|
|
import org.yeshi.utils.StringUtil;
|
import org.yeshi.utils.TimeUtil;
|
import org.yeshi.utils.bean.BeanUtil;
|
|
import java.util.List;
|
|
import com.yeshi.makemoney.app.dao.goldcorn.GoldCornGetRecordDao;
|
import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetRecord;
|
import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService;
|
import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornGetRecordQuery;
|
import com.yeshi.makemoney.app.dao.goldcorn.GoldCornGetRecordDao.DaoQuery;
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Query;
|
|
@Service
|
public class GoldCornGetRecordServiceImpl implements GoldCornGetRecordService {
|
|
@Resource
|
private GoldCornGetRecordDao goldCornGetRecordDao;
|
|
@Override
|
public List<GoldCornGetRecord> list(GoldCornGetRecordQuery goldCornGetRecordQuery, int page, int pageSize) {
|
DaoQuery daoQuery = new DaoQuery();
|
daoQuery.type = goldCornGetRecordQuery.getType();
|
daoQuery.uid = goldCornGetRecordQuery.getUid();
|
if (!StringUtil.isNullOrEmpty(goldCornGetRecordQuery.getStartTime())) {
|
daoQuery.minCreateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetRecordQuery.getStartTime(), "yyyy-MM-dd"));
|
}
|
|
if (!StringUtil.isNullOrEmpty(goldCornGetRecordQuery.getEndTime())) {
|
daoQuery.maxCreateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetRecordQuery.getEndTime(), "yyyy-MM-dd"));
|
}
|
|
|
daoQuery.start = (page - 1) * pageSize;
|
daoQuery.count = pageSize;
|
return goldCornGetRecordDao.list(daoQuery);
|
}
|
|
@Override
|
public long count(GoldCornGetRecordQuery goldCornGetRecordQuery) {
|
DaoQuery daoQuery = new DaoQuery();
|
daoQuery.type = goldCornGetRecordQuery.getType();
|
daoQuery.uid = goldCornGetRecordQuery.getUid();
|
if (!StringUtil.isNullOrEmpty(goldCornGetRecordQuery.getStartTime())) {
|
daoQuery.minCreateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetRecordQuery.getStartTime(), "yyyy-MM-dd"));
|
}
|
|
if (!StringUtil.isNullOrEmpty(goldCornGetRecordQuery.getEndTime())) {
|
daoQuery.maxCreateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetRecordQuery.getEndTime(), "yyyy-MM-dd"));
|
}
|
return goldCornGetRecordDao.count(daoQuery);
|
}
|
|
@Override
|
public GoldCornGetRecord get(String id) {
|
Query query = new Query();
|
query.addCriteria(Criteria.where("_id").is(id));
|
return goldCornGetRecordDao.findOne(query);
|
}
|
|
@Override
|
public void add(GoldCornGetRecord goldCornGetRecord) throws Exception {
|
//查询主键ID是否存在
|
if (goldCornGetRecordDao.get(goldCornGetRecord.getId()) != null) {
|
throw new Exception("已存在");
|
}
|
|
if (goldCornGetRecord.getCreateTime() == null) {
|
goldCornGetRecord.setCreateTime(new Date());
|
}
|
//保存
|
goldCornGetRecordDao.save(goldCornGetRecord);
|
}
|
|
@Override
|
public void update(GoldCornGetRecord goldCornGetRecord) {
|
if (goldCornGetRecord.getUpdateTime() == null) {
|
goldCornGetRecord.setUpdateTime(new Date());
|
}
|
//更新
|
goldCornGetRecordDao.updateSelective(goldCornGetRecord);
|
}
|
|
@Override
|
public void delete(List<String> idList) {
|
for (String id : idList) {
|
goldCornGetRecordDao.delete(id);
|
}
|
}
|
|
|
}
|