Commit fda6080f by 吴博

feat: [1004044] 小程序首页书单

parent e7145230
...@@ -288,4 +288,18 @@ public interface AppletBooklistBiz { ...@@ -288,4 +288,18 @@ public interface AppletBooklistBiz {
* @return * @return
*/ */
Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds); Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds);
/**
* 更新外部书单推荐到首页状态
* @param appletOuterBooklistDTO
*/
void updateOuterBooklist(AppletOuterBooklistDTO appletOuterBooklistDTO);
/**
* 客户端获取外部书单列表
* @param currentPage
* @param numPerPage
* @return
*/
PageBeanNew<AppletOuterBooklistDTO> listPageOuterBooklist4Wechat(Integer currentPage, Integer numPerPage);
} }
...@@ -33,6 +33,7 @@ import com.pcloud.book.es.entity.ESBookAndAdviser; ...@@ -33,6 +33,7 @@ import com.pcloud.book.es.entity.ESBookAndAdviser;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant; import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.book.util.properties.BookProps; import com.pcloud.book.util.properties.BookProps;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
...@@ -782,4 +783,31 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz { ...@@ -782,4 +783,31 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
public Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds) { public Map<Long, AppletBooklistDTO> getBookListMap(List<Long> bookListIds) {
return appletBooklistDao.getBookListMap(bookListIds); return appletBooklistDao.getBookListMap(bookListIds);
} }
@Override
public void updateOuterBooklist(AppletOuterBooklistDTO appletOuterBooklistDTO) {
appletOuterBooklistDao.updateOuterBooklist(appletOuterBooklistDTO);
}
@Override
public PageBeanNew<AppletOuterBooklistDTO> listPageOuterBooklist4Wechat(Integer currentPage, Integer numPerPage) {
Map<String, Object> map = new HashMap<>();
map.put("isShowHome", YesOrNoEnums.YES.getValue());
PageBeanNew<AppletOuterBooklistDTO> pageBeanNew = appletOuterBooklistDao.listPageNew(new PageParam(currentPage, numPerPage), map, "listPageOuterBooklist");
if (!ListUtils.isEmpty(pageBeanNew.getRecordList())) {
for (AppletOuterBooklistDTO appletOuterBooklistDTO : pageBeanNew.getRecordList()) {
Long booklistId = appletOuterBooklistDTO.getId();
//带3本书
String key = AppletConstants.OUTER_BOOKLIST_BOOK + booklistId;
List<AppletOuterBookDTO> bookList = JedisClusterUtils.getJsonList(key, AppletOuterBookDTO.class);
if (ListUtils.isEmpty(bookList)) {
bookList = appletOuterBookDao.listPageOuterBookByBooklistId(booklistId, 3);
JedisClusterUtils.setJson(key, bookList);
JedisClusterUtils.expire(key, 3600 * 12);
}
appletOuterBooklistDTO.setOuterBookDTOS(bookList);
}
}
return pageBeanNew;
}
} }
...@@ -86,4 +86,10 @@ public interface AppletOuterBooklistDao extends BaseDao<AppletOuterBooklist>{ ...@@ -86,4 +86,10 @@ public interface AppletOuterBooklistDao extends BaseDao<AppletOuterBooklist>{
* @param id * @param id
*/ */
void updateDeleteState(Long id); void updateDeleteState(Long id);
/**
* 更新外部书单
* @param appletOuterBooklistDTO
*/
void updateOuterBooklist(AppletOuterBooklistDTO appletOuterBooklistDTO);
} }
\ No newline at end of file
...@@ -70,4 +70,10 @@ public class AppletOuterBooklistDaoImpl extends BaseDaoImpl<AppletOuterBooklist> ...@@ -70,4 +70,10 @@ public class AppletOuterBooklistDaoImpl extends BaseDaoImpl<AppletOuterBooklist>
getSessionTemplate().update(getStatement("updateDeleteState"), id); getSessionTemplate().update(getStatement("updateDeleteState"), id);
} }
@Override
public void updateOuterBooklist(AppletOuterBooklistDTO appletOuterBooklistDTO) {
getSessionTemplate().update(getStatement("updateOuterBooklist"), appletOuterBooklistDTO);
}
} }
...@@ -61,4 +61,9 @@ public class AppletOuterBooklistDTO extends BaseDto { ...@@ -61,4 +61,9 @@ public class AppletOuterBooklistDTO extends BaseDto {
private List<AppletOuterBookDTO> outerBookDTOS; private List<AppletOuterBookDTO> outerBookDTOS;
private Long agentId; private Long agentId;
/**
* 书单推荐是否在小程序首页展示
*/
private Integer isShowHome;
} }
\ No newline at end of file
...@@ -50,5 +50,10 @@ public class AppletOuterBooklist extends BaseEntity { ...@@ -50,5 +50,10 @@ public class AppletOuterBooklist extends BaseEntity {
private Long agentId; private Long agentId;
/**
* 书单推荐是否在小程序首页展示
*/
private Integer isShowHome;
} }
\ No newline at end of file
...@@ -1185,6 +1185,27 @@ public class AppletHomeFacade { ...@@ -1185,6 +1185,27 @@ public class AppletHomeFacade {
appletBannerBiz.bannerClickRecord(wechatUserId, bannerId); appletBannerBiz.bannerClickRecord(wechatUserId, bannerId);
return new ResponseDto<>(); return new ResponseDto<>();
} }
@ApiOperation("更新外部书单推荐到首页状态")
@PostMapping("updateOuterBooklist")
public ResponseDto<?> updateOuterBooklist(@RequestHeader("token") String token, @RequestBody AppletOuterBooklistDTO appletOuterBooklistDTO) {
Map<String,Object> map = SessionUtil.getToken4Redis(token);
Long agentId = (Long) map.get(SessionUtil.RAY_AGENT_ID);
appletOuterBooklistDTO.setAgentId(agentId==null?0L:agentId);
appletBooklistBiz.updateOuterBooklist(appletOuterBooklistDTO);
return new ResponseDto<>();
}
@ApiOperation("客户端外部书单列表")
@GetMapping("listPageOuterBooklist4Wechat")
public ResponseDto<?> listPageOuterBooklist4Wechat(@CookieValue("userInfo") String userInfo,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletBooklistBiz.listPageOuterBooklist4Wechat(currentPage, numPerPage));
}
} }
......
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="agentId" column="agent_id" jdbcType="BIGINT" /> <result property="agentId" column="agent_id" jdbcType="BIGINT" />
<result property="isShowHome" column="is_show_home" jdbcType="TINYINT" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, booklist_name, user_name, digest, display_pic, publish, create_time, update_time, agent_id id, booklist_name, user_name, digest, display_pic, publish, create_time, update_time, agent_id, is_show_home
</sql> </sql>
<!--查询单个--> <!--查询单个-->
<select id="getById" resultMap="AppletOuterBooklistMap"> <select id="getById" resultMap="AppletOuterBooklistMap">
...@@ -27,8 +28,8 @@ ...@@ -27,8 +28,8 @@
<!--新增所有列--> <!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true"> <insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.applet_outer_booklist(booklist_name, user_name, digest, display_pic, publish, create_time, update_time, agent_id) insert into book.applet_outer_booklist(booklist_name, user_name, digest, display_pic, publish, create_time, update_time, agent_id, is_show_home)
values (#{booklistName}, #{userName}, #{digest}, #{displayPic}, #{publish}, now(), now(), #{agentId}) values (#{booklistName}, #{userName}, #{digest}, #{displayPic}, #{publish}, now(), now(), #{agentId}, #{isShowHome})
</insert> </insert>
<!--通过主键修改数据--> <!--通过主键修改数据-->
...@@ -48,6 +49,9 @@ ...@@ -48,6 +49,9 @@
<if test="publish != null and publish != ''"> <if test="publish != null and publish != ''">
publish = #{publish}, publish = #{publish},
</if> </if>
<if test="isShowHome != null">
is_show_home = #{isShowHome},
</if>
update_time = now(), update_time = now(),
</set> </set>
where id = #{id} where id = #{id}
...@@ -80,7 +84,8 @@ ...@@ -80,7 +84,8 @@
COUNT(c.id) bookCounts, COUNT(c.id) bookCounts,
b.digest, b.digest,
b.publish, b.publish,
b.create_time createTime b.create_time createTime,
b.is_show_home isShowHome
FROM FROM
applet_outer_booklist b applet_outer_booklist b
LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id
...@@ -99,6 +104,9 @@ ...@@ -99,6 +104,9 @@
and b.agent_id = 0 and b.agent_id = 0
</otherwise> </otherwise>
</choose> </choose>
<if test="isShowHome != null">
and is_show_home = #{isShowHome}
</if>
group by b.id group by b.id
ORDER BY ORDER BY
b.create_time DESC b.create_time DESC
...@@ -157,7 +165,8 @@ ...@@ -157,7 +165,8 @@
COUNT(c.id) bookCounts, COUNT(c.id) bookCounts,
b.digest, b.digest,
b.publish, b.publish,
b.create_time createTime b.create_time createTime,
b.is_show_home isShowHome
FROM FROM
applet_outer_booklist b applet_outer_booklist b
LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id LEFT JOIN applet_outer_booklist_config c ON b.id = c.booklist_id
...@@ -186,4 +195,15 @@ ...@@ -186,4 +195,15 @@
where where
id = #{id} id = #{id}
</update> </update>
<select id="updateOuterBooklist" parameterType="com.pcloud.book.applet.dto.AppletOuterBooklistDTO">
update
applet_outer_booklist
set
is_show_home = #{isShowHome},
update_time = now()
where
id = #{id}
</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