Commit d87b70b1 by 郑永强

C1001361 早晚报优化

parent 84344081
...@@ -2,6 +2,7 @@ package com.pcloud.book.adnews.biz; ...@@ -2,6 +2,7 @@ package com.pcloud.book.adnews.biz;
import com.pcloud.book.adnews.entity.AdNews; import com.pcloud.book.adnews.entity.AdNews;
import com.pcloud.book.adnews.entity.AdNewsSet; import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.book.adnews.entity.AdNewsWechat;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import java.util.List; import java.util.List;
...@@ -46,4 +47,42 @@ public interface AdNewsBiz { ...@@ -46,4 +47,42 @@ public interface AdNewsBiz {
* 获取编辑已选取的素材库列表 * 获取编辑已选取的素材库列表
*/ */
PageBeanNew<AdNews> getAdNewsChooseList(Long partyId, String title, Boolean hasUsed, Integer currentPage, Integer numPerPage); PageBeanNew<AdNews> getAdNewsChooseList(Long partyId, String title, Boolean hasUsed, Integer currentPage, Integer numPerPage);
/**
* 增加公众号反馈
* @param adNewsWechat
* @return
*/
Long addAdNewsWechat(AdNewsWechat adNewsWechat);
/**
* 获取公众号列表
* @param currentPage
* @param numPerPage
* @return
*/
PageBeanNew<AdNewsWechat> getAdNewsWechatList(Integer currentPage, Integer numPerPage);
/**
* 获取编辑已选择的公众号列表
* @param partyId
* @param currentPage
* @param numPerPage
*/
PageBeanNew<AdNewsWechat> getAdNewsWechatChooseList(Long partyId, Integer currentPage, Integer numPerPage);
/**
* 编辑添加选择的公众号
* @param adNewsWechatIds
* @param partyId
*/
void createAdNewsWechatChooseBatch(List<Long> adNewsWechatIds, Long partyId);
/**
* 编辑移除选择的公众号
* @param adNewsWechatId
* @param partyId
*/
void deleteAdNewsWechatChoose(Long adNewsWechatId, Long partyId);
} }
...@@ -54,6 +54,10 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -54,6 +54,10 @@ public class AdNewsBizImpl implements AdNewsBiz {
@Autowired @Autowired
private AdNewsChooseDao adNewsChooseDao; private AdNewsChooseDao adNewsChooseDao;
@Autowired @Autowired
private AdNewsWechatChooseDao adNewsWechatChooseDao;
@Autowired
private AdNewsWechatDao adNewsWechatDao;
@Autowired
private AdNewsDao adNewsDao; private AdNewsDao adNewsDao;
@Autowired @Autowired
private AdNewsGroupRecordDao adNewsGroupRecordDao; private AdNewsGroupRecordDao adNewsGroupRecordDao;
...@@ -70,9 +74,9 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -70,9 +74,9 @@ public class AdNewsBizImpl implements AdNewsBiz {
public Long createAdNewsSet(AdNewsSet adNewsSet) { public Long createAdNewsSet(AdNewsSet adNewsSet) {
adNewsCheck.createAdNewsSetCheck(adNewsSet); adNewsCheck.createAdNewsSetCheck(adNewsSet);
//新增之前判断是否有记录 //新增之前判断是否有记录
AdNewsSet adNewsSetOld=adNewsSetDao.getByPartyId(adNewsSet.getCreateUser()); AdNewsSet adNewsSetOld = adNewsSetDao.getByPartyId(adNewsSet.getCreateUser());
if (adNewsSetOld!=null){ if (adNewsSetOld != null) {
throw new BookBizException(BookBizException.ERROR,"不可重复创建!"); throw new BookBizException(BookBizException.ERROR, "不可重复创建!");
} }
adNewsSetDao.insert(adNewsSet); adNewsSetDao.insert(adNewsSet);
buildAdNewsGroups(adNewsSet, adNewsSet.getCreateUser()); buildAdNewsGroups(adNewsSet, adNewsSet.getCreateUser());
...@@ -161,20 +165,20 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -161,20 +165,20 @@ public class AdNewsBizImpl implements AdNewsBiz {
} }
//查询关联 //查询关联
List<AdNewsGroup> adNewsGroups = adNewsGroupDao.getListByAdNewsSetId(adNewsSetId); List<AdNewsGroup> adNewsGroups = adNewsGroupDao.getListByAdNewsSetId(adNewsSetId);
if (ListUtils.isEmpty(adNewsGroups)){ if (ListUtils.isEmpty(adNewsGroups)) {
return; return;
} }
List<Long> classifyIds = adNewsGroups.stream().filter(s -> s.getClassifyId() != null).map(AdNewsGroup::getClassifyId).collect(Collectors.toList()); List<Long> classifyIds = adNewsGroups.stream().filter(s -> s.getClassifyId() != null).map(AdNewsGroup::getClassifyId).collect(Collectors.toList());
//查询关联的群 //查询关联的群
List<GroupQrcodeFoAdDTO> groupQrcodeFoAdDTOS = groupQrcodeDao.GroupQrcodeFoAdDTOSByClassifyIds(classifyIds); List<GroupQrcodeFoAdDTO> groupQrcodeFoAdDTOS = groupQrcodeDao.GroupQrcodeFoAdDTOSByClassifyIds(classifyIds);
if (ListUtils.isEmpty(groupQrcodeFoAdDTOS)){ if (ListUtils.isEmpty(groupQrcodeFoAdDTOS)) {
return; return;
} }
Integer sendCount = adNewsSet.getSendCount(); Integer sendCount = adNewsSet.getSendCount();
//查询要发的记录 //查询要发的记录
Long adviserId = adNewsSet.getCreateUser(); Long adviserId = adNewsSet.getCreateUser();
List<AdNews> adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser(adNewsSetId, adviserId, sendCount); List<AdNews> adNewsList = adNewsDao.getNewsToSendBySetIdAndAdviser(adNewsSetId, adviserId, sendCount);
if (ListUtils.isEmpty(adNewsList)){ if (ListUtils.isEmpty(adNewsList)) {
return; return;
} }
//分成300一组 //分成300一组
...@@ -203,11 +207,11 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -203,11 +207,11 @@ public class AdNewsBizImpl implements AdNewsBiz {
endContent = adNewsSet.getEndContent(); endContent = adNewsSet.getEndContent();
} }
//循环发送 //循环发送
for (GroupQrcodeFoAdDTO groupQrcodeFoAdDTO:groupQrcodeFoAdDTOS){ for (GroupQrcodeFoAdDTO groupQrcodeFoAdDTO : groupQrcodeFoAdDTOS) {
String weixinGroupId=groupQrcodeFoAdDTO.getWeixinGroupId(); String weixinGroupId = groupQrcodeFoAdDTO.getWeixinGroupId();
String robotId =wechatGroupConsr.getRobotIdByGroupId(weixinGroupId); String robotId = wechatGroupConsr.getRobotIdByGroupId(weixinGroupId);
if (StringUtil.isEmpty(robotId)){ if (StringUtil.isEmpty(robotId)) {
LOGGER.info("发送编辑端早晚报未找到小号"+weixinGroupId); LOGGER.info("发送编辑端早晚报未找到小号" + weixinGroupId);
} }
if (!StringUtil.isEmpty(startContent)) { if (!StringUtil.isEmpty(startContent)) {
//发送开场语 //发送开场语
...@@ -246,6 +250,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -246,6 +250,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
public AdNewsSet getAdNewsSet(Long partyId) { public AdNewsSet getAdNewsSet(Long partyId) {
AdNewsSet adNewsSet = adNewsSetDao.getByPartyId(partyId); AdNewsSet adNewsSet = adNewsSetDao.getByPartyId(partyId);
if (adNewsSet != null) { if (adNewsSet != null) {
// 获取勾选的社群
List<AdNewsGroup> adNewsGroups = adNewsGroupDao.getListByAdNewsSetId(adNewsSet.getId()); List<AdNewsGroup> adNewsGroups = adNewsGroupDao.getListByAdNewsSetId(adNewsSet.getId());
adNewsSet.setAdNewsGroups(adNewsGroups); adNewsSet.setAdNewsGroups(adNewsGroups);
if (!ListUtils.isEmpty(adNewsGroups)) { if (!ListUtils.isEmpty(adNewsGroups)) {
...@@ -260,9 +265,9 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -260,9 +265,9 @@ public class AdNewsBizImpl implements AdNewsBiz {
@ParamLog("编辑添加选择的早晚报素材") @ParamLog("编辑添加选择的早晚报素材")
@Override @Override
public void createAdNewsChooseBatch(List<Long> adNewsIds, Long partyId) { public void createAdNewsChooseBatch(List<Long> adNewsIds, Long partyId) {
List<AdNewsChoose> adNewsChooses=new ArrayList<>(); List<AdNewsChoose> adNewsChooses = new ArrayList<>();
for (Long adNewsId:adNewsIds){ for (Long adNewsId : adNewsIds) {
AdNewsChoose adNewsChoose=new AdNewsChoose(); AdNewsChoose adNewsChoose = new AdNewsChoose();
adNewsChoose.setAdNewsId(adNewsId); adNewsChoose.setAdNewsId(adNewsId);
adNewsChoose.setAdviserId(partyId); adNewsChoose.setAdviserId(partyId);
adNewsChoose.setCreateUser(partyId); adNewsChoose.setCreateUser(partyId);
...@@ -281,7 +286,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -281,7 +286,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
@ParamLog("编辑移除选择的早晚报素材") @ParamLog("编辑移除选择的早晚报素材")
@Override @Override
public void deleteAdNewsChoose(Long adNewsId, Long partyId) { public void deleteAdNewsChoose(Long adNewsId, Long partyId) {
adNewsChooseDao.deleteAdNewsChooseById(adNewsId,partyId); adNewsChooseDao.deleteAdNewsChooseById(adNewsId, partyId);
} }
@ParamLog("获取素材库列表") @ParamLog("获取素材库列表")
...@@ -290,7 +295,7 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -290,7 +295,7 @@ public class AdNewsBizImpl implements AdNewsBiz {
PageParam pageParam = new PageParam(currentPage, numPerPage); PageParam pageParam = new PageParam(currentPage, numPerPage);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("title", title); map.put("title", title);
map.put("partyId",partyId); map.put("partyId", partyId);
PageBeanNew<AdNews> pageBeanNew = adNewsDao.listPageNew(pageParam, map, "getAdNewsList"); PageBeanNew<AdNews> pageBeanNew = adNewsDao.listPageNew(pageParam, map, "getAdNewsList");
return pageBeanNew; return pageBeanNew;
} }
...@@ -343,4 +348,57 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -343,4 +348,57 @@ public class AdNewsBizImpl implements AdNewsBiz {
String ip = Optional.ofNullable(groupVersion.get(wechatGroupId)).orElse(new BookWxQrcodeDTO()).getWechatGroupIp(); String ip = Optional.ofNullable(groupVersion.get(wechatGroupId)).orElse(new BookWxQrcodeDTO()).getWechatGroupIp();
return ip; return ip;
} }
@ParamLog("增加公众号反馈")
@Override
public Long addAdNewsWechat(AdNewsWechat adNewsWechat){
return adNewsWechatDao.insert(adNewsWechat);
}
@ParamLog("获取公众号列表")
@Override
public PageBeanNew<AdNewsWechat> getAdNewsWechatList(Integer currentPage, Integer numPerPage) {
PageParam pageParam = new PageParam(currentPage, numPerPage);
Map<String, Object> map = new HashMap<>();
PageBeanNew<AdNewsWechat> pageBeanNew = adNewsWechatDao.listPageNew(pageParam, map, "getAdNewsWechatList");
return pageBeanNew;
}
@ParamLog("获取编辑已选取的公众号列表")
@Override
public PageBeanNew<AdNewsWechat> getAdNewsWechatChooseList(Long partyId, Integer currentPage, Integer numPerPage) {
PageParam pageParam = new PageParam(currentPage, numPerPage);
Map<String, Object> map = new HashMap<>();
map.put("partyId", partyId);
PageBeanNew<AdNewsWechat> pageBeanNew = adNewsWechatDao.listPageNew(pageParam, map, "getAdNewsWechatChooseList");
return pageBeanNew;
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("编辑添加选择的公众号")
@Override
public void createAdNewsWechatChooseBatch(List<Long> adNewsWechatIds, Long partyId) {
List<AdNewsWechatChoose> adNewsWechatChooses = new ArrayList<>();
for (Long adNewsWechatId : adNewsWechatIds) {
AdNewsWechatChoose adNewsWechatChoose = new AdNewsWechatChoose();
adNewsWechatChoose.setAdNewsWechatId(adNewsWechatId);
adNewsWechatChoose.setAdviserId(partyId);
adNewsWechatChoose.setCreateUser(partyId);
adNewsWechatChoose.setUpdateUser(partyId);
adNewsWechatChooses.add(adNewsWechatChoose);
}
//校验重复添加
Integer count = adNewsWechatChooseDao.getCountByAdNewsWechatIdsAndPartyId(adNewsWechatIds, partyId);
if (count > 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "请勿重复添加!");
}
adNewsWechatChooseDao.batchInsert(adNewsWechatChooses);
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("编辑移除选择的公众号")
@Override
public void deleteAdNewsWechatChoose(Long adNewsWechatId, Long partyId) {
adNewsWechatChooseDao.deleteAdNewsWechatChooseById(adNewsWechatId, partyId);
}
} }
package com.pcloud.book.adnews.check; package com.pcloud.book.adnews.check;
import com.google.common.base.Enums;
import com.pcloud.book.adnews.entity.AdNewsGroup; import com.pcloud.book.adnews.entity.AdNewsGroup;
import com.pcloud.book.adnews.entity.AdNewsSet; import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.book.adnews.enums.AdContentFromEnum;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -16,49 +19,52 @@ import org.springframework.stereotype.Component; ...@@ -16,49 +19,52 @@ import org.springframework.stereotype.Component;
public class AdNewsCheck { public class AdNewsCheck {
public void createAdNewsSetCheck(AdNewsSet adNewsSet){ public void createAdNewsSetCheck(AdNewsSet adNewsSet) {
if (adNewsSet==null){ if (adNewsSet == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数错误"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误");
} }
if (ListUtils.isEmpty(adNewsSet.getAdNewsGroups())){ if (ListUtils.isEmpty(adNewsSet.getAdNewsGroups())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"发送群分类不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "发送群分类不能为空!");
} }
if (adNewsSet.getSendCount()==null||adNewsSet.getSendCount()<=0){ if (adNewsSet.getSendCount() == null || adNewsSet.getSendCount() <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"推送条数不能为空且必须大于0!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "推送条数不能为空且必须大于0!");
} }
if (adNewsSet.getHasMorningOpen()==null){ if (adNewsSet.getHasMorningOpen() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启早报不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "是否开启早报不能为空!");
} }
if (adNewsSet.getHasEveningOpen()==null){ if (adNewsSet.getHasEveningOpen() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启晚报不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "是否开启晚报不能为空!");
} }
if (adNewsSet.getHasStartContent()==null){ if (adNewsSet.getHasStartContent() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启开场语不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "是否开启开场语不能为空!");
} }
if (adNewsSet.getHasEndContent()==null){ if (adNewsSet.getHasEndContent() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"是否开启结束语不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "是否开启结束语不能为空!");
} }
if (adNewsSet.getHasMorningOpen()&&StringUtil.isEmpty(adNewsSet.getMorningTime())){ if (adNewsSet.getHasMorningOpen() && StringUtil.isEmpty(adNewsSet.getMorningTime())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"早报时间不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "早报时间不能为空!");
} }
if (adNewsSet.getHasEveningOpen()&&StringUtil.isEmpty(adNewsSet.getEveningTime())){ if (adNewsSet.getHasEveningOpen() && StringUtil.isEmpty(adNewsSet.getEveningTime())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"晚报时间不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "晚报时间不能为空!");
} }
if (adNewsSet.getHasStartContent()&&StringUtil.isEmpty(adNewsSet.getStartContent())){ if (adNewsSet.getHasStartContent() && StringUtil.isEmpty(adNewsSet.getStartContent())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"开场语不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "开场语不能为空!");
} }
if (adNewsSet.getHasEndContent()&&StringUtil.isEmpty(adNewsSet.getEndContent())){ if (adNewsSet.getHasEndContent() && StringUtil.isEmpty(adNewsSet.getEndContent())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"结束语不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "结束语不能为空!");
} }
for(AdNewsGroup adNewsGroup:adNewsSet.getAdNewsGroups()){ if (adNewsSet.getContentFrom() != AdContentFromEnum.WECHAT.key && adNewsSet.getContentFrom() != AdContentFromEnum.CUSTOM.key) {
if (adNewsGroup==null){ throw new BookBizException(BookBizException.PARAM_IS_ERROR, "请选择早晚报内容来源!");
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"早晚报关联不能为空!");
} }
if (adNewsGroup.getClassifyId()==null){ for (AdNewsGroup adNewsGroup : adNewsSet.getAdNewsGroups()) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"群分类id不能为空!"); if (adNewsGroup == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "早晚报关联不能为空!");
} }
if (adNewsGroup.getBookGroupId()==null){ if (adNewsGroup.getClassifyId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"社群码id不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "群分类id不能为空!");
}
if (adNewsGroup.getBookGroupId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "社群码id不能为空!");
} }
} }
......
...@@ -6,9 +6,15 @@ import com.pcloud.common.core.dao.BaseDao; ...@@ -6,9 +6,15 @@ import com.pcloud.common.core.dao.BaseDao;
import java.util.List; import java.util.List;
public interface AdNewsGroupDao extends BaseDao<AdNewsGroup> { public interface AdNewsGroupDao extends BaseDao<AdNewsGroup> {
Integer batchInsert(List<AdNewsGroup> adNewsGroups); Integer batchInsert(List<AdNewsGroup> adNewsGroups);
void deleteByAdNewsSetId(Long adNewsSetId); void deleteByAdNewsSetId(Long adNewsSetId);
/**
* 获取勾选关联的社群
* @param adNewsSetId
* @return
*/
List<AdNewsGroup> getListByAdNewsSetId(Long adNewsSetId); List<AdNewsGroup> getListByAdNewsSetId(Long adNewsSetId);
} }
package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNewsChoose;
import com.pcloud.book.adnews.entity.AdNewsWechatChoose;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @author zhengyongqiang
* @date 2019/8/7 11:47
*/
public interface AdNewsWechatChooseDao extends BaseDao<AdNewsWechatChoose> {
Integer batchInsert(List<AdNewsWechatChoose> adNewsWechatChooses);
void deleteAdNewsWechatChooseById(Long adNewsWechatId, Long partyId);
Integer getCountByAdNewsWechatIdsAndPartyId(List<Long> adNewsIds, Long partyId);
}
package com.pcloud.book.adnews.dao;
import com.pcloud.book.adnews.entity.AdNewsWechat;
import com.pcloud.common.core.dao.BaseDao;
/**
* @author zhengyongqiang
* @date 2019/8/7 11:46
*/
public interface AdNewsWechatDao extends BaseDao<AdNewsWechat> {
}
package com.pcloud.book.adnews.dao.impl;
import com.pcloud.book.adnews.dao.AdNewsWechatChooseDao;
import com.pcloud.book.adnews.entity.AdNewsWechatChoose;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author zhengyongqiang
* @date 2019/8/7 11:52
*/
@Repository("adNewsWechatChooseDao")
public class AdNewsWechatChooseDaoImpl extends BaseDaoImpl<AdNewsWechatChoose> implements AdNewsWechatChooseDao {
@Override
public Integer batchInsert(List<AdNewsWechatChoose> adNewsWechatChooses) {
return super.getSqlSession().insert(getStatement("batchInsert"),adNewsWechatChooses);
}
@Override
public void deleteAdNewsWechatChooseById(Long adNewsWechatId, Long partyId) {
Map<String, Object> map = new HashMap<>();
map.put("adNewsWechatId", adNewsWechatId);
map.put("partyId", partyId);
super.getSqlSession().delete(getStatement("deleteAdNewsWechatChooseById"), map);
}
@Override
public Integer getCountByAdNewsWechatIdsAndPartyId(List<Long> adNewsWechatIds, Long partyId) {
Map<String, Object> map = new HashMap<>();
map.put("adNewsWechatIds", adNewsWechatIds);
map.put("partyId", partyId);
return super.getSqlSession().selectOne(getStatement("getCountByAdNewsWechatIdsAndPartyId"), map);
}
}
package com.pcloud.book.adnews.dao.impl;
import com.pcloud.book.adnews.dao.AdNewsWechatDao;
import com.pcloud.book.adnews.entity.AdNewsWechat;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
/**
* @author zhengyongqiang
* @date 2019/8/7 11:52
*/
@Repository("adNewsWechatDao")
public class AdNewsWechatDaoImpl extends BaseDaoImpl<AdNewsWechat> implements AdNewsWechatDao {
}
...@@ -49,6 +49,15 @@ public class AdNewsSet extends BaseEntity { ...@@ -49,6 +49,15 @@ public class AdNewsSet extends BaseEntity {
@ApiModelProperty("修改人") @ApiModelProperty("修改人")
private Long updateUser; private Long updateUser;
@ApiModelProperty("内容来源")
private Integer contentFrom;
@ApiModelProperty("早报内容")
private String morningContent;
@ApiModelProperty("晚报内容")
private String eveningContent;
@ApiModelProperty("分类关联集合") @ApiModelProperty("分类关联集合")
private List<AdNewsGroup> adNewsGroups; private List<AdNewsGroup> adNewsGroups;
...@@ -143,6 +152,30 @@ public class AdNewsSet extends BaseEntity { ...@@ -143,6 +152,30 @@ public class AdNewsSet extends BaseEntity {
this.updateUser = updateUser; this.updateUser = updateUser;
} }
public Integer getContentFrom() {
return contentFrom;
}
public void setContentFrom(Integer contentFrom) {
this.contentFrom = contentFrom;
}
public String getMorningContent() {
return morningContent;
}
public void setMorningContent(String morningContent) {
this.morningContent = morningContent;
}
public String getEveningContent() {
return eveningContent;
}
public void setEveningContent(String eveningContent) {
this.eveningContent = eveningContent;
}
public List<AdNewsGroup> getAdNewsGroups() { public List<AdNewsGroup> getAdNewsGroups() {
return adNewsGroups; return adNewsGroups;
} }
...@@ -173,8 +206,11 @@ public class AdNewsSet extends BaseEntity { ...@@ -173,8 +206,11 @@ public class AdNewsSet extends BaseEntity {
", hasEndContent=" + hasEndContent + ", hasEndContent=" + hasEndContent +
", createUser=" + createUser + ", createUser=" + createUser +
", updateUser=" + updateUser + ", updateUser=" + updateUser +
", contentFrom=" + contentFrom +
", morningContent='" + morningContent + '\'' +
", eveningContent='" + eveningContent + '\'' +
", adNewsGroups=" + adNewsGroups + ", adNewsGroups=" + adNewsGroups +
", classifyIds=" + classifyIds + ", classifyIds=" + classifyIds +
"} " + super.toString(); '}';
} }
} }
package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @author zhengyongqiang
* @date 2019/8/7 11:23
*/
@ApiModel("新闻微信公众号")
public class AdNewsWechat extends BaseEntity {
private static final long serialVersionUID = 454065623001378319L;
public AdNewsWechat() {
}
public AdNewsWechat(String wechatId, String wechatName, Long adviserId, Boolean isDelete) {
this.wechatId = wechatId;
this.wechatName = wechatName;
this.adviserId = adviserId;
this.isDelete = isDelete;
}
@ApiModelProperty("微信公众号唯一标识")
private String wechatId;
@ApiModelProperty("微信公众号名称")
private String wechatName;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("是否删除")
private Boolean isDelete;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getWechatId() {
return wechatId;
}
public void setWechatId(String wechatId) {
this.wechatId = wechatId;
}
public String getWechatName() {
return wechatName;
}
public void setWechatName(String wechatName) {
this.wechatName = wechatName;
}
public Long getAdviserId() {
return adviserId;
}
public void setAdviserId(Long adviserId) {
this.adviserId = adviserId;
}
public Boolean getDelete() {
return isDelete;
}
public void setDelete(Boolean delete) {
isDelete = delete;
}
@Override
public String toString() {
return "AdNewsWechat{" +
"wechatId='" + wechatId + '\'' +
", wechatName='" + wechatName + '\'' +
", adviserId=" + adviserId +
", isDelete=" + isDelete +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}
package com.pcloud.book.adnews.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @author zhengyongqiang
* @date 2019/8/7 11:32
*/
@ApiModel("新闻公众号选择关联")
public class AdNewsWechatChoose extends BaseEntity {
private static final long serialVersionUID = 209558478794921448L;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("公众号id")
private Long adNewsWechatId;
@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 getAdNewsWechatId() {
return adNewsWechatId;
}
public void setAdNewsWechatId(Long adNewsWechatId) {
this.adNewsWechatId = adNewsWechatId;
}
public Boolean getDelete() {
return isDelete;
}
public void setDelete(Boolean delete) {
isDelete = delete;
}
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 "AdNewsWechatChoose{" +
"adviserId=" + adviserId +
", adNewsWechatId=" + adNewsWechatId +
", isDelete=" + isDelete +
", createUser=" + createUser +
", updateUser=" + updateUser +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}
package com.pcloud.book.adnews.enums;
import com.pcloud.book.advertising.enums.AdDetailModeEnum;
import org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl;
/**
* 早晚报内容来源
*
* @author zhengyongqiang
* @date 2019/8/6 17:50
*/
public enum AdContentFromEnum {
WECHAT(0, "微信公众号"),
CUSTOM(1, "自定义内容 ");
public final Integer key;
public final String name;
AdContentFromEnum(Integer key, String name) {
this.key = key;
this.name = name;
}
public static String getNameByKey(String key) {
AdContentFromEnum[] var1 = values();
int var2 = var1.length;
for (int var3 = 0; var3 < var2; ++var3) {
AdContentFromEnum methodEnum = var1[var3];
if (methodEnum.key.equals(key)) {
return methodEnum.name;
}
}
return null;
}
}
package com.pcloud.book.adnews.enums;
/**
* 公众号状态
* @author zhengyongqiang
* @date 2019/8/7 11:37
*/
public enum AdNewsWechatEnum {
EXAMINING(0), // 审核中
ENABLE(1); // 已启用
public final Integer key;
AdNewsWechatEnum(Integer key){
this.key=key;
}
}
...@@ -16,7 +16,6 @@ import java.util.List; ...@@ -16,7 +16,6 @@ import java.util.List;
@Api(description = "推送群消息外部接口") @Api(description = "推送群消息外部接口")
public interface AdNewsFacade { public interface AdNewsFacade {
@ApiOperation("新增编辑端早晚报设置") @ApiOperation("新增编辑端早晚报设置")
@PostMapping("/createAdNewsSet") @PostMapping("/createAdNewsSet")
ResponseDto<?> createAdNewsSet( ResponseDto<?> createAdNewsSet(
...@@ -70,4 +69,12 @@ public interface AdNewsFacade { ...@@ -70,4 +69,12 @@ public interface AdNewsFacade {
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage @RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException; ) throws BizException, PermissionException;
@ApiOperation("增加公众号反馈")
@PostMapping("/addAdNewsWechat")
ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "wechatName") @ApiParam("公众号id/微信号") String wechatName
) throws BizException,PermissionException;
} }
...@@ -2,6 +2,7 @@ package com.pcloud.book.adnews.facade.impl; ...@@ -2,6 +2,7 @@ package com.pcloud.book.adnews.facade.impl;
import com.pcloud.book.adnews.biz.AdNewsBiz; import com.pcloud.book.adnews.biz.AdNewsBiz;
import com.pcloud.book.adnews.entity.AdNewsSet; import com.pcloud.book.adnews.entity.AdNewsSet;
import com.pcloud.book.adnews.entity.AdNewsWechat;
import com.pcloud.book.adnews.facade.AdNewsFacade; import com.pcloud.book.adnews.facade.AdNewsFacade;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.ApiParam; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -144,5 +146,15 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -144,5 +146,15 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
return new ResponseDto<>(adNewsBiz.getAdNewsChooseList(partyId, title, hasUsed, currentPage, numPerPage)); return new ResponseDto<>(adNewsBiz.getAdNewsChooseList(partyId, title, hasUsed, currentPage, numPerPage));
} }
@ApiOperation("增加公众号反馈")
@PostMapping("/addAdNewsWechat")
@Override
public ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "wechatName") @ApiParam("公众号id/微信号") String wechatName
) throws BizException,PermissionException{
Long partyId = (Long) SessionUtil.getVlaue(token,SessionUtil.PARTY_ID);
AdNewsWechat adNewsWechat = new AdNewsWechat(null,wechatName,partyId,false);
return new ResponseDto<>(adNewsBiz.addAdNewsWechat(adNewsWechat));
}
} }
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, morning_time, evening_time, has_morning_open, has_evening_open, send_count, start_content, 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 end_content, has_start_content, has_end_content, create_user, create_time, update_user, update_time
,content_from,morning_content,evening_content
</sql> </sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long"> <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
...@@ -45,7 +46,10 @@ ...@@ -45,7 +46,10 @@
create_user, create_user,
create_time, create_time,
update_user, update_user,
update_time update_time,
content_from,
morning_content,
evening_content
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
#{morningTime,jdbcType=VARCHAR}, #{morningTime,jdbcType=VARCHAR},
...@@ -61,6 +65,9 @@ ...@@ -61,6 +65,9 @@
NOW(), NOW(),
#{updateUser,jdbcType=BIGINT}, #{updateUser,jdbcType=BIGINT},
NOW(), NOW(),
#{contentFrom,jdbcType=BIGINT},
#{morningContent,jdbcType=VARCHAR},
#{eveningContent,jdbcType=VARCHAR},
</trim> </trim>
</insert> </insert>
...@@ -97,7 +104,16 @@ ...@@ -97,7 +104,16 @@
<if test="updateUser != null"> <if test="updateUser != null">
update_user = #{updateUser,jdbcType=BIGINT}, update_user = #{updateUser,jdbcType=BIGINT},
</if> </if>
update_time = NOW(), <if test="contentFrom != null">
content_from = #{contentFrom,jdbcType=BIGINT},
</if>
<if test="morningContent != null">
morning_content = #{morningContent,jdbcType=VARCHAR},
</if>
<if test="eveningContent != null">
evening_content = #{eveningContent,jdbcType=VARCHAR},
</if>
update_time = NOW()
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
......
<?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.AdNewsWechatChooseDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsWechatChoose">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="ad_news_wechat_id" property="adNewsWechatId" 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_wechat_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_wechat_choose
where id = #{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsWechatChoose" useGeneratedKeys="true" keyProperty="id">
insert into ad_news_wechat_choose
<trim prefix="(" suffix=")" suffixOverrides=",">
adviser_id,
ad_news_wechat_id,
is_delete,
create_user,
create_time,
update_user,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{adviserId,jdbcType=BIGINT},
#{adNewsWechatId,jdbcType=BIGINT},
0,
#{createUser,jdbcType=BIGINT},
NOW(),
#{updateUser,jdbcType=BIGINT},
NOW(),
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.adnews.entity.AdNewsWechatChoose">
update ad_news_wechat_choose
<set>
<if test="adviserId != null">
adviser_id = #{adviserId,jdbcType=BIGINT},
</if>
<if test="adNewsWechatId != null">
ad_news_wechat_id = #{adNewsWechatId,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_wechat_choose (
adviser_id,
ad_news_wechat_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.adNewsWechatId,jdbcType=BIGINT},
0,
#{item.createUser,jdbcType=BIGINT},
NOW(),
#{item.updateUser,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
<!--根据id删除-->
<update id="deleteAdNewsWechatChooseById" parameterType="map">
update ad_news_wechat_choose set
is_delete=1,
update_user=#{partyId},
update_time=now()
where ad_news_wechat_id=#{adNewsWechatId}
</update>
<!--根据条件获取数量-->
<select id="getCountByAdNewsWechatIdsAndPartyId" parameterType="map" resultType="Integer">
select count(1) from ad_news_wechat_choose where
is_delete=0
and adviser_id=#{partyId}
and ad_news_wechat_id in
<foreach collection="adNewsWechatIds" 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.AdNewsWechatDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsWechat">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="wechat_id" property="wechatId" jdbcType="VARCHAR"/>
<result column="wechat_name" property="wechatName" jdbcType="VARCHAR"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="is_delete" property="isDelete" jdbcType="BOOLEAN"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, wechat_id, wechat_name, adviser_id, is_delete, create_time, update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from ad_news_wechat
where id = #{id,jdbcType=BIGINT}
</select>
<!--获取公众号列表-->
<select id="getAdNewsWechatList" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from ad_news_wechat
where
wechat_id IS NOT NULL
order by id desc
</select>
<!--获取编辑已选中的公众号列表-->
<select id="getAdNewsWechatChooseList" parameterType="map" resultMap="BaseResultMap">
SELECT
a.id,
a.wechat_id,
a.wechat_name,
a.adviser_id,
a.is_delete,
a.create_time,
a.update_time
FROM
ad_news_wechat a
LEFT JOIN ad_news_wechat_choose b ON b.ad_news_wechat_id = b.id
AND b.is_delete = 0
AND b.adviser_id = #{partyId}
WHERE
a.`wechat_id` IS NOT NULL
</select>
<insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsWechat" useGeneratedKeys="true" keyProperty="id">
insert into ad_news_wechat
<trim prefix="(" suffix=")" suffixOverrides=",">
wechat_id, wechat_name, adviser_id, is_delete, create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{wechatId,jdbcType=VARCHAR},
#{wechatName,jdbcType=VARCHAR},
#{adviserId,jdbcType=BIGINT},
#{isDelete,jdbcType=BOOLEAN},
NOW()
</trim>
</insert>
</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