Commit 20dbb89e by 桂前礼

feat: [1003651] 强化banner的转化和灵活配置能力

parent 636613d8
......@@ -49,5 +49,7 @@ public interface AppletBannerBiz {
* @date:2020/7/17 16:03
* * @param null
*/
PageBeanNew<AppletBannerDTO> listBanner4Wechat(Integer currentPage, Integer numPerPage, Boolean showState, Long officialAccountsId);
PageBeanNew<AppletBannerDTO> listBanner4Wechat(Integer currentPage, Integer numPerPage, Boolean showState, Long officialAccountsId, Long wechatUserId);
void bannerClickRecord(Long wechatUserId, Long bannerId);
}
......@@ -4,7 +4,9 @@ import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("小程序banner")
public class AppletBannerDTO extends BaseDto {
......@@ -15,7 +17,7 @@ public class AppletBannerDTO extends BaseDto {
@ApiModelProperty("banner图")
private String bannerPic;
@ApiModelProperty("跳转类型(1指定页面2web页面)")
@ApiModelProperty("跳转类型 1指定页面, 2web页面, 3资讯, 4应用作品")
private Integer jumpType;
@ApiModelProperty("跳转地址")
......@@ -26,4 +28,22 @@ public class AppletBannerDTO extends BaseDto {
@ApiModelProperty("是否展示")
private Boolean showState;
@ApiModelProperty("点击量PV/UV")
private String clickPVUV;
@ApiModelProperty("咨询的选择方式 1自定义, 2自动获取")
private Integer fillType;
@ApiModelProperty("作品/应用/咨询的ID")
private Long serveId;
@ApiModelProperty("作品/应用/咨询的类型")
private Integer serveType;
@ApiModelProperty("咨询具体信息")
private AppletNewsDTO newsItem;
@ApiModelProperty("咨询具体信息")
private ServeItemInfoDTO appItem;
}
package com.pcloud.book.applet.dto;
import lombok.Data;
@Data
public class AppletBannerStats {
private Long bannerId;
private Long pv;
private Long uv;
}
package com.pcloud.book.applet.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("作品 应用信息封装")
public class ServeItemInfoDTO implements Serializable {
private static final long serialVersionUID = 127018233194941988L;
@ApiModelProperty("ID")
private Long serveId;
@ApiModelProperty("类型")
private Integer serveType;
@ApiModelProperty("名称")
private String serveName;
@ApiModelProperty("类型名称")
private String serveTypeName;
@ApiModelProperty("图片")
private String servePic;
@ApiModelProperty("宽图")
private String transverseImg;
@ApiModelProperty("跳转链接")
private String resultUrl;
@ApiModelProperty("是否包含第三方链接")
private Boolean hasThirdLink;
}
......@@ -4,7 +4,9 @@ import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("小程序banner")
public class AppletBanner extends BaseEntity {
......@@ -12,7 +14,7 @@ public class AppletBanner extends BaseEntity {
@ApiModelProperty("banner图")
private String bannerPic;
@ApiModelProperty("跳转类型(1指定页面2web页面)")
@ApiModelProperty("跳转类型 1指定页面, 2web页面, 3资讯, 4应用|作品")
private Integer jumpType;
@ApiModelProperty("跳转地址")
......@@ -26,4 +28,17 @@ public class AppletBanner extends BaseEntity {
@ApiModelProperty("出版社id")
private Long agentId;
/**
* 选择自动获取,将依据当前用户正在读的书,所属分类获取最新上架的资讯,
* 同时,如果不传banner将会自动获取咨询对应的大图
*/
@ApiModelProperty("咨询的选择方式 1自定义, 2自动获取")
private Integer fillType;
@ApiModelProperty("作品/应用/咨询的ID")
private Long serveId;
@ApiModelProperty("作品/应用/咨询的类型")
private Integer serveType;
}
package com.pcloud.book.applet.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* applet_banner_record
* @author guiq
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AppletBannerRecord implements Serializable {
/**
* 编号
*/
private Long id;
/**
* banner图
*/
private Long bannerId;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 用户id
*/
private Long wechatUserId;
/**
* ID
*/
private Long serveId;
/**
* 资讯1 | 作品6 | 应用5
*/
private Integer serveType;
/**
* 跳转类型
*/
private Integer jumpType;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -39,10 +39,13 @@ import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.ParamChecker;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.string.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
......@@ -55,15 +58,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import java.util.List;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@Api(description = "小睿小程序首页")
@RestController("appletHomeFacade")
@RequestMapping("appletHome")
......@@ -343,10 +342,12 @@ public class AppletHomeFacade {
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage) {
Long officialAccountsId = Cookie.getId(userInfo,Cookie._OFFICIAL_ACCOUNTS_ID);
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
}
return new ResponseDto<>(appletBannerBiz.listBanner4Wechat(currentPage, numPerPage, true, officialAccountsId));
return new ResponseDto<>(appletBannerBiz.listBanner4Wechat(currentPage, numPerPage, true, officialAccountsId, wechatUserId));
}
@ApiOperation("获取书单下书籍列表")
......@@ -1174,6 +1175,15 @@ public class AppletHomeFacade {
answerSubscribeDTO.setWechatUserId(wechatUserId);
return new ResponseDto<>(answerSubscribeBiz.getSubscribeState(answerSubscribeDTO));
}
@ApiOperation("小程序首页banner点击埋点")
@RequestMapping(value = "/bannerClickRecord", method = RequestMethod.GET)
public ResponseDto<Void> bannerClickRecord(@CookieValue("userInfo") String userInfo, @RequestParam("bannerId") Long bannerId) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
ParamChecker.checkNumberIsNull(bannerId, "参数缺失!");
appletBannerBiz.bannerClickRecord(wechatUserId, bannerId);
return new ResponseDto<>();
}
}
......
package com.pcloud.book.applet.mapper;
import com.pcloud.book.applet.dto.AppletBannerStats;
import com.pcloud.book.applet.entity.AppletBannerRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper
@Component
public interface AppletBannerRecordMapper {
int deleteByPrimaryKey(Long id);
int insert(AppletBannerRecord record);
int insertSelective(AppletBannerRecord record);
AppletBannerRecord selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AppletBannerRecord record);
int updateByPrimaryKey(AppletBannerRecord record);
List<AppletBannerStats> getBannerPVUV(@Param("bannerIds") List<Long> bannerIds);
}
\ No newline at end of file
......@@ -195,4 +195,6 @@ public interface RightsSettingBiz {
* @param nowItems
*/
void fillProductAndApp(List<RightsNowItem> nowItems);
AppletNewsDTO getAppletNewsDTO4UserReadBook(AppletUserBookcase userReadBook);
}
package com.pcloud.book.rightsSetting.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletBooklistBiz;
......@@ -111,9 +113,8 @@ import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
......@@ -137,11 +138,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz {
......@@ -1585,6 +1581,48 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
nowItems.removeAll(list_remove);
}
@Override
public AppletNewsDTO getAppletNewsDTO4UserReadBook(AppletUserBookcase userReadBook) {
AppletNewsDTO appletNewsDTO = new AppletNewsDTO();
BaseTempletClassify baseTempletClassify = appletUserBookcaseDao.getBookClassifyInfo(userReadBook.getBookId(), userReadBook.getChannelId(), userReadBook.getAdviserId());
if (Objects.nonNull(baseTempletClassify) && Objects.nonNull(baseTempletClassify.getFirstClassify())) {
rightsSettingBiz.setClassifyAndLabel(baseTempletClassify);
Integer deepRead = null;
Integer easyRead = null;
Integer efficientRead = null;
if (ReadTypeEnum.QS_READ.value.equals(userReadBook.getReadType())) {
easyRead = 1;
} else if (ReadTypeEnum.GX_READ.value.equals(userReadBook.getReadType())) {
efficientRead = 1;
} else if (ReadTypeEnum.SD_READ.value.equals(userReadBook.getReadType())) {
deepRead = 1;
}
Map<String, Object> map = new HashMap<>();
map.put("firstClassify", baseTempletClassify.getFirstClassify());
map.put("secondClassify", baseTempletClassify.getSecondClassify());
map.put("gradeLabelId", baseTempletClassify.getGradeLabelId());
map.put("subjectLabelId", baseTempletClassify.getSubjectLabelId());
map.put("deepRead", deepRead);
map.put("easyRead", easyRead);
map.put("efficientRead", efficientRead);
PageBeanNew<AppletNewsDTO> page = appletNewsDao.listPageNew(new PageParam(0, 1), map, "getClassifyNewsByTempletLabel");
if (Objects.nonNull(page) && CollUtil.isNotEmpty(page.getRecordList())) {
appletNewsDTO = page.getRecordList().get(0);
} else {
map.put("firstClassify", baseTempletClassify.getFirstClassify());
map.put("secondClassify", baseTempletClassify.getSecondClassify());
map.put("gradeLabelId", baseTempletClassify.getGradeLabelId());
map.put("subjectLabelId", baseTempletClassify.getSubjectLabelId());
map.put("rightsType", null);
page = appletNewsDao.listPageNew(new PageParam(0, 1), map, "getPageByNewsByTempletLabel");
if (Objects.nonNull(page) && CollUtil.isNotEmpty(page.getRecordList())) {
appletNewsDTO = page.getRecordList().get(0);
}
}
}
return appletNewsDTO;
}
private void fillGiftCouponPack(RightsSetting rightsSetting, Integer readType) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemTypeNew.GIFT_COUPON_PACKAGE, readType);
if (null != rightsSettingTitle){
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.applet.dao.impl.AppletBannerDaoImpl" >
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletBanner" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="banner_pic" property="bannerPic" jdbcType="VARCHAR" />
<result column="jump_type" property="jumpType" jdbcType="INTEGER" />
<result column="jump_url" property="jumpUrl" jdbcType="VARCHAR" />
<result column="seq" property="seq" jdbcType="INTEGER" />
<result column="show_state" property="showState" jdbcType="BOOLEAN" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="agent_id" property="agentId" jdbcType="BIGINT" />
</resultMap>
<mapper namespace="com.pcloud.book.applet.dao.impl.AppletBannerDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletBanner">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="banner_pic" jdbcType="VARCHAR" property="bannerPic"/>
<result column="jump_type" jdbcType="INTEGER" property="jumpType"/>
<result column="jump_url" jdbcType="VARCHAR" property="jumpUrl"/>
<result column="seq" jdbcType="INTEGER" property="seq"/>
<result column="show_state" jdbcType="BOOLEAN" property="showState"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="agent_id" jdbcType="BIGINT" property="agentId"/>
<result column="serve_id" jdbcType="BIGINT" property="serveId"/>
<result column="serve_type" jdbcType="TINYINT" property="serveType"/>
<result column="fill_type" jdbcType="TINYINT" property="fillType"/>
</resultMap>
<sql id="Base_Column_List" >
id, banner_pic, jump_type, jump_url, seq, show_state, create_time, update_time, agent_id
<sql id="Base_Column_List">
id, banner_pic, jump_type, jump_url, seq, show_state, create_time, update_time, agent_id,
serve_id, serve_type, fill_type
</sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletBanner" useGeneratedKeys="true" keyProperty="id">
insert into applet_banner(
banner_pic, jump_type, jump_url, seq, show_state, create_time, update_time, agent_id
)
values (
#{bannerPic}, #{jumpType}, #{jumpUrl}, #{seq}, #{showState}, NOW(), NOW(), #{agentId}
)
</insert>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletBanner"
useGeneratedKeys="true">
insert into applet_banner
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bannerPic != null">
banner_pic,
</if>
<if test="jumpType != null">
jump_type,
</if>
<if test="jumpUrl != null">
jump_url,
</if>
<if test="seq != null">
seq,
</if>
<if test="showState != null">
show_state,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="agentId != null">
agent_id,
</if>
<if test="serveId != null">
serve_id,
</if>
<if test="serveType != null">
serve_type,
</if>
<if test="fillType != null">
fill_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bannerPic != null">
#{bannerPic,jdbcType=VARCHAR},
</if>
<if test="jumpType != null">
#{jumpType,jdbcType=INTEGER},
</if>
<if test="jumpUrl != null">
#{jumpUrl,jdbcType=VARCHAR},
</if>
<if test="seq != null">
#{seq,jdbcType=INTEGER},
</if>
<if test="showState != null">
#{showState,jdbcType=BOOLEAN},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="agentId != null">
#{agentId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
#{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
#{serveType,jdbcType=TINYINT},
</if>
<if test="fillType != null">
#{fillType,jdbcType=BOOLEAN},
</if>
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.applet.entity.AppletBanner">
update applet_banner
<set>
<if test="bannerPic != null">
banner_pic = #{bannerPic},
</if>
<if test="jumpType != null">
jump_type = #{jumpType,jdbcType=INTEGER},
</if>
<if test="jumpUrl != null">
jump_url = #{jumpUrl},
</if>
<if test="seq != null">
seq = #{seq,jdbcType=INTEGER},
</if>
<if test="showState != null">
show_state = #{showState,jdbcType=BOOLEAN},
</if>
update_time=NOW()
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="update" parameterType="com.pcloud.book.applet.entity.AppletBanner">
update applet_banner
<set>
<if test="bannerPic != null">
banner_pic = #{bannerPic,jdbcType=VARCHAR},
</if>
<if test="jumpType != null">
jump_type = #{jumpType,jdbcType=INTEGER},
</if>
<if test="jumpUrl != null">
jump_url = #{jumpUrl,jdbcType=VARCHAR},
</if>
<if test="seq != null">
seq = #{seq,jdbcType=INTEGER},
</if>
<if test="showState != null">
show_state = #{showState,jdbcType=BOOLEAN},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
update_time = NOW(),
<if test="agentId != null">
agent_id = #{agentId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
serve_id = #{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
serve_type = #{serveType,jdbcType=TINYINT},
</if>
<if test="fillType != null">
fill_type = #{fillType,jdbcType=BOOLEAN},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getById" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from applet_banner
where id=#{id}
</select>
<select id="getById" parameterType="long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from applet_banner
where id=#{id}
</select>
<delete id="deleteById" parameterType="long">
<delete id="deleteById" parameterType="long">
delete from applet_banner
where id=#{id}
</delete>
<select id="listBanner" resultType="com.pcloud.book.applet.dto.AppletBannerDTO" parameterType="map">
SELECT
id id,
banner_pic bannerPic,
seq seq,
show_state showState,
jump_type jumpType,
jump_url jumpUrl
FROM applet_banner
where 1=1
<if test="showState != null">
and show_state = #{showState}
</if>
<choose>
<when test="agentId != null">
and agent_id = #{agentId}
</when>
<otherwise>
and agent_id = 0
</otherwise>
</choose>
ORDER BY seq ASC
</select>
<select id="listBanner" resultType="com.pcloud.book.applet.dto.AppletBannerDTO" parameterType="map">
SELECT
id id,
banner_pic bannerPic,
seq seq,
show_state showState,
jump_type jumpType,
jump_url jumpUrl,
fill_type fillType,
serve_id serveId,
serve_type serveType
FROM applet_banner
where 1=1
<if test="showState != null">
and show_state = #{showState}
</if>
<choose>
<when test="agentId != null">
and agent_id = #{agentId}
</when>
<otherwise>
and agent_id = 0
</otherwise>
</choose>
ORDER BY seq ASC
</select>
<select id="getMaxSeq" resultType="Integer" parameterType="map">
<select id="getMaxSeq" resultType="Integer" parameterType="map">
SELECT IFNULL(MAX(seq),0) FROM applet_banner
WHERE agent_id = #{agentId}
</select>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.applet.mapper.AppletBannerRecordMapper">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletBannerRecord">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="banner_id" jdbcType="BIGINT" property="bannerId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="wechat_user_id" jdbcType="BIGINT" property="wechatUserId"/>
<result column="serve_id" jdbcType="BIGINT" property="serveId"/>
<result column="serve_type" jdbcType="TINYINT" property="serveType"/>
<result column="jump_type" jdbcType="BOOLEAN" property="jumpType"/>
</resultMap>
<sql id="Base_Column_List">
id, banner_id, create_time, update_time, wechat_user_id, serve_id, serve_type, jump_type
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from applet_banner_record
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from applet_banner_record
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletBannerRecord"
useGeneratedKeys="true">
insert into applet_banner_record (banner_id, create_time, update_time,
wechat_user_id, serve_id, serve_type,
jump_type)
values (#{bannerId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{wechatUserId,jdbcType=BIGINT}, #{serveId,jdbcType=BIGINT}, #{serveType,jdbcType=TINYINT},
#{jumpType,jdbcType=BOOLEAN})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id"
parameterType="com.pcloud.book.applet.entity.AppletBannerRecord" useGeneratedKeys="true">
insert into applet_banner_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bannerId != null">
banner_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="wechatUserId != null">
wechat_user_id,
</if>
<if test="serveId != null">
serve_id,
</if>
<if test="serveType != null">
serve_type,
</if>
<if test="jumpType != null">
jump_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bannerId != null">
#{bannerId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="wechatUserId != null">
#{wechatUserId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
#{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
#{serveType,jdbcType=TINYINT},
</if>
<if test="jumpType != null">
#{jumpType,jdbcType=BOOLEAN},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.applet.entity.AppletBannerRecord">
update applet_banner_record
<set>
<if test="bannerId != null">
banner_id = #{bannerId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="wechatUserId != null">
wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
</if>
<if test="serveId != null">
serve_id = #{serveId,jdbcType=BIGINT},
</if>
<if test="serveType != null">
serve_type = #{serveType,jdbcType=TINYINT},
</if>
<if test="jumpType != null">
jump_type = #{jumpType,jdbcType=BOOLEAN},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.applet.entity.AppletBannerRecord">
update applet_banner_record
set banner_id = #{bannerId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
serve_id = #{serveId,jdbcType=BIGINT},
serve_type = #{serveType,jdbcType=TINYINT},
jump_type = #{jumpType,jdbcType=BOOLEAN}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getBannerPVUV" resultType="com.pcloud.book.applet.dto.AppletBannerStats">
SELECT
t.banner_id bannerId,
count( 0 ) uv,
SUM( t.p ) pv
FROM
( SELECT banner_id, count( 0 ) p FROM applet_banner_record WHERE
banner_id IN
<foreach collection="bannerIds" close=")" item="item" open="(" separator=",">
${item}
</foreach>
GROUP BY banner_id, wechat_user_id ) t
GROUP BY
t.banner_id
</select>
</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