提交 9bc10771 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 732266f7
......@@ -12,10 +12,6 @@ import lombok.Data;
@Data
@ApiModel(value="EbookListStatisticsVO",description="查询文章集合返回的实体")
public class EbookListStatisticsVO {
@ApiModelProperty("id,新增时不需要填写")
private String id;
@ApiModelProperty(value = "标题")
private String name;
@ApiModelProperty(value = "浏览数量")
private Integer browseNum;
@ApiModelProperty("上传时间")
......
......@@ -13,6 +13,7 @@ import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.vo.resource.ResourceRelationListVo;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListStatisticsVO;
import com.zrqx.core.vo.resource.articlelibrary.ArticleLibraryListVO;
import com.zrqx.core.vo.resource.ebook.EbookListStatisticsVO;
/**
* 文章库
*/
......@@ -70,15 +71,17 @@ public interface ArticleLibraryMapper extends BaseMapper<ArticleLibrary> {
* @date: 2019年9月20日 上午10:39:57
*/
@Select("<script>"
+ "select id,name,DATE_FORMAT(uploadTime,'%Y-%m-%d') uploadTime,browseNum from res_article_library where DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt; date(uploadTime) "
+ "<if test = '" + NOTBLANK + "(form.beginTime)'>"
+ "and uploadTime &gt;= concat(#{form.beginTime}, ' 00:00:00' )"
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.endTime)'>"
+ "and uploadTime &lt;= concat(#{form.endTime}, ' 23:59:59')"
+ "</if>"
+ " ORDER BY uploadTime desc"
+ "</script>")
+"select createTime as uploadTime , count(createTime) as 'browseNum' from ("
+"select id,DATE_FORMAT(createTime,'%Y-%m-%d') createTime,goodsType from res_record where "
+ "date_sub(curdate(), INTERVAL 7 DAY) &lt;= date(createTime) and goodsType=2 "
+ "<if test = '" + NOTBLANK + "(form.beginTime)'>"
+ "and createTime &gt;= concat(#{form.beginTime}, ' 00:00:00' )"
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.endTime)'>"
+ " and createTime &lt;= concat(#{form.endTime}, ' 23:59:59')"
+ "</if>"
+ ") ss group by createTime"
+ "</script>")
List<ArticleLibraryListStatisticsVO> queryArticleReadingVolume(@Param("form")QueryStatisticsForm form);
......
......@@ -27,14 +27,16 @@ public interface BookMapper extends BaseMapper<Book> {
+ "</script>")
List<ResourceRelationListVo> queryByTileAndDiyType(@Param("form")QueryResourceForPoPForm form);
@Select("<script>"
+"select id,name,DATE_FORMAT(uploadTime,'%Y-%m-%d') uploadTime,browseNum from res_book where DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt; date(uploadTime) "
+ "<if test = '" + NOTBLANK + "(form.beginTime)'>"
+ "and uploadTime &gt;= concat(#{form.beginTime}, ' 00:00:00' )"
+"select createTime as uploadTime , count(createTime) as 'browseNum' from ("
+"select id,DATE_FORMAT(createTime,'%Y-%m-%d') createTime,goodsType from res_record where "
+ "date_sub(curdate(), INTERVAL 7 DAY) &lt;= date(createTime) and goodsType=1 "
+ "<if test = '" + NOTBLANK + "(form.beginTime)'>"
+ "and createTime &gt;= concat(#{form.beginTime}, ' 00:00:00' )"
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.endTime)'>"
+ "and uploadTime &lt;= concat(#{form.endTime}, ' 23:59:59')"
+ " and createTime &lt;= concat(#{form.endTime}, ' 23:59:59')"
+ "</if>"
+ " ORDER BY uploadTime desc"
+ ") ss group by createTime"
+ "</script>")
List<EbookListStatisticsVO> queryBookReadingVolume(@Param("form")QueryStatisticsForm form);
......
package com.zrqx.resource.fg.controller.articlelibrary;
import java.text.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -35,7 +37,7 @@ public class FgArticleLibraryController {
@ApiOperation(value = "查询", notes = "根据ID查询")
@GetMapping(value = ResourceRequestPath.GET_OID)
public CallBack<FgArticleLibraryOneVO> getById(@PathVariable String oid) {
public CallBack<FgArticleLibraryOneVO> getById(@PathVariable String oid) throws ParseException {
FgArticleLibraryOneVO vo = service.articleOneInfoById(oid,true);
// 保存浏览记录
recordService.saveOrUpdateRecord(oid, AllResourceTypeEnum.ARTICLE.getCode().toString());
......
package com.zrqx.resource.fg.controller.ebook;
import java.text.ParseException;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
......@@ -78,7 +79,7 @@ public class FgEbookController {
@ApiOperation("根据id查找电子书")
@GetMapping(ResourceRequestPath.GET)
public CallBack<FgEbookVO> echo(QueryResourceRelationForm entity) {
public CallBack<FgEbookVO> echo(QueryResourceRelationForm entity) throws ParseException {
FgEbookVO vo = bookservice.ebookOneInfoById(entity.getId()).get(0);
// 保存浏览记录
recordService.saveOrUpdateRecord(entity.getId(), AllResourceTypeEnum.BOOK.getCode().toString());
......
package com.zrqx.resource.fg.service.record;
import java.text.ParseException;
import java.util.List;
import com.zrqx.core.model.resource.record.Record;
......@@ -17,7 +18,7 @@ public interface FgRecordService extends BaseService<Record, Integer> {
* @author ycw
* @date: 2019年2月12日 下午3:02:55
*/
boolean saveOrUpdateRecord(String goodsId, String goodsType);
boolean saveOrUpdateRecord(String goodsId, String goodsType) throws ParseException ;
/**
* 我的浏览记录
......@@ -25,5 +26,5 @@ public interface FgRecordService extends BaseService<Record, Integer> {
* @author ycw
* @date: 2019年2月12日 下午4:16:19
*/
List<FgMyRecordVO> getMyRecord();
List<FgMyRecordVO> getMyRecord() ;
}
package com.zrqx.resource.fg.service.record;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
......@@ -60,31 +62,24 @@ public class FgRecordServiceImpl extends BaseServiceImpl<Record, Integer>
* @param goodsType 资源类型 电子书2-1 文章2-2
* @return
* @author ycw
* @throws ParseException
* @date: 2019年2月12日 下午3:02:55
*/
@Override
public boolean saveOrUpdateRecord(String goodsId, String goodsType) {
if(!redis.isExistMember()){
return false;
}
public boolean saveOrUpdateRecord(String goodsId, String goodsType) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Record record = new Record();
record.setGoodsId(goodsId);
record.setGoodsType(goodsType);
record.setMemberId(redis.getMember().getId());
Record records = mapper.selectOne(record);
if (records != null) {
records.setCreateTime(new Date());
sdf.parse(new Date().toString());
records.setCreateTime(sdf.parse(new Date().toString()));
mapper.updateByPrimaryKeySelective(records);
} else {
record.setCreateTime(new Date());
mapper.insertSelective(record);
}
//如果浏览记录超过15条,按照浏览时间降序排列,删除多余的浏览记录
Record myRecord = new Record();
myRecord.setMemberId(redis.getMember().getId());
if(mapper.selectCount(myRecord) > 15){
mapper.deleteOtherRecord(redis.getMember().getId());
}
return true;
}
......
package com.zrqx.resource.wap.controller.articlelibrary;
import java.text.ParseException;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
......@@ -51,7 +52,7 @@ public class WapArticleLibraryController {
}
@ApiOperation(value = "查询", notes = "根据ID查询")
@GetMapping(value = ResourceRequestPath.GET_OID)
public CallBack<FgArticleLibraryOneVO> getById(@PathVariable String oid) {
public CallBack<FgArticleLibraryOneVO> getById(@PathVariable String oid) throws ParseException {
FgArticleLibraryOneVO vo = service.articleOneInfoById(oid,true);
// 保存浏览记录
recordService.saveOrUpdateRecord(oid, AllResourceTypeEnum.ARTICLE.getCode().toString());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论