Commit 01bc4162 by 田超

Merge branch 'feature/appletSql' into 'master'

feat:[none]appletSql

See merge request rays/pcloud-book!1426
parents a21a5992 f48731c3
...@@ -2,6 +2,7 @@ package com.pcloud.book.applet.biz.impl; ...@@ -2,6 +2,7 @@ package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.biz.AppletResourceApplyBiz; import com.pcloud.book.applet.biz.AppletResourceApplyBiz;
import com.pcloud.book.applet.biz.AppletThirdResourcesBiz; import com.pcloud.book.applet.biz.AppletThirdResourcesBiz;
import com.pcloud.book.applet.contants.AppletConstants;
import com.pcloud.book.applet.contants.AppletResourceApplyConstants; import com.pcloud.book.applet.contants.AppletResourceApplyConstants;
import com.pcloud.book.applet.dao.AppletLinkClickDao; import com.pcloud.book.applet.dao.AppletLinkClickDao;
import com.pcloud.book.applet.dao.AppletNewsDao; import com.pcloud.book.applet.dao.AppletNewsDao;
...@@ -28,6 +29,7 @@ import com.pcloud.common.page.PageBeanNew; ...@@ -28,6 +29,7 @@ import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam; import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils; import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.readercenter.wechat.entity.WechatUser; import com.pcloud.readercenter.wechat.entity.WechatUser;
...@@ -434,11 +436,22 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz { ...@@ -434,11 +436,22 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
@Override @Override
public PageBeanNew<AppletThirdResources> getThirdResourcesByGradeLabel4ResourcePage(Long gradeLabelId, Integer currentPage, Integer numPerPage) { public PageBeanNew<AppletThirdResources> getThirdResourcesByGradeLabel4ResourcePage(Long gradeLabelId, Integer currentPage, Integer numPerPage) {
String startDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -7), DateUtils.DATE_FORMAT_DATEONLY); String startDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -7), DateUtils.DATE_FORMAT_DATEONLY);
Integer crowdType = gradeLabelId.intValue();
String key = AppletConstants.H5_THIRD_RESOURCE_REDIS+startDate;
String field = gradeLabelId.toString();
//前6条缓存中取
if (currentPage == 0 && numPerPage == 6) {
List<AppletThirdResources> resourcesList = JedisClusterUtils.hgetJson2List(key, field, AppletThirdResources.class);
if (!ListUtils.isEmpty(resourcesList)) {
Integer count = thirdResourcesDao.countResourceIdByGradeLabel(crowdType);
return new PageBeanNew<>(currentPage, numPerPage, count, resourcesList);
}
}
//根据标签查询,按照近7天浏览量排序 //根据标签查询,按照近7天浏览量排序
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("startDate", startDate); paramMap.put("startDate", startDate);
paramMap.put("crowdType", gradeLabelId.intValue()); paramMap.put("crowdType", crowdType);
PageBeanNew<Long> idPageBean = thirdResourcesDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listResourceIdByGradeLabelAndClickCount"); PageBeanNew<Long> idPageBean = thirdResourcesDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listResourceIdByGradeLabelAndClickCount","countResourceIdByGradeLabel");
if (ListUtils.isEmpty(idPageBean.getRecordList())) { if (ListUtils.isEmpty(idPageBean.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, idPageBean.getTotalCount(), new ArrayList<>()); return new PageBeanNew<>(currentPage, numPerPage, idPageBean.getTotalCount(), new ArrayList<>());
} }
...@@ -446,6 +459,10 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz { ...@@ -446,6 +459,10 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
List<AppletThirdResources> thirdResources = thirdResourcesDao.getAppletsByIds(idPageBean.getRecordList()); List<AppletThirdResources> thirdResources = thirdResourcesDao.getAppletsByIds(idPageBean.getRecordList());
//推送图片类型 //推送图片类型
setResourcesPic(thirdResources); setResourcesPic(thirdResources);
if (currentPage == 0 && numPerPage == 6 && !ListUtils.isEmpty(thirdResources)) {
JedisClusterUtils.hset2Json(key, field, thirdResources);
JedisClusterUtils.expire(key, 2*60*60);
}
return new PageBeanNew<>(currentPage, numPerPage, idPageBean.getTotalCount(), thirdResources); return new PageBeanNew<>(currentPage, numPerPage, idPageBean.getTotalCount(), thirdResources);
} }
......
...@@ -80,6 +80,11 @@ public class AppletConstants { ...@@ -80,6 +80,11 @@ public class AppletConstants {
public static final String APPLET_RESOURCE_AGGR_STATIS = CacheConstant.BOOK +"APPLET:getAggrStatis"; public static final String APPLET_RESOURCE_AGGR_STATIS = CacheConstant.BOOK +"APPLET:getAggrStatis";
/** /**
* 小睿H5第三方资源推荐
*/
public static final String H5_THIRD_RESOURCE_REDIS = CacheConstant.BOOK +"APPLET:thirdResource4H5";
/**
* 未配置答案的书刊 * 未配置答案的书刊
*/ */
public static final List<Long> NO_ANSWER_BOOK = Arrays.asList( public static final List<Long> NO_ANSWER_BOOK = Arrays.asList(
......
...@@ -19,4 +19,6 @@ public interface AppletThirdResourcesDao extends BaseDao<AppletThirdResources> { ...@@ -19,4 +19,6 @@ public interface AppletThirdResourcesDao extends BaseDao<AppletThirdResources> {
List<AppletThirdResources> getAppletsByIds(List<Long> ids); List<AppletThirdResources> getAppletsByIds(List<Long> ids);
AppletThirdResources getByResourcesId(Long id); AppletThirdResources getByResourcesId(Long id);
Integer countResourceIdByGradeLabel(Integer crowdType);
} }
...@@ -47,4 +47,11 @@ public class AppletThirdResourcesDaoImpl extends BaseDaoImpl<AppletThirdResource ...@@ -47,4 +47,11 @@ public class AppletThirdResourcesDaoImpl extends BaseDaoImpl<AppletThirdResource
map.put("id", id); map.put("id", id);
return getSessionTemplate().selectOne(getStatement("getByResourcesId"), map); return getSessionTemplate().selectOne(getStatement("getByResourcesId"), map);
} }
@Override
public Integer countResourceIdByGradeLabel(Integer crowdType) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("crowdType", crowdType);
return getSessionTemplate().selectOne(getStatement("countResourceIdByGradeLabel"), paramMap);
}
} }
...@@ -605,6 +605,9 @@ public class QrcodeSceneConsr { ...@@ -605,6 +605,9 @@ public class QrcodeSceneConsr {
@ParamLog("查书刊订阅的公众号二维码") @ParamLog("查书刊订阅的公众号二维码")
public GroupQrcodeVO getSubscribeQrcode(Long accountSettingId) { public GroupQrcodeVO getSubscribeQrcode(Long accountSettingId) {
GroupQrcodeVO qrcodeVO = new GroupQrcodeVO(); GroupQrcodeVO qrcodeVO = new GroupQrcodeVO();
if (null == accountSettingId) {
return qrcodeVO;
}
try { try {
qrcodeVO = ResponseHandleUtil.parseResponse(qrcodeSceneService.getSubscribeQrcode(accountSettingId), GroupQrcodeVO.class); qrcodeVO = ResponseHandleUtil.parseResponse(qrcodeSceneService.getSubscribeQrcode(accountSettingId), GroupQrcodeVO.class);
...@@ -616,6 +619,9 @@ public class QrcodeSceneConsr { ...@@ -616,6 +619,9 @@ public class QrcodeSceneConsr {
public AccountSetting getAppInfo(Long accountSettingId) { public AccountSetting getAppInfo(Long accountSettingId) {
AccountSetting accountSetting = new AccountSetting(); AccountSetting accountSetting = new AccountSetting();
if (null == accountSettingId) {
return accountSetting;
}
try { try {
accountSetting = ResponseHandleUtil.parseResponse(accountSettingService.getAppInfo(accountSettingId), AccountSetting.class); accountSetting = ResponseHandleUtil.parseResponse(accountSettingService.getAppInfo(accountSettingId), AccountSetting.class);
......
...@@ -328,5 +328,17 @@ ...@@ -328,5 +328,17 @@
a.target_id DESC a.target_id DESC
</select> </select>
<select id="countResourceIdByGradeLabel" parameterType="map" resultType="integer">
SELECT
COUNT(DISTINCT a.target_id)
FROM
applet_resource_apply a
INNER JOIN applet_third_resources r ON a.target_id = r.id
WHERE
a.crowd_type = #{crowdType}
AND a.target_type = "THIRD_RESOURCE"
AND a.target_id > 0
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment