Commit 11293978 by 宋祥

Merge branch 'mymaster' into 'master'

C1001153 微信群早晚报-选取公众号内容,让编辑确定是否发送

See merge request rays/pcloud-book!64
parents 54a5061a 0f18c2a9
package com.pcloud.book.adnews.service;
import com.pcloud.common.exceptions.BizException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
@FeignClient(value = "pcloud-service-book", qualifier = "adNewsServiceCloud", path = "book/v1.0/adNewsService")
@Api(description = "编辑端早晚报内部接口")
public interface AdNewsService {
@ApiOperation("发送编辑端早晚报")
@PostMapping("/sendAdNews")
void sendAdNews(@RequestBody Map<String, Object> map) throws BizException;
}
package com.pcloud.book.adnews.biz;
import com.pcloud.book.adnews.entity.AdNews;
import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
public interface AdNewsBiz {
/**
* 新增早晚报设置
*/
Long createAdNewsSet(AdNewsSet adNewsSet);
/**
* 修改早晚报设置
*/
void updateAdNewsSet(AdNewsSet adNewsSet);
/**
* 发送编辑端早晚报
*/
void sendAdNews(Long adNewsSetId);
/**
* 根据创建人获取早晚报设置
*/
AdNewsSet getAdNewsSet(Long partyId);
/**
* 编辑添加选择的早晚报素材
*/
void createAdNewsChooseBatch(List<Long> adNewsIds, Long partyId);
/**
* 编辑移除选择的早晚报素材
*/
void deleteAdNewsChoose(Long adNewsId, Long partyId);
/**
* 获取素材库列表
*/
PageBeanNew<AdNews> getAdNewsList(String title, Long partyId, Integer currentPage, Integer numPerPage);
/**
* 获取编辑已选取的素材库列表
*/
PageBeanNew<AdNews> getAdNewsChooseList(Long partyId, String title, Boolean hasUsed, Integer currentPage, Integer numPerPage);
}
package com.pcloud.book.adnews.check;
import com.pcloud.book.adnews.entity.AdNewsGroup;
import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.springframework.stereotype.Component;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 17:18
**/
@Component("adNewsCheck")
public class AdNewsCheck {
public void createAdNewsSetCheck(AdNewsSet adNewsSet){
if (adNewsSet==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数错误");
}
if (ListUtils.isEmpty(adNewsSet.getAdNewsGroups())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"发送群分类不能为空!");
}
if (adNewsSet.getSendCount()==null||adNewsSet.getSendCount()<=0){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"推送条数不能为空且必须大于0!");
}
if (adNewsSet.getHasMorningOpen()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启早报不能为空!");
}
if (adNewsSet.getHasEveningOpen()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启晚报不能为空!");
}
if (adNewsSet.getHasStartContent()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启开场语不能为空!");
}
if (adNewsSet.getHasEndContent()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启结束语不能为空!");
}
if (adNewsSet.getHasMorningOpen()&&StringUtil.isEmpty(adNewsSet.getMorningTime())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"早报时间不能为空!");
}
if (adNewsSet.getHasEveningOpen()&&StringUtil.isEmpty(adNewsSet.getEveningTime())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"晚报时间不能为空!");
}
if (adNewsSet.getHasStartContent()&&StringUtil.isEmpty(adNewsSet.getStartContent())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"开场语不能为空!");
}
if (adNewsSet.getHasEndContent()&&StringUtil.isEmpty(adNewsSet.getEndContent())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"结束语不能为空!");
}
for(AdNewsGroup adNewsGroup:adNewsSet.getAdNewsGroups()){
if (adNewsGroup==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"早晚报关联不能为空!");
}
if (adNewsGroup.getClassifyId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"群分类id不能为空!");
}
if (adNewsGroup.getBookGroupId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"社群码id不能为空!");
}
}
}
}
package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNewsChoose;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface AdNewsChooseDao extends BaseDao<AdNewsChoose> {
Integer batchInsert(List<AdNewsChoose> adNewsChooses);
void deleteAdNewsChooseById(Long adNewsId, Long partyId);
Integer getCountByAdNewsIdsAndPartyId(List<Long> adNewsIds, Long partyId);
}
package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNews;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface AdNewsDao extends BaseDao<AdNews> {
List<AdNews> getNewsToSendBySetIdAndAdviser(Long adNewsSetId, Long adviserId, Integer top);
}
package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNewsGroup;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface AdNewsGroupDao extends BaseDao<AdNewsGroup> {
Integer batchInsert(List<AdNewsGroup> adNewsGroups);
void deleteByAdNewsSetId(Long adNewsSetId);
List<AdNewsGroup> getListByAdNewsSetId(Long adNewsSetId);
}
package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNewsGroupRecord;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 16:18
**/
public interface AdNewsGroupRecordDao extends BaseDao<AdNewsGroupRecord> {
Integer batchInsert(List<AdNewsGroupRecord> adNewsGroupRecords);
}
package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.common.core.dao.BaseDao;
public interface AdNewsSetDao extends BaseDao<AdNewsSet> {
AdNewsSet getByPartyId(Long createUser);
}
package com.pcloud.book.adnews.dao.impl;
import com.pcloud.book.adnews.dao.AdNewsChooseDao;
import com.pcloud.book.adnews.entity.AdNewsChoose;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 16:17
**/
@Repository("adNewsChooseDao")
public class AdNewsChooseDaoImpl extends BaseDaoImpl<AdNewsChoose> implements AdNewsChooseDao {
@Override
public Integer batchInsert(List<AdNewsChoose> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public void deleteAdNewsChooseById(Long adNewsId, Long partyId) {
Map<String,Object> map=new HashMap<>();
map.put("adNewsId",adNewsId);
map.put("partyId",partyId);
super.getSqlSession().update(getStatement("deleteAdNewsChooseById"), map);
}
@Override
public Integer getCountByAdNewsIdsAndPartyId(List<Long> adNewsIds, Long partyId) {
Map<String,Object> map=new HashMap<>();
map.put("adNewsIds",adNewsIds);
map.put("partyId",partyId);
return super.getSqlSession().selectOne(getStatement("getCountByAdNewsIdsAndPartyId"), map);
}
}
package com.pcloud.book.adnews.dao.impl;
import com.pcloud.book.adnews.dao.AdNewsDao;
import com.pcloud.book.adnews.entity.AdNews;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 16:16
**/
@Repository("adNewsDao")
public class AdNewsDaoImpl extends BaseDaoImpl<AdNews> implements AdNewsDao {
@Override
public List<AdNews> getNewsToSendBySetIdAndAdviser(Long adNewsSetId, Long adviserId, Integer top) {
Map<String, Object> map = new HashMap<>();
map.put("adNewsSetId", adNewsSetId);
map.put("adviserId", adviserId);
map.put("top", top);
return super.getSqlSession().selectList(getStatement("getNewsToSendBySetIdAndAdviser"), map);
}
}
package com.pcloud.book.adnews.dao.impl;
import com.pcloud.book.adnews.dao.AdNewsGroupDao;
import com.pcloud.book.adnews.entity.AdNewsGroup;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 16:18
**/
@Repository("adNewsGroupDao")
public class AdNewsGroupDaoImpl extends BaseDaoImpl<AdNewsGroup> implements AdNewsGroupDao {
@Override
public Integer batchInsert(List<AdNewsGroup> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public void deleteByAdNewsSetId(Long adNewsSetId) {
super.getSqlSession().update(getStatement("deleteByAdNewsSetId"), adNewsSetId);
}
@Override
public List<AdNewsGroup> getListByAdNewsSetId(Long adNewsSetId) {
return super.getSqlSession().selectList(getStatement("getListByAdNewsSetId"), adNewsSetId);
}
}
package com.pcloud.book.adnews.dao.impl;
import com.pcloud.book.adnews.dao.AdNewsGroupRecordDao;
import com.pcloud.book.adnews.entity.AdNewsGroupRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 16:18
**/
@Repository("adNewsGroupRecordDao")
public class AdNewsGroupRecordDaoImpl extends BaseDaoImpl<AdNewsGroupRecord> implements AdNewsGroupRecordDao {
@Override
public Integer batchInsert(List<AdNewsGroupRecord> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
}
package com.pcloud.book.adnews.dao.impl;
import com.pcloud.book.adnews.dao.AdNewsSetDao;
import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 16:19
**/
@Repository("adNewsSetDao")
public class AdNewsSetDaoImpl extends BaseDaoImpl<AdNewsSet> implements AdNewsSetDao {
@Override
public AdNewsSet getByPartyId(Long createUser) {
return super.getSqlSession().selectOne(getStatement("getByPartyId"), createUser);
}
}
package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 15:03
**/
@ApiModel("新闻")
public class AdNews extends BaseEntity {
private static final long serialVersionUID = -8389321600700338319L;
@ApiModelProperty("类型")
private String type;
@ApiModelProperty("来源")
private String newsFrom;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("发布者")
private String publisher;
@ApiModelProperty("链接")
private String url;
@ApiModelProperty("短链接")
private String shortUrl;
@ApiModelProperty("发布日期")
private String newsDate;
@ApiModelProperty("是否使用")
private Boolean hasUsed;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getNewsFrom() {
return newsFrom;
}
public void setNewsFrom(String newsFrom) {
this.newsFrom = newsFrom;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getShortUrl() {
return shortUrl;
}
public void setShortUrl(String shortUrl) {
this.shortUrl = shortUrl;
}
public String getNewsDate() {
return newsDate;
}
public void setNewsDate(String newsDate) {
this.newsDate = newsDate;
}
public Boolean getHasUsed() {
return hasUsed;
}
public void setHasUsed(Boolean hasUsed) {
this.hasUsed = hasUsed;
}
@Override
public String toString() {
return "AdNews{" +
"type='" + type + '\'' +
", newsFrom='" + newsFrom + '\'' +
", title='" + title + '\'' +
", publisher='" + publisher + '\'' +
", url='" + url + '\'' +
", shortUrl='" + shortUrl + '\'' +
", newsDate='" + newsDate + '\'' +
", hasUsed=" + hasUsed +
"} " + super.toString();
}
}
package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 15:15
**/
@ApiModel("编辑新闻选择")
public class AdNewsChoose extends BaseEntity {
private static final long serialVersionUID = -5993780219105490818L;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("新闻id")
private Long adNewsId;
@ApiModelProperty("是否删除")
private Boolean isDelete;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("修改人")
private Long updateUser;
public Long getAdviserId() {
return adviserId;
}
public void setAdviserId(Long adviserId) {
this.adviserId = adviserId;
}
public Long getAdNewsId() {
return adNewsId;
}
public void setAdNewsId(Long adNewsId) {
this.adNewsId = adNewsId;
}
public Boolean getIsDelete() {
return isDelete;
}
public void setIsDelete(Boolean isDelete) {
this.isDelete = isDelete;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
@Override
public String toString() {
return "AdNewsChoose{" +
"adviserId=" + adviserId +
", adNewsId=" + adNewsId +
", isDelete=" + isDelete +
", createUser=" + createUser +
", updateUser=" + updateUser +
"} " + super.toString();
}
}
package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 15:20
**/
@ApiModel("编辑新闻群关联")
public class AdNewsGroup extends BaseEntity {
private static final long serialVersionUID = 6345080788160740088L;
@ApiModelProperty("分类Id")
private Long classifyId;
@ApiModelProperty("社群码id")
private Long bookGroupId;
@ApiModelProperty("早晚报设置id")
private Long adNewsSetId;
@ApiModelProperty("是否删除")
private Boolean isDelete;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("修改人")
private Long updateUser;
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public Long getAdNewsSetId() {
return adNewsSetId;
}
public void setAdNewsSetId(Long adNewsSetId) {
this.adNewsSetId = adNewsSetId;
}
public Boolean getIsDelete() {
return isDelete;
}
public void setIsDelete(Boolean isDelete) {
this.isDelete = isDelete;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
@Override
public String toString() {
return "AdNewsGroup{" +
"classifyId=" + classifyId +
", bookGroupId=" + bookGroupId +
", adNewsSetId=" + adNewsSetId +
", isDelete=" + isDelete +
", createUser=" + createUser +
", updateUser=" + updateUser +
"} " + super.toString();
}
}
package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 15:55
**/
@ApiModel("编辑新闻发送记录")
public class AdNewsGroupRecord extends BaseEntity{
private static final long serialVersionUID = -3271071194854381077L;
@ApiModelProperty("群id")
private Long qrcodeId;
@ApiModelProperty("分类id")
private Long classifyId;
@ApiModelProperty("社群码id")
private Long bookGroupId;
@ApiModelProperty("编辑新闻id")
private Long adNewsId;
@ApiModelProperty("编辑新闻设置id")
private Long adNewsSetId;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("修改人")
private Long updateUser;
public Long getQrcodeId() {
return qrcodeId;
}
public void setQrcodeId(Long qrcodeId) {
this.qrcodeId = qrcodeId;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public Long getAdNewsId() {
return adNewsId;
}
public void setAdNewsId(Long adNewsId) {
this.adNewsId = adNewsId;
}
public Long getAdNewsSetId() {
return adNewsSetId;
}
public void setAdNewsSetId(Long adNewsSetId) {
this.adNewsSetId = adNewsSetId;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
@Override
public String toString() {
return "AdNewsGroupRecord{" +
"qrcodeId=" + qrcodeId +
", classifyId=" + classifyId +
", bookGroupId=" + bookGroupId +
", adNewsId=" + adNewsId +
", adNewsSetId=" + adNewsSetId +
", createUser=" + createUser +
", updateUser=" + updateUser +
"} " + super.toString();
}
}
package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 16:13
**/
@ApiModel("编辑新闻发送记录")
public class AdNewsSet extends BaseEntity {
private static final long serialVersionUID = -1115799214395961840L;
@ApiModelProperty("早报时间")
private String morningTime;
@ApiModelProperty("晚报时间")
private String eveningTime;
@ApiModelProperty("是否开启早报")
private Boolean hasMorningOpen;
@ApiModelProperty("是否开启晚报")
private Boolean hasEveningOpen;
@ApiModelProperty("发送次数")
private Integer sendCount;
@ApiModelProperty("开场语")
private String startContent;
@ApiModelProperty("结束语")
private String endContent;
@ApiModelProperty("是否开启开场语")
private Boolean hasStartContent;
@ApiModelProperty("是否开启结束语")
private Boolean hasEndContent;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("修改人")
private Long updateUser;
@ApiModelProperty("分类关联集合")
private List<AdNewsGroup> adNewsGroups;
@ApiModelProperty("分类id集合")
private List<Long> classifyIds;
public String getMorningTime() {
return morningTime;
}
public void setMorningTime(String morningTime) {
this.morningTime = morningTime;
}
public String getEveningTime() {
return eveningTime;
}
public void setEveningTime(String eveningTime) {
this.eveningTime = eveningTime;
}
public Boolean getHasMorningOpen() {
return hasMorningOpen;
}
public void setHasMorningOpen(Boolean hasMorningOpen) {
this.hasMorningOpen = hasMorningOpen;
}
public Boolean getHasEveningOpen() {
return hasEveningOpen;
}
public void setHasEveningOpen(Boolean hasEveningOpen) {
this.hasEveningOpen = hasEveningOpen;
}
public Integer getSendCount() {
return sendCount;
}
public void setSendCount(Integer sendCount) {
this.sendCount = sendCount;
}
public String getStartContent() {
return startContent;
}
public void setStartContent(String startContent) {
this.startContent = startContent;
}
public String getEndContent() {
return endContent;
}
public void setEndContent(String endContent) {
this.endContent = endContent;
}
public Boolean getHasStartContent() {
return hasStartContent;
}
public void setHasStartContent(Boolean hasStartContent) {
this.hasStartContent = hasStartContent;
}
public Boolean getHasEndContent() {
return hasEndContent;
}
public void setHasEndContent(Boolean hasEndContent) {
this.hasEndContent = hasEndContent;
}
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
public List<AdNewsGroup> getAdNewsGroups() {
return adNewsGroups;
}
public void setAdNewsGroups(List<AdNewsGroup> adNewsGroups) {
this.adNewsGroups = adNewsGroups;
}
public List<Long> getClassifyIds() {
return classifyIds;
}
public void setClassifyIds(List<Long> classifyIds) {
this.classifyIds = classifyIds;
}
@Override
public String toString() {
return "AdNewsSet{" +
"morningTime='" + morningTime + '\'' +
", eveningTime='" + eveningTime + '\'' +
", hasMorningOpen=" + hasMorningOpen +
", hasEveningOpen=" + hasEveningOpen +
", sendCount=" + sendCount +
", startContent='" + startContent + '\'' +
", endContent='" + endContent + '\'' +
", hasStartContent=" + hasStartContent +
", hasEndContent=" + hasEndContent +
", createUser=" + createUser +
", updateUser=" + updateUser +
", adNewsGroups=" + adNewsGroups +
", classifyIds=" + classifyIds +
"} " + super.toString();
}
}
package com.pcloud.book.adnews.facade;
import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@FeignClient(value = "pcloud-service-book",qualifier = "adNewsFacadeCloud",path = "adNews")
@Api(description = "推送群消息外部接口")
public interface AdNewsFacade {
@ApiOperation("新增编辑端早晚报设置")
@PostMapping("/createAdNewsSet")
ResponseDto<?> createAdNewsSet(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("编辑端早晚报设置") AdNewsSet adNewsSet
) throws BizException, PermissionException;
@ApiOperation("修改编辑端早晚报设置")
@PostMapping("/updateAdNewsSet")
ResponseDto<?> updateAdNewsSet(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("编辑端早晚报设置") AdNewsSet adNewsSet
) throws BizException, PermissionException;
@ApiOperation("获取编辑早晚报设置")
@GetMapping("/getAdNewsSet")
ResponseDto<?> getAdNewsSet(
@RequestHeader("token") @ApiParam("token信息") String token
) throws BizException, PermissionException;
@ApiOperation("编辑添加选择的早晚报素材")
@PostMapping("/createAdNewsChooseBatch")
ResponseDto<?> createAdNewsChooseBatch(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("新闻id集合") List<Long> adNewsIds
) throws BizException, PermissionException;
@ApiOperation("编辑移除选择的早晚报素材")
@GetMapping("/deleteAdNewsChoose")
ResponseDto<?> deleteAdNewsChoose(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam @ApiParam("adNewsChooseId") Long adNewsChooseId
) throws BizException, PermissionException;
@ApiOperation("获取早晚报素材库")
@GetMapping("/getAdNewsList")
ResponseDto<?> getAdNewsList(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException;
@ApiOperation("获取编辑选择的早晚报素材库")
@GetMapping("/getAdNewsChooseList")
ResponseDto<?> getAdNewsChooseList(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title,
@RequestParam(value = "hasUsed",required = false) @ApiParam("标题") Boolean hasUsed,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException;
}
package com.pcloud.book.adnews.facade.impl;
import com.pcloud.book.adnews.biz.AdNewsBiz;
import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.book.adnews.facade.AdNewsFacade;
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.ListUtils;
import com.pcloud.common.utils.SessionUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/17 15:00
**/
@RestController("adNewsFacade")
@RequestMapping("adNews")
public class AdNewsFacadeImpl implements AdNewsFacade {
@Autowired
private AdNewsBiz adNewsBiz;
@ApiOperation("新增编辑端早晚报设置")
@PostMapping("/createAdNewsSet")
@Override
public ResponseDto<?> createAdNewsSet(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("编辑端早晚报设置") AdNewsSet adNewsSet
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (adNewsSet == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误");
}
adNewsSet.setCreateUser(partyId);
adNewsSet.setUpdateUser(partyId);
return new ResponseDto<>(adNewsBiz.createAdNewsSet(adNewsSet));
}
@ApiOperation("修改编辑端早晚报设置")
@PostMapping("/updateAdNewsSet")
@Override
public ResponseDto<?> updateAdNewsSet(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("编辑端早晚报设置") AdNewsSet adNewsSet
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (adNewsSet == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误");
}
if (adNewsSet.getId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "早晚报设置id不能为空");
}
adNewsSet.setUpdateUser(partyId);
adNewsBiz.updateAdNewsSet(adNewsSet);
return new ResponseDto<>();
}
@ApiOperation("获取编辑早晚报设置")
@GetMapping("/getAdNewsSet")
@Override
public ResponseDto<?> getAdNewsSet(
@RequestHeader("token") @ApiParam("token信息") String token
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(adNewsBiz.getAdNewsSet(partyId));
}
@ApiOperation("编辑添加选择的早晚报素材")
@PostMapping("/createAdNewsChooseBatch")
@Override
public ResponseDto<?> createAdNewsChooseBatch(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("新闻id集合") List<Long> adNewsIds
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (ListUtils.isEmpty(adNewsIds)){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误");
}
adNewsBiz.createAdNewsChooseBatch(adNewsIds,partyId);
return new ResponseDto<>();
}
@ApiOperation("编辑移除选择的早晚报素材")
@GetMapping("/deleteAdNewsChoose")
@Override
public ResponseDto<?> deleteAdNewsChoose(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam @ApiParam("adNewsId") Long adNewsId
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (adNewsId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误");
}
adNewsBiz.deleteAdNewsChoose(adNewsId, partyId);
return new ResponseDto<>();
}
@ApiOperation("获取早晚报素材库")
@GetMapping("/getAdNewsList")
@Override
public ResponseDto<?> getAdNewsList(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (currentPage == null || currentPage < 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "当前页不能为空且不能小于0!");
}
if (numPerPage == null || numPerPage <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "每页条数不能为空且必须大于0!");
}
return new ResponseDto<>(adNewsBiz.getAdNewsList(title,partyId,currentPage,numPerPage));
}
@ApiOperation("获取编辑选择的早晚报素材库")
@GetMapping("/getAdNewsChooseList")
@Override
public ResponseDto<?> getAdNewsChooseList(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title,
@RequestParam(value = "hasUsed",required = false) @ApiParam("使用状态") Boolean hasUsed,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (currentPage == null || currentPage < 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "当前页不能为空且不能小于0!");
}
if (numPerPage == null || numPerPage <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "每页条数不能为空且必须大于0!");
}
return new ResponseDto<>(adNewsBiz.getAdNewsChooseList(partyId, title, hasUsed, currentPage, numPerPage));
}
}
package com.pcloud.book.adnews.service.impl;
import com.pcloud.book.adnews.biz.AdNewsBiz;
import com.pcloud.book.adnews.service.AdNewsService;
import com.pcloud.common.exceptions.BizException;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/18 14:45
**/
@RestController("adNewsService")
@RequestMapping("adNewsService")
public class AdNewsServiceImpl implements AdNewsService {
private static final Logger LOGGER = LoggerFactory.getLogger(AdNewsServiceImpl.class);
private static final ExecutorService EXECUTOR_SINGLE_SERVICE = Executors.newSingleThreadExecutor();
@Autowired
private AdNewsBiz adNewsBiz;
@ApiOperation("发送编辑端早晚报")
@PostMapping("/sendAdNews")
@Override
public void sendAdNews(@RequestBody Map<String, Object> map) throws BizException {
LOGGER.info("内部接口发送编辑端早晚报被调用" + map.toString());
//开线程跑,及时给定时任务返回,避免超时重复调用
EXECUTOR_SINGLE_SERVICE.execute(() -> adNewsBiz.sendAdNews(new Long(map.get("adNewsSetId").toString())));
}
}
package com.pcloud.book.group.dao;
import com.pcloud.book.advertising.dto.WeixinClassifyInfoDTO;
import com.pcloud.book.group.dto.ChangeGroupNameDTO;
import com.pcloud.book.group.dto.GroupAndUserNumberDTO;
import com.pcloud.book.group.dto.GroupQrcodeDTO;
import com.pcloud.book.group.dto.GroupQrcodeInfo4Advertising;
import com.pcloud.book.group.dto.GroupQrcodeInfoDTO;
import com.pcloud.book.group.dto.UpdateQrDTO;
import com.pcloud.book.group.dto.*;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.vo.GroupQrcodeBaseInfoVO;
import com.pcloud.book.group.vo.ListGroupQrcodeResponseVO;
......@@ -196,4 +191,9 @@ public interface GroupQrcodeDao extends BaseDao<GroupQrcode> {
* @return
*/
List<Long> filterDeleteQrcodeId(List<String> wxGroupIdList);
/**
* 根据分类id集合查询
*/
List<GroupQrcodeFoAdDTO> GroupQrcodeFoAdDTOSByClassifyIds(List<Long> classifyIds);
}
......@@ -4,12 +4,7 @@ import com.google.common.collect.Maps;
import com.pcloud.book.advertising.dto.WeixinClassifyInfoDTO;
import com.pcloud.book.group.dao.GroupQrcodeDao;
import com.pcloud.book.group.dto.ChangeGroupNameDTO;
import com.pcloud.book.group.dto.GroupAndUserNumberDTO;
import com.pcloud.book.group.dto.GroupQrcodeDTO;
import com.pcloud.book.group.dto.GroupQrcodeInfo4Advertising;
import com.pcloud.book.group.dto.GroupQrcodeInfoDTO;
import com.pcloud.book.group.dto.UpdateQrDTO;
import com.pcloud.book.group.dto.*;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.vo.GroupQrcodeBaseInfoVO;
import com.pcloud.book.group.vo.ListGroupQrcodeResponseVO;
......@@ -188,4 +183,9 @@ public class GroupQrcodeDaoImpl extends BaseDaoImpl<GroupQrcode> implements Grou
public List<Long> filterDeleteQrcodeId(List<String> wxGroupIdList) {
return this.getSqlSession().selectList(this.getStatement("filterDeleteQrcodeId"), wxGroupIdList);
}
@Override
public List<GroupQrcodeFoAdDTO> GroupQrcodeFoAdDTOSByClassifyIds(List<Long> classifyIds) {
return this.getSqlSession().selectList(this.getStatement("GroupQrcodeFoAdDTOSByClassifyIds"), classifyIds);
}
}
package com.pcloud.book.group.dto;
import java.io.Serializable;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/7/18 15:09
**/
public class GroupQrcodeFoAdDTO implements Serializable {
private static final long serialVersionUID = 7018070035247234809L;
private Long qrcodeId;
private Long classifyId;
private Long bookGroupId;
private String weixinGroupId;
public Long getQrcodeId() {
return qrcodeId;
}
public void setQrcodeId(Long qrcodeId) {
this.qrcodeId = qrcodeId;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public String getWeixinGroupId() {
return weixinGroupId;
}
public void setWeixinGroupId(String weixinGroupId) {
this.weixinGroupId = weixinGroupId;
}
@Override
public String toString() {
return "GroupQrcodeFoAdDTO{" +
"qrcodeId=" + qrcodeId +
", classifyId=" + classifyId +
", bookGroupId=" + bookGroupId +
", weixinGroupId='" + weixinGroupId + '\'' +
'}';
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.adnews.dao.impl.AdNewsChooseDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsChoose">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="ad_news_id" property="adNewsId" jdbcType="BIGINT"/>
<result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, adviser_id, ad_news_id, is_delete, create_time, create_user, update_time, update_user
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from ad_news_choose
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsChoose" useGeneratedKeys="true" keyProperty="id">
insert into ad_news_choose
<trim prefix="(" suffix=")" suffixOverrides=",">
adviser_id,
ad_news_id,
is_delete,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{adviserId,jdbcType=BIGINT},
#{adNewsId,jdbcType=BIGINT},
0,
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.adnews.entity.AdNewsChoose">
update ad_news_choose
<set>
<if test="adviserId != null">
adviser_id = #{adviserId,jdbcType=BIGINT},
</if>
<if test="adNewsId != null">
ad_news_id = #{adNewsId,jdbcType=BIGINT},
</if>
<if test="isDelete != null">
is_delete = #{isDelete,jdbcType=BOOLEAN},
</if>
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=VARCHAR},
</if>
update_time=now()
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into ad_news_choose (
adviser_id,
ad_news_id,
is_delete,
create_user,
create_time,
update_user,
update_time
)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.adviserId,jdbcType=BIGINT},
#{item.adNewsId,jdbcType=BIGINT},
0,
#{item.createUser,jdbcType=BIGINT},
NOW(),
#{item.updateUser,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
<!--根据id删除-->
<update id="deleteAdNewsChooseById" parameterType="map">
update ad_news_choose set
is_delete=1,
update_user=#{partyId},
update_time=now()
where ad_news_id=#{adNewsId}
</update>
<!--根据条件获取数量-->
<select id="getCountByAdNewsIdsAndPartyId" parameterType="map" resultType="Integer">
select count(1) from ad_news_choose where
is_delete=0
and adviser_id=#{partyId}
and ad_news_id in
<foreach collection="adNewsIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.adnews.dao.impl.AdNewsGroupDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsGroup">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="ad_news_set_id" property="adNewsSetId" jdbcType="BIGINT"/>
<result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, classify_id, book_group_id, ad_news_set_id, is_delete, create_user, create_time, update_user, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from ad_news_group
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsGroup" useGeneratedKeys="true" keyProperty="id">
insert into ad_news_group
<trim prefix="(" suffix=")" suffixOverrides=",">
classify_id,
book_group_id,
ad_news_set_id,
is_delete,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{classifyId,jdbcType=BIGINT},
#{bookGroupId,jdbcType=BIGINT},
#{adNewsSetId,jdbcType=BIGINT},
#{isDelete,jdbcType=BOOLEAN},
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.adnews.entity.AdNewsGroup">
update ad_news_group
<set>
<if test="classifyId != null">
classify_id = #{classifyId,jdbcType=BIGINT},
</if>
<if test="bookGroupId != null">
book_group_id = #{bookGroupId,jdbcType=BIGINT},
</if>
<if test="adNewsSetId != null">
ad_news_set_id = #{adNewsSetId,jdbcType=BIGINT},
</if>
<if test="isDelete != null">
is_delete = #{isDelete,jdbcType=BOOLEAN},
</if>
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=VARCHAR},
</if>
update_time=now()
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into ad_news_group (
classify_id,
book_group_id,
ad_news_set_id,
is_delete,
create_user,
create_time,
update_user,
update_time
)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.classifyId,jdbcType=BIGINT},
#{item.bookGroupId,jdbcType=BIGINT},
#{item.adNewsSetId,jdbcType=BIGINT},
0,
#{item.createUser,jdbcType=BIGINT},
NOW(),
#{item.updateUser,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
<!--根据早晚报设置id删除-->
<update id="deleteByAdNewsSetId" parameterType="Long">
update ad_news_group set
is_delete=1,
update_time=now()
where ad_news_set_id=#{adNewsSetId}
</update>
<!--根据早晚报设置id查询-->
<select id="getListByAdNewsSetId" parameterType="Long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from ad_news_group
where is_delete=0 and ad_news_set_id=#{adNewsSetId}
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.adnews.dao.impl.AdNewsGroupRecordDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsGroupRecord">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT"/>
<result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="ad_news_id" property="adNewsId" jdbcType="BIGINT"/>
<result column="ad_news_set_id" property="adNewsSetId" jdbcType="BIGINT"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, qrcode_id, classify_id, book_group_id, ad_news_id, ad_news_set_id, create_user, create_time, update_user, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from ad_news_group_record
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsGroupRecord" useGeneratedKeys="true" keyProperty="id">
insert into ad_news_group_record
<trim prefix="(" suffix=")" suffixOverrides=",">
qrcode_id,
classify_id,
book_group_id,
ad_news_id,
ad_news_set_id,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{qrcodeId,jdbcType=BIGINT},
#{classifyId,jdbcType=BIGINT},
#{bookGroupId,jdbcType=BIGINT},
#{adNewsId,jdbcType=BIGINT},
#{adNewsSetId,jdbcType=BIGINT},
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.adnews.entity.AdNewsGroupRecord">
update ad_news_group_record
<set>
<if test="qrcodeId != null">
qrcode_id = #{qrcodeId,jdbcType=BIGINT},
</if>
<if test="classifyId != null">
classify_id = #{classifyId,jdbcType=BIGINT},
</if>
<if test="bookGroupId != null">
book_group_id = #{bookGroupId,jdbcType=BIGINT},
</if>
<if test="adNewsId != null">
ad_news_id = #{adNewsId,jdbcType=BIGINT},
</if>
<if test="adNewsSetId != null">
ad_news_set_id = #{adNewsSetId,jdbcType=BIGINT},
</if>
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=VARCHAR},
</if>
update_time=now()
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into ad_news_group_record (
qrcode_id,
classify_id,
book_group_id,
ad_news_id,
ad_news_set_id,
create_user,
create_time,
update_user,
update_time
)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.qrcodeId,jdbcType=BIGINT},
#{item.classifyId,jdbcType=BIGINT},
#{item.bookGroupId,jdbcType=BIGINT},
#{item.adNewsId,jdbcType=BIGINT},
#{item.adNewsSetId,jdbcType=BIGINT},
#{item.createUser,jdbcType=BIGINT},
NOW(),
#{item.updateUser,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.adnews.dao.impl.AdNewsDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNews">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="type" property="type" jdbcType="VARCHAR"/>
<result column="news_from" property="newsFrom" jdbcType="VARCHAR"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="publisher" property="publisher" jdbcType="VARCHAR"/>
<result column="url" property="url" jdbcType="VARCHAR"/>
<result column="short_url" property="shortUrl" jdbcType="VARCHAR"/>
<result column="news_date" property="newsDate" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, type, news_from, title, publisher, url, short_url, news_date, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from ad_news
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNews" useGeneratedKeys="true" keyProperty="id">
insert into ad_news
<trim prefix="(" suffix=")" suffixOverrides=",">
type,
news_from,
title,
publisher,
url,
short_url,
news_date,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{type,jdbcType=VARCHAR},
#{newsFrom,jdbcType=VARCHAR},
#{title,jdbcType=VARCHAR},
#{publisher,jdbcType=VARCHAR},
#{url,jdbcType=VARCHAR},
#{shortUrl,jdbcType=VARCHAR},
#{newsDate,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.adnews.entity.AdNews">
update ad_news
<set>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="newsFrom != null">
news_from = #{newsFrom,jdbcType=VARCHAR},
</if>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="publisher != null">
publisher = #{publisher,jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="shortUrl != null">
short_url = #{shortUrl,jdbcType=VARCHAR},
</if>
<if test="newsDate != null">
news_date = #{newsDate,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into ad_news (
type,
news_from,
title,
publisher,
url,
short_url,
news_date,
create_time
)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.type,jdbcType=VARCHAR},
#{item.newsFrom,jdbcType=VARCHAR},
#{item.title,jdbcType=VARCHAR},
#{item.publisher,jdbcType=VARCHAR},
#{item.url,jdbcType=VARCHAR},
#{item.shortUrl,jdbcType=VARCHAR},
#{item.newsDate,jdbcType=VARCHAR},
NOW()
)
</foreach>
</insert>
<!--查找要发送的新闻-->
<select id="getNewsToSendBySetIdAndAdviser" parameterType="map" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
ad_news t
WHERE
t.id IN (
SELECT
t1.ad_news_id
FROM
ad_news_choose t1
WHERE
t1.is_delete=0
and t1.adviser_id =#{adviserId}
)
AND t.id NOT IN (
SELECT
t2.ad_news_id
FROM
ad_news_group_record t2
WHERE
t2.ad_news_set_id =#{adNewsSetId}
)
ORDER BY
t.create_time DESC
LIMIT #{top}
</select>
<!--获取素材库列表-->
<select id="getAdNewsList" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from ad_news
where id not in (
select distinct ad_news_id from ad_news_choose
where adviser_id = #{partyId}
)
<if test="title!=null">
and title like concat('%', #{title},'%')
</if>
order by create_time desc
</select>
<!--获取编辑选择的素材-->
<select id="getAdNewsChooseList" parameterType="map" resultType="com.pcloud.book.adnews.entity.AdNews">
SELECT
t1.id id,
t1.type type,
t1.news_from newsFrom,
t1.title title,
t1.publisher publisher,
t1.url url,
t1.short_url shortUrl,
t1.news_date newsDate,
t1.create_time createTime,
CASE COUNT(t3.id) WHEN 0 THEN 0 ELSE 1 END hasUsed
FROM
ad_news t1
INNER JOIN ad_news_choose t2 ON t1.id = t2.ad_news_id
LEFT JOIN ad_news_group_record t3 ON t1.id=t3.ad_news_id
WHERE
t2.is_delete = 0
AND t2.adviser_id = #{partyId}
<if test="title!=null">
AND t1.title like concat('%', #{title},'%')
</if>
GROUP BY
t1.id
<if test="hasUsed!=null">
having hasUsed=#{hasUsed}
</if>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.adnews.dao.impl.AdNewsSetDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsSet">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="morning_time" property="morningTime" jdbcType="VARCHAR"/>
<result column="evening_time" property="eveningTime" jdbcType="VARCHAR"/>
<result column="has_morning_open" property="hasMorningOpen" jdbcType="BOOLEAN"/>
<result column="has_evening_open" property="hasEveningOpen" jdbcType="BOOLEAN"/>
<result column="send_count" property="sendCount" jdbcType="INTEGER"/>
<result column="start_content" property="startContent" jdbcType="VARCHAR"/>
<result column="end_content" property="endContent" jdbcType="VARCHAR"/>
<result column="has_start_content" property="hasStartContent" jdbcType="BOOLEAN"/>
<result column="has_end_content" property="hasEndContent" jdbcType="BOOLEAN"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_user" property="updateUser" jdbcType="BIGINT"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, morning_time, evening_time, has_morning_open, has_evening_open, send_count, start_content,
end_content, has_start_content, has_end_content, create_user, create_time, update_user, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from ad_news_set
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsSet" useGeneratedKeys="true" keyProperty="id">
insert into ad_news_set
<trim prefix="(" suffix=")" suffixOverrides=",">
morning_time,
evening_time,
has_morning_open,
has_evening_open,
send_count,
start_content,
end_content,
has_start_content,
has_end_content,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{morningTime,jdbcType=VARCHAR},
#{eveningTime,jdbcType=VARCHAR},
#{hasMorningOpen,jdbcType=BOOLEAN},
#{hasEveningOpen,jdbcType=BOOLEAN},
#{sendCount,jdbcType=INTEGER},
#{startContent,jdbcType=VARCHAR},
#{endContent,jdbcType=VARCHAR},
#{hasStartContent,jdbcType=BOOLEAN},
#{hasEndContent,jdbcType=BOOLEAN},
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.adnews.entity.AdNewsSet">
update ad_news_set
<set>
<if test="morningTime != null">
morning_time = #{morningTime,jdbcType=VARCHAR},
</if>
<if test="eveningTime != null">
evening_time = #{eveningTime,jdbcType=VARCHAR},
</if>
<if test="hasMorningOpen != null">
has_morning_open = #{hasMorningOpen,jdbcType=BOOLEAN},
</if>
<if test="hasEveningOpen != null">
has_evening_open = #{hasEveningOpen,jdbcType=BOOLEAN},
</if>
<if test="sendCount != null">
send_count = #{sendCount,jdbcType=INTEGER},
</if>
<if test="startContent != null">
start_content = #{startContent,jdbcType=VARCHAR},
</if>
<if test="endContent != null">
end_content = #{endContent,jdbcType=VARCHAR},
</if>
<if test="hasStartContent != null">
has_start_content = #{hasStartContent,jdbcType=BOOLEAN},
</if>
<if test="hasEndContent != null">
has_end_content = #{hasEndContent,jdbcType=BOOLEAN},
</if>
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=BIGINT},
</if>
update_time = NOW(),
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--根据创建人查询-->
<select id="getByPartyId" parameterType="Long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from ad_news_set
where create_user=#{createUser}
</select>
</mapper>
\ No newline at end of file
......@@ -480,4 +480,22 @@
</if>
</select>
<!--根据分类id集合查询-->
<select id="GroupQrcodeFoAdDTOSByClassifyIds" parameterType="list" resultType="com.pcloud.book.group.dto.GroupQrcodeFoAdDTO">
SELECT
t.id qrcodeId,
t.weixin_group_id weixinGroupId,
t1.id classifyId,
t1.book_group_id bookGroupId
FROM
book_group_qrcode t
INNER JOIN book_group_classify t1 ON t.classify_id = t1.id
WHERE
t.is_delete = 0
AND t1.is_delete = 0
AND t1.id IN
<foreach collection = "list" index="index" item = "item" open = "(" separator= "," close = ")">
#{item}
</foreach>
</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