| | |
| | | <version>2.5.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-io</groupId> |
| | | <artifactId>commons-io</artifactId> |
| | | <version>2.5</version> |
| | | </dependency> |
| | | |
| | | |
| | | </dependencies> |
| | | |
New file |
| | |
| | | package com.ks.push.dao; |
| | | |
| | | import com.ks.push.pojo.DO.BPushAppInfo; |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.data.mongodb.core.query.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class BPushAppInfoDao extends MongodbBaseDao<BPushAppInfo> { |
| | | |
| | | public void updateSelective(BPushAppInfo bean) { |
| | | Query query = new Query(); |
| | | Update update = new Update(); |
| | | query.addCriteria(Criteria.where("appCode").is(bean.getAppCode())); |
| | | if (bean.getName() != null) { |
| | | update.set("name", bean.getName()); |
| | | } |
| | | if (bean.getDesc() != null) { |
| | | update.set("desc", bean.getDesc()); |
| | | } |
| | | if (bean.getCreateTime() != null) { |
| | | update.set("createTime", bean.getCreateTime()); |
| | | } |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | |
| | | private Query getQuery(DaoQuery daoQuery) { |
| | | List<Criteria> andList = new ArrayList<>(); |
| | | if (daoQuery.appCode != null) { |
| | | andList.add(Criteria.where("appCode").is(daoQuery.appCode)); |
| | | } |
| | | |
| | | if (daoQuery.name != null) { |
| | | andList.add(Criteria.where("name").regex(daoQuery.name)); |
| | | } |
| | | |
| | | if (daoQuery.minCreateTime != null) { |
| | | andList.add(Criteria.where("createTime").gte(daoQuery.minCreateTime)); |
| | | } |
| | | |
| | | if (daoQuery.maxCreateTime != null) { |
| | | andList.add(Criteria.where("createTime").lt(daoQuery.maxCreateTime)); |
| | | } |
| | | |
| | | Criteria[] ands = new Criteria[andList.size()]; |
| | | andList.toArray(ands); |
| | | Query query = new Query(); |
| | | query.addCriteria(new Criteria().andOperator(ands)); |
| | | return query; |
| | | } |
| | | |
| | | public List<BPushAppInfo> list(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | query.limit(daoQuery.count); |
| | | query.skip(daoQuery.start); |
| | | return findList(query); |
| | | } |
| | | |
| | | public long count(DaoQuery daoQuery) { |
| | | Query query = getQuery(daoQuery); |
| | | return count(query); |
| | | } |
| | | |
| | | |
| | | public static class DaoQuery { |
| | | public String appCode; |
| | | public String name; |
| | | public Date minCreateTime; |
| | | public Date maxCreateTime; |
| | | public int start; |
| | | public int count; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ks.push.manager; |
| | | |
| | | import com.ks.push.dao.BPushAppInfoDao; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Component |
| | | public class BPushAppInfoManager { |
| | | |
| | | @Resource |
| | | private BPushAppInfoDao bPushAppInfoDao; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | [{type: 'checkbox', title: "ID"}, |
| | | {field: 'id', width: 80, sort: true, title: "ID"}, |
| | | {field: 'appCode', width: 120, sort: true, title: "应用唯一标识"}, |
| | | {field: 'appName', edit: 'text', width: 150, title: "应用名称"}, |
| | | {field: 'appDesc', edit: 'text', width: 200, title: "应用简介"}, |
| | | {field: 'remarks', edit: 'text', width: 200, title: "备注"}, |
| | | {field: 'name', edit: 'text', width: 150, title: "应用名称"}, |
| | | {field: 'desc', edit: 'text', width: 200, title: "应用简介"}, |
| | | {field: 'createTime', sort: true, width: 150, title: "创建时间"}, |
| | | {field: 'updateTime', sort: true, width: 150, title: "修改时间"}, |
| | | // {field: 'status', width: 80, title: "状态", templet: "#statusContainer"}, |
| | |
| | | package com.ks; |
| | | |
| | | import com.ks.lib.common.dao.MongodbBaseDao; |
| | | import com.ks.push.dao.BPushAppInfoDao; |
| | | import com.ks.push.pojo.DO.BPushAppInfo; |
| | | import com.ks.push.pojo.DO.BPushDeviceToken; |
| | | import com.ks.push.pojo.DO.BPushTaskExcuteResult; |
| | | import org.yeshi.utils.generater.SpringComponentGenerater; |
| | | import org.yeshi.utils.generater.entity.MongoDBDaoData; |
| | | import org.yeshi.utils.generater.entity.ServiceData; |
| | | import org.yeshi.utils.generater.mybatis.MyBatisMapperUtil; |
| | | |
| | | public class GeneralTest { |
| | |
| | | } |
| | | } |
| | | |
| | | @org.junit.Test |
| | | public void createService() { |
| | | try { |
| | | SpringComponentGenerater.createService(new ServiceData.Builder().setDaoClass(BPushAppInfoDao.class).setEntityClass(BPushAppInfo.class).setPackageName("").build(),"D:\\workspace\\DayBuy\\service-push\\src\\main\\java\\com\\ks\\push\\dao\\"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |