Commit db75852f by 郑永强

feat: [1003101] 资讯原文编辑不展示来源支持外链添加,原文资讯支持第三方小程序联接

parent 2d5fcb6b
package com.pcloud.book.applet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* (AppletNewsServe)实体类
*
* @author makejava
* @since 2020-06-30 16:56:08
*/
@Data
public class AppletNewsServeDTO extends BaseDto {
private Long id;
@ApiModelProperty("资讯id")
private Long appletNewsId;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("导图")
private String picUrl;
@ApiModelProperty("跳转地址")
private String linkUrl;
@ApiModelProperty("服务id")
private Long serveId;
@ApiModelProperty("服务类型,1:applet;2:第三方资讯;")
private Integer serveType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("小程序id")
private String appletsId;
@ApiModelProperty("小程序宣传语")
private String slogan;
@ApiModelProperty("小程序宣传图片")
private String sloganImgUrl;
@ApiModelProperty("小程序访问地址")
private String appletsUrl;
@ApiModelProperty("小程序备注")
private String remark;
}
......@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import java.util.Date;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -80,4 +81,7 @@ public class AppletNewsVO extends BaseDto {
private Integer jumpType;
@ApiModelProperty("跳转地址")
private String jumpUrl;
@ApiModelProperty("选取的服务")
List<AppletNewsServeDTO> appletNewsServeList;
}
package com.pcloud.book.applet.enums;
public enum AppletNewsServeTypeEnum {
/**
* 第三方小程序
*/
APPLET(1),
/**
* 第三方资源
*/
LINK(2);
public Integer code;
AppletNewsServeTypeEnum(Integer code) {
this.code = code;
}
}
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
/**
* (AppletNewsServe)表服务接口
*
* @author makejava
* @since 2020-06-30 16:56:08
*/
public interface AppletNewsServeBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletNewsServe getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param appletNewsServe 实例对象
* @return 主键
*/
Long insert(AppletNewsServe appletNewsServe);
/**
* 修改数据
*
* @param appletNewsServe 实例对象
*/
void update(AppletNewsServe appletNewsServe);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
}
\ No newline at end of file
package com.pcloud.book.applet.biz.impl;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.contants.AppletConstants;
......@@ -7,10 +8,12 @@ import com.pcloud.book.applet.dao.AppletLinkClickDao;
import com.pcloud.book.applet.dao.AppletNewsClassifyDao;
import com.pcloud.book.applet.dao.AppletNewsCommentDao;
import com.pcloud.book.applet.dao.AppletNewsDao;
import com.pcloud.book.applet.dao.AppletNewsServeDao;
import com.pcloud.book.applet.dto.AppletNewsClassifyDTO;
import com.pcloud.book.applet.dto.AppletNewsCommentDTO;
import com.pcloud.book.applet.dto.AppletNewsCustomTagDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import com.pcloud.book.applet.dto.AppletNewsVO;
import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletLinkClick;
......@@ -19,6 +22,8 @@ import com.pcloud.book.applet.entity.AppletNewsClassify;
import com.pcloud.book.applet.entity.AppletNewsClassifyUser;
import com.pcloud.book.applet.entity.AppletNewsComment;
import com.pcloud.book.applet.entity.AppletNewsCustomTag;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.book.applet.enums.AppletNewsServeTypeEnum;
import com.pcloud.book.applet.enums.DataRecordTypeEnum;
import com.pcloud.book.applet.enums.DataTypeEnum;
import com.pcloud.book.applet.vo.AppletNewsClassifyVO;
......@@ -29,6 +34,8 @@ import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.push.dao.PersonalAppletsDao;
import com.pcloud.book.push.entity.PersonalApplets;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.common.exceptions.BizException;
......@@ -44,7 +51,9 @@ import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
......@@ -76,6 +85,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
private AssistTempletConsr assistTempletConsr;
@Autowired
private AppletLinkClickDao appletLinkClickDao;
@Autowired
private AppletNewsServeDao appletNewsServeDao;
@Autowired
private PersonalAppletsDao personalAppletsDao;
@Override
public Long addAppletNewsClassify(AppletNewsClassify appletNewsClassify) {
......@@ -115,6 +128,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long addAppletNews(AppletNews appletNews) {
if (urlNumberExist(appletNews)){
throw new BookBizException(BookBizException.ERROR,"链接编号重复");
......@@ -122,11 +136,53 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
appletNews.setShowState(false);
rightsSettingBiz.setClassifyAndLabel(appletNews);
appletNewsDao.insert(appletNews);
// 保存选取的服务
this.saveAppletNewsServe(appletNews.getAppletNewsServeList(), appletNews.getId());
this.updateSource(null,appletNews.getSource());
return appletNews.getId();
}
/**
* 保存选取的服务
* @param appletNewsServeList
* @param appletNewsId
*/
private void saveAppletNewsServe(List<AppletNewsServe> appletNewsServeList, Long appletNewsId) {
// 删除旧数据
appletNewsServeDao.deleteByAppletNewsId(appletNewsId);
if(ListUtils.isEmpty(appletNewsServeList)){
return;
}
for (AppletNewsServe appletNewsServe : appletNewsServeList) {
appletNewsServe.setAppletNewsId(appletNewsId);
}
this.checkAppletNewsServe(appletNewsServeList);
appletNewsServeDao.insert(appletNewsServeList);
}
private void checkAppletNewsServe(List<AppletNewsServe> appletNewsServeList) {
for (AppletNewsServe appletNewsServe : appletNewsServeList) {
if(!AppletNewsServeTypeEnum.LINK.code.equals(appletNewsServe.getServeType())){
continue;
}
if(StringUtil.isEmpty(appletNewsServe.getTitle())){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "标题不能为空");
}
if(StringUtil.isEmpty(appletNewsServe.getPicUrl())){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "导图不能为空");
}
if(StringUtil.isEmpty(appletNewsServe.getLinkUrl())){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "跳转链接不能为空");
}
}
long appletCount = appletNewsServeList.stream().filter(x -> AppletNewsServeTypeEnum.APPLET.code.equals(x.getServeType())).count();
if(appletCount > 3){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "第三方小程序数量不能大于3个");
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateAppletNews(AppletNews appletNews) {
if (null == appletNews.getId()){
throw new BookBizException(BookBizException.ERROR,"id为空");
......@@ -137,6 +193,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
AppletNews beforeNews = appletNewsDao.getById(appletNews.getId());
rightsSettingBiz.setClassifyAndLabel(appletNews);
appletNewsDao.update(appletNews);
this.saveAppletNewsServe(appletNews.getAppletNewsServeList(), appletNews.getId());
this.updateSource(beforeNews.getSource(),appletNews.getSource());
JedisClusterUtils.del(AppletConstants.HOME_NEWS_LIST);
}
......@@ -358,10 +415,73 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if (null!=appletNews){
BeanUtils.copyProperties(appletNews,appletNewsDTO);
}
this.fillAppletNewsServe(appletNewsDTO);
this.fillBrowseCount(Lists.newArrayList(appletNewsDTO));
fillLabel(Arrays.asList(appletNewsDTO));
return appletNewsDTO;
}
/**
* 点击量浏览量
* * @param null
*/
private void fillBrowseCount(List<AppletNewsDTO> recordList) {
if (ListUtils.isEmpty(recordList)) {
return;
}
List<Long> newsIds = recordList.stream().filter(s -> s != null).map(AppletNewsDTO::getId).distinct().collect(Collectors.toList());
Map<Long, PvuvDTO> browseMap = appletLinkClickDao.mapPVUV(DataTypeEnum.news.code, DataRecordTypeEnum.browse.code, newsIds);
for (AppletNewsDTO appletNewsDTO : recordList) {
Long newsId = appletNewsDTO.getId();
if (!MapUtils.isEmpty(browseMap) && browseMap.containsKey(newsId)) {
PvuvDTO pvuvDTO = browseMap.get(newsId);
appletNewsDTO.setBrowseCount(pvuvDTO.getPv());
} else {
appletNewsDTO.setBrowseCount(0);
}
}
}
/**
* 填充第三方服务
* @param appletNewsDTO
*/
private void fillAppletNewsServe(AppletNewsDTO appletNewsDTO) {
List<AppletNewsServeDTO> appletNewsServeList = appletNewsServeDao.getByAppletNewsId(appletNewsDTO.getId());
if(ListUtils.isEmpty(appletNewsServeList)){
appletNewsDTO.setAppletNewsServeList(Lists.newArrayList());
}
this.fillPersonalApplet(appletNewsServeList);
appletNewsDTO.setAppletNewsServeList(appletNewsServeList);
}
/**
* 填充小程序相关数据
* @param appletNewsServeList
*/
private void fillPersonalApplet(List<AppletNewsServeDTO> appletNewsServeList) {
List<Long> personalAppletIds = appletNewsServeList.stream().filter(x -> AppletNewsServeTypeEnum.APPLET.code.equals(x.getServeType())).map(x -> x.getServeId()).collect(Collectors.toList());
if(ListUtils.isEmpty(personalAppletIds)){
return;
}
Map<Long, PersonalApplets> personalAppletsMap = personalAppletsDao.mapByIds(personalAppletIds);
if(personalAppletsMap == null || personalAppletsMap.isEmpty()){
return;
}
PersonalApplets personalApplets;
for (AppletNewsServeDTO appletNewsServeDTO : appletNewsServeList) {
personalApplets = personalAppletsMap.get(appletNewsServeDTO.getServeId());
if(personalApplets == null){
continue;
}
appletNewsServeDTO.setAppletsId(personalApplets.getAppletsId());
appletNewsServeDTO.setSlogan(personalApplets.getSlogan());
appletNewsServeDTO.setSloganImgUrl(personalApplets.getSloganImgUrl());
appletNewsServeDTO.setAppletsUrl(personalApplets.getAppletsUrl());
appletNewsServeDTO.setRemark(personalApplets.getRemark());
}
}
@Override
public void updateNewsShowState(AppletNews appletNews) {
appletNewsDao.updateNewsShowState(appletNews);
......@@ -410,9 +530,24 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if (null != appletNews) {
BeanUtils.copyProperties(appletNews, appletNewsVO);
}
// 填充第三方服务
this.fillAppletNewsServe(appletNewsVO);
return appletNewsVO;
}
/**
* 填充第三方服务
* @param appletNewsVO
*/
private void fillAppletNewsServe(AppletNewsVO appletNewsVO) {
List<AppletNewsServeDTO> appletNewsServeList = appletNewsServeDao.getByAppletNewsId(appletNewsVO.getId());
if(ListUtils.isEmpty(appletNewsServeList)){
appletNewsVO.setAppletNewsServeList(Lists.newArrayList());
}
this.fillPersonalApplet(appletNewsServeList);
appletNewsVO.setAppletNewsServeList(appletNewsServeList);
}
@Override
public List<String> getNewsSourceList() {
return appletNewsDao.getNewsSourceList();
......
package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.book.applet.dao.AppletNewsServeDao;
import com.pcloud.book.applet.biz.AppletNewsServeBiz;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* (AppletNewsServe)表服务实现类
*
* @author makejava
* @since 2020-06-30 16:56:08
*/
@Service("appletNewsServeBiz")
public class AppletNewsServeBizImpl implements AppletNewsServeBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletNewsServeBizImpl.class);
@Autowired
private AppletNewsServeDao appletNewsServeDao;
@Override
@ParamLog("通过ID查询单条数据")
public AppletNewsServe getById(Long id) {
return appletNewsServeDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = appletNewsServeDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)){
return pageBeanNew;
}
// 加载其它数据
return pageBeanNew;
}
@Override
@ParamLog("新增")
public Long insert(AppletNewsServe appletNewsServe) {
appletNewsServeDao.insert(appletNewsServe);
return appletNewsServe.getId();
}
@Override
@ParamLog("修改")
public void update(AppletNewsServe appletNewsServe) {
if(appletNewsServe == null || !NumberUtil.isNumber(appletNewsServe.getId())){
throw BizException.PARAM_IS_NULL;
}
appletNewsServeDao.update(appletNewsServe);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
appletNewsServeDao.deleteById(id);
}
}
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* (AppletNewsServe)表数据库访问层
*
* @author makejava
* @since 2020-06-30 16:56:08
*/
public interface AppletNewsServeDao extends BaseDao<AppletNewsServe> {
int deleteByAppletNewsId(Long appletNewsId);
List<AppletNewsServeDTO> getByAppletNewsId(Long appletNewsId);
}
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.book.applet.dao.AppletNewsServeDao;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* (AppletNewsServe)表数据库访问层
*
* @author makejava
* @since 2020-06-30 16:56:08
*/
@Repository("appletNewsServeDaoImpl")
public class AppletNewsServeDaoImpl extends BaseDaoImpl<AppletNewsServe> implements AppletNewsServeDao {
@Override
public int deleteByAppletNewsId(Long appletNewsId) {
return this.sqlSessionTemplate.delete(getStatement("deleteByAppletNewsId"), appletNewsId);
}
@Override
public List<AppletNewsServeDTO> getByAppletNewsId(Long appletNewsId) {
return this.sqlSessionTemplate.selectList(getStatement("getByAppletNewsId"), appletNewsId);
}
}
package com.pcloud.book.applet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
@ApiModel("小程序资讯")
......@@ -89,4 +91,13 @@ public class AppletNewsDTO extends BaseDto {
private String customTag;
@ApiModelProperty("自定义标识id")
private Long customTagId;
@ApiModelProperty("展示来源")
private Integer showSource;
@ApiModelProperty("展示第三方资源")
private Integer showLink;
@ApiModelProperty("浏览量pv")
private Integer browseCount;
@ApiModelProperty("选取的服务")
List<AppletNewsServeDTO> appletNewsServeList;
}
......@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("小程序资讯")
public class AppletNews extends BaseTempletClassify {
......@@ -54,4 +56,11 @@ public class AppletNews extends BaseTempletClassify {
private String urlNumber;
@ApiModelProperty("自定义标识id")
private Long customTagId;
@ApiModelProperty("展示来源")
private Integer showSource;
@ApiModelProperty("展示第三方资源")
private Integer showLink;
@ApiModelProperty("选取的服务")
List<AppletNewsServe> appletNewsServeList;
}
package com.pcloud.book.applet.entity;
import java.util.Date;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* (AppletNewsServe)实体类
*
* @author makejava
* @since 2020-06-30 16:56:08
*/
@Data
public class AppletNewsServe extends BaseEntity {
private static final long serialVersionUID = 367325712059908419L;
private Long id;
@ApiModelProperty("资讯id")
private Long appletNewsId;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("导图")
private String picUrl;
@ApiModelProperty("跳转地址")
private String linkUrl;
@ApiModelProperty("服务id")
private Long serveId;
@ApiModelProperty("服务类型,1:applet;2:第三方资讯;")
private Integer serveType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}
package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.book.applet.biz.AppletNewsServeBiz;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
/**
* (AppletNewsServe)表控制层
*
* @author makejava
* @since 2020-06-30 16:56:08
*/
@RestController("appletNewsServeFacade")
@RequestMapping("appletNewsServe")
public class AppletNewsServeFacade {
@Autowired
private AppletNewsServeBiz appletNewsServeBiz;
@ApiOperation("通过主键查询单条数据")
@GetMapping("getById")
public ResponseDto<?> getById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletNewsServeBiz.getById(id));
}
@ApiOperation("分页查询")
@GetMapping("getList")
public ResponseDto<?> getList(@RequestHeader("token") String token,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletNewsServeBiz.getList(currentPage, numPerPage));
}
@ApiOperation("新增")
@PostMapping("insert")
public ResponseDto<?> insert(@RequestHeader("token") String token, @RequestBody AppletNewsServe appletNewsServe)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletNewsServeBiz.insert(appletNewsServe));
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update(@RequestHeader("token") String token,@RequestBody AppletNewsServe appletNewsServe) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
appletNewsServeBiz.update(appletNewsServe);
return new ResponseDto<>();
}
@ApiOperation("删除")
@GetMapping("deleteById")
public ResponseDto<?> deleteById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
if (null == id) {
throw BookBizException.PARAM_DELETION;
}
appletNewsServeBiz.deleteById(id);
return new ResponseDto<>();
}
}
\ No newline at end of file
......@@ -73,7 +73,7 @@ public interface SelfPushBiz {
void updatePersonalApplets(PersonalApplets applets);
PageBeanNew<PersonalApplets> getAllApplets(String appletsId,Integer currentPage,Integer numPerPage);
PageBeanNew<PersonalApplets> getAllApplets(String appletsId,String content,Integer currentPage,Integer numPerPage);
PageBeanNew<PersonalAppletsRecordDTO> getSendAppletsRecords(Integer currentPage, Integer numPerPage, String startTime, String endTime, Integer status, Long partyId);
......
......@@ -993,10 +993,11 @@ public class SelfPushBizImpl implements SelfPushBiz {
}
@Override
public PageBeanNew<PersonalApplets> getAllApplets(String appletsId,Integer currentPage,Integer numPerPage) {
public PageBeanNew<PersonalApplets> getAllApplets(String appletsId,String content,Integer currentPage,Integer numPerPage) {
Map<String, Object> map = new HashMap<>();
map.put("appletsId", appletsId);
map.put("content", content);
return personalAppletsDao.listPageNew(new PageParam(currentPage, numPerPage),map,"getAllApplets");
}
......
package com.pcloud.book.push.dao;
import com.pcloud.book.push.entity.PersonalApplets;
import com.pcloud.book.push.entity.SelfPush;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* @描述:小程序
......@@ -15,5 +15,7 @@ import java.util.List;
public interface PersonalAppletsDao extends BaseDao<PersonalApplets>{
List<PersonalApplets> getAllApplets(String appletsId);
List<PersonalApplets> getAllApplets(String appletsId, String content);
Map<Long,PersonalApplets> mapByIds(List<Long> personalAppletIds);
}
......@@ -23,9 +23,15 @@ public class PersonalAppletsDaoImpl extends BaseDaoImpl<PersonalApplets> impleme
@Override
public List<PersonalApplets> getAllApplets(String appletsId) {
public List<PersonalApplets> getAllApplets(String appletsId, String content) {
Map<String,Object> map=new HashMap<>();
map.put("appletsId",appletsId);
map.put("content",content);
return getSessionTemplate().selectList(getStatement("getAllApplets"),map);
}
@Override
public Map<Long, PersonalApplets> mapByIds(List<Long> list) {
return this.sqlSessionTemplate.selectMap(getStatement("mapByIds"), list, "id");
}
}
......@@ -24,4 +24,7 @@ public class PersonalApplets extends BaseEntity {
@ApiModelProperty("小程序访问地址")
private String appletsUrl;
@ApiModelProperty("备注")
private String remark;
}
......@@ -169,13 +169,14 @@ public class SelfPushFacade {
@GetMapping("getAllApplets")
public ResponseDto<?> getAllApplets(@RequestHeader("token") String token,
@RequestParam(value = "appletsId",required = false) @ApiParam("小程序id") String appletsId,
@RequestParam(value = "content",required = false) @ApiParam("小程序id或备注") String content,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
if (null == currentPage || null == numPerPage) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少分页参数");
}
PageBeanNew<PersonalApplets> pageBeanNew=selfPushBiz.getAllApplets(appletsId,currentPage,numPerPage);
PageBeanNew<PersonalApplets> pageBeanNew=selfPushBiz.getAllApplets(appletsId,content,currentPage,numPerPage);
return new ResponseDto<>(pageBeanNew);
}
......
......@@ -27,25 +27,27 @@
<result column="jump_url" property="jumpUrl" jdbcType="VARCHAR" />
<result column="url_number" property="urlNumber" jdbcType="VARCHAR" />
<result column="custom_tag_id" property="customTagId" jdbcType="BIGINT" />
<result column="show_source" property="showSource" jdbcType="INTEGER" />
<result column="show_link" property="showLink" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest,
pic1, pic2, pic3, content, show_state, create_time, update_time, first_classify, second_classify, grade_label_id, subject_label_id, rights_classify_id,
jump_type, jump_url, url_number, custom_tag_id
jump_type, jump_url, url_number, custom_tag_id, show_source, show_link
</sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletNews" useGeneratedKeys="true" keyProperty="id">
insert into applet_news(
news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest,
pic1, pic2, pic3, content, show_state, create_time, update_time , first_classify, second_classify, grade_label_id, subject_label_id, rights_classify_id,
jump_type, jump_url,url_number, custom_tag_id
jump_type, jump_url,url_number, custom_tag_id, show_source, show_link
)
values (
#{newsName}, #{source}, #{newsClassifyId}, #{proLabelId}, #{depLabelId}, #{purLabelId}, #{type}, #{digest},
#{pic1}, #{pic2}, #{pic3}, #{content}, #{showState}, NOW(), NOW(), #{firstClassify,jdbcType=BIGINT}, #{secondClassify,jdbcType=BIGINT},
#{gradeLabelId,jdbcType=BIGINT}, #{subjectLabelId,jdbcType=BIGINT}, #{rightsClassifyId,jdbcType=BIGINT},
#{jumpType}, #{jumpUrl}, #{urlNumber}, #{customTagId}
#{jumpType}, #{jumpUrl}, #{urlNumber}, #{customTagId}, #{showSource}, #{showLink}
)
</insert>
......@@ -83,6 +85,12 @@
<if test="jumpType != null">
jump_type = #{jumpType},
</if>
<if test="showSource != null">
show_source = #{showSource},
</if>
<if test="showLink != null">
show_link = #{showLink},
</if>
jump_url = #{jumpUrl},
url_number = #{urlNumber},
update_time=NOW()
......@@ -135,7 +143,9 @@
n.jump_url jumpUrl,
n.url_number urlNumber,
n.custom_tag_id customTagId,
t.custom_tag customTag
t.custom_tag customTag,
n.show_source showSource,
n.show_link showLink
FROM applet_news n
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
LEFT JOIN rights_setting_classify d ON n.rights_classify_id = d.id
......@@ -205,7 +215,9 @@
n.rights_classify_id rightsClassifyId,
n.jump_type jumpType,
n.jump_url jumpUrl,
n.url_number urlNumber
n.url_number urlNumber,
n.show_source showSource,
n.show_link showLink
FROM applet_news n
WHERE 1=1
and n.show_state = 1
......@@ -363,7 +375,9 @@
d.classify rightsClassifyContent,
n.jump_type jumpType,
n.jump_url jumpUrl,
n.url_number urlNumber
n.url_number urlNumber,
n.show_source showSource,
n.show_link showLink
FROM applet_news n
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
LEFT JOIN rights_setting_classify d ON n.rights_classify_id = d.id
......@@ -415,7 +429,9 @@
n.rights_classify_id rightsClassifyId,
n.jump_type jumpType,
n.jump_url jumpUrl,
n.url_number urlNumber
n.url_number urlNumber,
n.show_source showSource,
n.show_link showLink
FROM applet_news n
WHERE n.show_state = 1
AND n.id IN
......@@ -450,7 +466,9 @@
n.subject_label_id subjectLabelId,
n.rights_classify_id rightsClassifyId,
n.jump_type jumpType,
n.jump_url jumpUrl
n.jump_url jumpUrl,
n.show_source showSource,
n.show_link showLink
FROM applet_news n
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
WHERE n.show_state = 1
......
<?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.AppletNewsServeDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletNewsServe">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="applet_news_id" property="appletNewsId" jdbcType="BIGINT"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="serve_id" property="serveId" jdbcType="BIGINT"/>
<result column="serve_type" property="serveType" jdbcType="INTEGER"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="BaseDTOResultMap" type="com.pcloud.book.applet.dto.AppletNewsServeDTO">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="applet_news_id" property="appletNewsId" jdbcType="BIGINT"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="serve_id" property="serveId" jdbcType="BIGINT"/>
<result column="serve_type" property="serveType" jdbcType="INTEGER"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, applet_news_id, title, pic_url, link_url, serve_id, serve_type, update_time, create_time
</sql>
<sql id="BaseDto_Column_List">
id, applet_news_id, title, pic_url, link_url, serve_id, serve_type, update_time, create_time
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_news_serve
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_news_serve
</select>
<select id="getByAppletNewsId" resultMap="BaseDTOResultMap">
SELECT
<include refid="BaseDto_Column_List"/>
FROM applet_news_serve
WHERE applet_news_id = #{appletNewsId}
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_news_serve(
applet_news_id,
title,
pic_url,
link_url,
serve_id,
serve_type,
update_time,
create_time
) VALUES (
#{appletNewsId, jdbcType=BIGINT},
#{title, jdbcType=VARCHAR},
#{picUrl, jdbcType=VARCHAR},
#{linkUrl, jdbcType=VARCHAR},
#{serveId, jdbcType=INTEGER},
#{serveType, jdbcType=INTEGER},
NOW(),
NOW()
)
</insert>
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_news_serve (
applet_news_id,
title,
pic_url,
link_url,
serve_id,
serve_type,
update_time,
create_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.appletNewsId, jdbcType=BIGINT},
#{item.title, jdbcType=VARCHAR},
#{item.picUrl, jdbcType=VARCHAR},
#{item.linkUrl, jdbcType=VARCHAR},
#{item.serveId, jdbcType=BIGINT},
#{item.serveType, jdbcType=INTEGER},
NOW(),
NOW()
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE applet_news_serve
<set>
<if test="appletNewsId != null">
applet_news_id = #{appletNewsId},
</if>
<if test="title != null and title != ''">
title = #{title},
</if>
<if test="picUrl != null and picUrl != ''">
pic_url = #{picUrl},
</if>
<if test="linkUrl != null and linkUrl != ''">
link_url = #{linkUrl},
</if>
<if test="serveId != null">
serve_id = #{serveId},
</if>
<if test="serveType != null">
serve_type = #{serveType},
</if>
</set>
WHERE id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM applet_news_serve where id = #{id}
</delete>
<!--通过主键删除-->
<delete id="deleteByAppletNewsId">
DELETE FROM applet_news_serve where applet_news_id = #{appletNewsId}
</delete>
</mapper>
......@@ -9,20 +9,21 @@
<result column="applets_url" property="appletsUrl" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, applets_id, slogan, slogan_img_url, applets_url, create_time, update_time
id, applets_id, slogan, slogan_img_url, applets_url, create_time, update_time, remark
</sql>
<insert id="insert" parameterType="com.pcloud.book.push.entity.PersonalApplets" useGeneratedKeys="true" keyProperty="id">
insert into personal_applets ( applets_id,
slogan, slogan_img_url, applets_url,
create_time, update_time
create_time, update_time, remark
)
values (#{appletsId,jdbcType=VARCHAR}, #{slogan,jdbcType=VARCHAR},
#{sloganImgUrl,jdbcType=VARCHAR}, #{appletsUrl,jdbcType=VARCHAR},
now(), now()
now(), now(), #{remark}
)
</insert>
......@@ -38,9 +39,21 @@
<if test="appletsId!=null">
and applets_id=#{appletsId}
</if>
<if test="content!=null">
and (applets_id LIKE concat('%',#{content},'%') OR remark LIKE concat('%',#{content},'%'))
</if>
order by create_time desc
</select>
<select id="mapByIds" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from personal_applets
where id IN
<foreach collection="list" item="item" separator="," open="(" close=")">
${item}
</foreach>
</select>
<update id="update" parameterType="com.pcloud.book.push.entity.PersonalApplets">
update personal_applets
<set>
......@@ -56,6 +69,9 @@
<if test="appletsUrl != null">
applets_url = #{appletsUrl,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
update_time = NOW(),
</set>
where id = #{id,jdbcType=BIGINT}
......
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