fanli/src/main/java/com/yeshi/fanli/controller/admin/PushRecordAdminController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/dao/config/PushRecordDao.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushRecordMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/entity/xinge/PushRecord.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/mapping/push/PushRecordMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushRecordServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushRecordService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli/src/main/java/com/yeshi/fanli/controller/admin/PushRecordAdminController.java
@@ -7,14 +7,12 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.yeshi.utils.JsonUtil; import com.yeshi.fanli.entity.xinge.PushRecord; import com.yeshi.fanli.service.inter.push.PushRecordService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; import org.yeshi.utils.JsonUtil; import net.sf.json.JSONObject; @@ -47,15 +45,15 @@ type = 0; } List<PushRecord> list = pushRecordService.getPushRecordList(key, type, pageIndex); int pageSize = Constant.PAGE_SIZE; List<PushRecord> list = pushRecordService.getPushRecordList((pageIndex-1) * pageSize, pageSize, key, type); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无更多数据")); return; } int pageSize = Constant.PAGE_SIZE; int count = pushRecordService.getCount(key, type, pageIndex); long count = pushRecordService.getCount(key, type); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); fanli/src/main/java/com/yeshi/fanli/dao/config/PushRecordDao.java
File was deleted fanli/src/main/java/com/yeshi/fanli/dao/mybatis/push/PushRecordMapper.java
@@ -1,8 +1,22 @@ package com.yeshi.fanli.dao.mybatis.push; import java.util.List; import org.apache.ibatis.annotations.Param; import com.yeshi.fanli.dao.BaseMapper; import com.yeshi.fanli.entity.xinge.PushRecord; public interface PushRecordMapper extends BaseMapper<PushRecord>{ List<PushRecord> listQuery(@Param("start")long start, @Param("count") int count, @Param("key") String key, @Param("type") Integer type); Long countQuery(@Param("key") String key, @Param("type") Integer type); PushRecord getByAndroidPushId(@Param("pushId") String pushId); PushRecord getByIosPushId(@Param("pushId") String pushId); } fanli/src/main/java/com/yeshi/fanli/entity/xinge/PushRecord.java
@@ -1,58 +1,48 @@ package com.yeshi.fanli.entity.xinge; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import org.yeshi.utils.mybatis.Column; import org.yeshi.utils.mybatis.Table; @Entity @Table(name = "yeshi_ec_push_record") @org.yeshi.utils.mybatis.Table("yeshi_ec_push_record") @Table("yeshi_ec_push_record") public class PushRecord { @Id @GeneratedValue(strategy = GenerationType.AUTO) @org.yeshi.utils.mybatis.Column(name = "id") @Column(name = "id") private Long id; @Column(name = "`url`") @org.yeshi.utils.mybatis.Column(name = "url") @Column(name = "url") private String url; @Column(name = "`type`") @org.yeshi.utils.mybatis.Column(name = "type") @Column(name = "type") private Integer type; // 1.商品推送 2.url推送 3.推荐详情页面推送 4.站内信 @Column(name = "`title`") @org.yeshi.utils.mybatis.Column(name = "title") @Column(name = "title") private String title; @Column(name = "`state`") @org.yeshi.utils.mybatis.Column(name = "state") @Column(name = "state") private Integer state;// 1:都成功 2:仅android成功 3.仅IOS成功 4.都失败 @org.yeshi.utils.mybatis.Column(name = "createtime") @Column(name = "createtime") private Long createtime; @org.yeshi.utils.mybatis.Column(name = "count") @Column(name = "count") private Long count; @org.yeshi.utils.mybatis.Column(name = "iosPushId") @Column(name = "iosPushId") private String iosPushId; @org.yeshi.utils.mybatis.Column(name = "androidPushId") @Column(name = "androidPushId") private String androidPushId; @org.yeshi.utils.mybatis.Column(name = "account") @Column(name = "account") private Integer account; // 接收对象 0:�?��设备 1:IOS设备 2:Android设备 3.单个账号 4.其他 @org.yeshi.utils.mybatis.Column(name = "appName") @Column(name = "state") private String appName; @org.yeshi.utils.mybatis.Column(name = "uid") @Column(name = "`uid`") @Column(name = "uid") private Long uid; public Long getId() { return id; fanli/src/main/java/com/yeshi/fanli/mapping/push/PushRecordMapper.xml
@@ -68,4 +68,41 @@ <if test="uid != null">uid=#{uid,jdbcType=BIGINT},</if> </set> where id = #{id,jdbcType=BIGINT} </update> <select id="listQuery" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_push_record p WHERE 1=1 <if test="key != null and key != '' "> AND p.`title` LIKE '%${key}%' </if> <if test="type != null and type != 0 "> AND p.`type` = #{type} </if> ORDER BY p.id DESC LIMIT #{start},#{count} </select> <select id="countQuery" resultType="java.lang.Long"> SELECT IFNULL(COUNT(p.`id`),0) FROM yeshi_ec_push_record p WHERE 1=1 <if test="key != null and key != '' "> AND p.`title` LIKE '%${key}%' </if> <if test="type != null and type != 0 "> AND p.`type` = #{type} </if> </select> <select id="getByAndroidPushId" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_push_record p WHERE p.`androidPushId` = #{pushId} LIMIT 1 </select> <select id="getByIosPushId" resultMap="BaseResultMap"> SELECT * FROM yeshi_ec_push_record p WHERE p.`iosPushId` = #{pushId} LIMIT 1 </select> </mapper> fanli/src/main/java/com/yeshi/fanli/service/impl/push/PushRecordServiceImpl.java
@@ -1,98 +1,52 @@ package com.yeshi.fanli.service.impl.push; import java.io.Serializable; import java.util.List; import javax.annotation.Resource; import org.hibernate.HibernateException; import org.hibernate.SQLQuery; import org.hibernate.Session; import org.springframework.orm.hibernate4.HibernateCallback; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.config.PushRecordDao; import com.yeshi.fanli.dao.mybatis.push.PushRecordMapper; import com.yeshi.fanli.entity.xinge.PushRecord; import com.yeshi.fanli.service.inter.push.PushRecordService; import com.yeshi.fanli.util.Constant; @Service public class PushRecordServiceImpl implements PushRecordService { @Resource private PushRecordDao dao; private PushRecordMapper pushRecordMapper; public void save(PushRecord pushRecord) { pushRecord.setCreatetime(System.currentTimeMillis()); dao.save(pushRecord); public List<PushRecord> getPushRecordList(long start, int pageSize,String key, int type) { return pushRecordMapper.listQuery(start, pageSize, key, type); } public List<PushRecord> getPushRecordList(String title, int type, int page) { int start = (page-1) * Constant.PAGE_SIZE; StringBuffer hqlBuf=new StringBuffer("from PushRecord pr where 1=1 "); if(title !=null && !"".equals(title.trim())){ hqlBuf.append(" and (pr.title like ? )"); } if(type != 0){ hqlBuf.append(" and (pr.type = ? )"); } hqlBuf.append(" order by pr.id desc "); String hql = hqlBuf.toString(); if(hql.contains("pr.title") && hql.contains("pr.type")){ return dao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[]{"%"+title+"%",type}); }else if(hql.contains("pr.title") && !hql.contains("pr.type")){ return dao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[]{"%"+title+"%"}); }else if(!hql.contains("pr.title") && hql.contains("pr.type")){ return dao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[]{type}); }else{ return dao.list(hqlBuf.toString(), start, Constant.PAGE_SIZE, new Serializable[]{}); } public Long getCount(String title, int type) { return pushRecordMapper.countQuery(title, type); } public int getCount(String title, int type, int page) { StringBuffer hqlBuf=new StringBuffer("select count(*) from PushRecord pr where 1=1 "); if(title !=null && !"".equals(title.trim())){ hqlBuf.append(" and (pr.title like ? )"); } if(type != 0){ hqlBuf.append(" and (pr.type = ? )"); } String hql = hqlBuf.toString(); if(hql.contains("pr.title") && hql.contains("pr.type")){ return (int) dao.getCount(hqlBuf.toString(), new Serializable[]{"%"+title+"%",type}); }else if(hql.contains("pr.title") && !hql.contains("pr.type")){ return (int) dao.getCount(hqlBuf.toString(),new Serializable[]{"%"+title+"%"}); }else if(!hql.contains("pr.title") && hql.contains("pr.type")){ return (int) dao.getCount(hqlBuf.toString(),new Serializable[]{type}); }else{ return (int) dao.getCount(hqlBuf.toString(),new Serializable[]{}); } } public void increaseByAndroid(final String pushId) { final String sql="update yeshi_ec_push_record pr set pr.count=pr.count+1 where pr.androidPushId = ? "; dao.excute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { SQLQuery query = session.createSQLQuery(sql); query.setParameter(0, pushId); return query.executeUpdate(); public void increaseByAndroid(String pushId) { PushRecord pushRecord = pushRecordMapper.getByAndroidPushId(pushId); if (pushRecord != null) { Long count = pushRecord.getCount(); if(count == null) { pushRecord.setCount(1L); } else { pushRecord.setCount(count + 1); } }); pushRecordMapper.updateByPrimaryKeySelective(pushRecord); } } public void increaseByIOS(final String pushId) { final String sql="update yeshi_ec_push_record pr set pr.count=pr.count+1 where pr.iosPushId = ? "; dao.excute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { SQLQuery query = session.createSQLQuery(sql); query.setParameter(0, pushId); return query.executeUpdate(); public void increaseByIOS(String pushId) { PushRecord pushRecord = pushRecordMapper.getByIosPushId(pushId); if (pushRecord != null) { Long count = pushRecord.getCount(); if(count == null) { pushRecord.setCount(1L); } else { pushRecord.setCount(count + 1); } }); pushRecordMapper.updateByPrimaryKeySelective(pushRecord); } } } fanli/src/main/java/com/yeshi/fanli/service/inter/push/PushRecordService.java
@@ -6,11 +6,9 @@ public interface PushRecordService { public void save(PushRecord pushRecord); public List<PushRecord> getPushRecordList(long page, int pageSize, String title, int type); public List<PushRecord> getPushRecordList(String title, int type, int page); public int getCount(String title, int type, int page); public Long getCount(String title, int type); public void increaseByAndroid(String pushId);