Commit c92e4e0d by 郑永强

早晚报公众号选择

parent d87b70b1
...@@ -56,7 +56,7 @@ public interface AdNewsBiz { ...@@ -56,7 +56,7 @@ public interface AdNewsBiz {
Long addAdNewsWechat(AdNewsWechat adNewsWechat); Long addAdNewsWechat(AdNewsWechat adNewsWechat);
/** /**
* 获取公众号列表 * 获取所有的公众号列表
* @param currentPage * @param currentPage
* @param numPerPage * @param numPerPage
* @return * @return
......
...@@ -387,11 +387,14 @@ public class AdNewsBizImpl implements AdNewsBiz { ...@@ -387,11 +387,14 @@ public class AdNewsBizImpl implements AdNewsBiz {
adNewsWechatChoose.setUpdateUser(partyId); adNewsWechatChoose.setUpdateUser(partyId);
adNewsWechatChooses.add(adNewsWechatChoose); adNewsWechatChooses.add(adNewsWechatChoose);
} }
//校验重复添加 // //校验重复添加
Integer count = adNewsWechatChooseDao.getCountByAdNewsWechatIdsAndPartyId(adNewsWechatIds, partyId); // Integer count = adNewsWechatChooseDao.getCountByAdNewsWechatIdsAndPartyId(adNewsWechatIds, partyId);
if (count > 0) { // if (count > 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "请勿重复添加!"); // throw new BookBizException(BookBizException.PARAM_IS_ERROR, "请勿重复添加!");
} // }
// 移除编辑之前的选择
adNewsWechatChooseDao.deleteAdNewsWechatChooseByPartyId(partyId);
// 重新建立关系
adNewsWechatChooseDao.batchInsert(adNewsWechatChooses); adNewsWechatChooseDao.batchInsert(adNewsWechatChooses);
} }
......
...@@ -16,5 +16,7 @@ public interface AdNewsWechatChooseDao extends BaseDao<AdNewsWechatChoose> { ...@@ -16,5 +16,7 @@ public interface AdNewsWechatChooseDao extends BaseDao<AdNewsWechatChoose> {
void deleteAdNewsWechatChooseById(Long adNewsWechatId, Long partyId); void deleteAdNewsWechatChooseById(Long adNewsWechatId, Long partyId);
void deleteAdNewsWechatChooseByPartyId(Long partyId);
Integer getCountByAdNewsWechatIdsAndPartyId(List<Long> adNewsIds, Long partyId); Integer getCountByAdNewsWechatIdsAndPartyId(List<Long> adNewsIds, Long partyId);
} }
...@@ -30,6 +30,13 @@ public class AdNewsWechatChooseDaoImpl extends BaseDaoImpl<AdNewsWechatChoose> i ...@@ -30,6 +30,13 @@ public class AdNewsWechatChooseDaoImpl extends BaseDaoImpl<AdNewsWechatChoose> i
} }
@Override @Override
public void deleteAdNewsWechatChooseByPartyId(Long partyId) {
Map<String, Object> map = new HashMap<>();
map.put("partyId", partyId);
super.getSqlSession().delete(getStatement("deleteAdNewsWechatChooseByPartyId"), map);
}
@Override
public Integer getCountByAdNewsWechatIdsAndPartyId(List<Long> adNewsWechatIds, Long partyId) { public Integer getCountByAdNewsWechatIdsAndPartyId(List<Long> adNewsWechatIds, Long partyId) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("adNewsWechatIds", adNewsWechatIds); map.put("adNewsWechatIds", adNewsWechatIds);
......
package com.pcloud.book.adnews.facade; package com.pcloud.book.adnews.facade;
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.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException; import com.pcloud.common.permission.PermissionException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -12,7 +14,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -12,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@FeignClient(value = "pcloud-service-book",qualifier = "adNewsFacadeCloud",path = "adNews") @FeignClient(value = "pcloud-service-book", qualifier = "adNewsFacadeCloud", path = "adNews")
@Api(description = "推送群消息外部接口") @Api(description = "推送群消息外部接口")
public interface AdNewsFacade { public interface AdNewsFacade {
...@@ -54,7 +56,7 @@ public interface AdNewsFacade { ...@@ -54,7 +56,7 @@ public interface AdNewsFacade {
@GetMapping("/getAdNewsList") @GetMapping("/getAdNewsList")
ResponseDto<?> getAdNewsList( ResponseDto<?> getAdNewsList(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title, @RequestParam(value = "title", required = false) @ApiParam("标题") String title,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage, @RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage @RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException; ) throws BizException, PermissionException;
...@@ -63,8 +65,8 @@ public interface AdNewsFacade { ...@@ -63,8 +65,8 @@ public interface AdNewsFacade {
@GetMapping("/getAdNewsChooseList") @GetMapping("/getAdNewsChooseList")
ResponseDto<?> getAdNewsChooseList( ResponseDto<?> getAdNewsChooseList(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title, @RequestParam(value = "title", required = false) @ApiParam("标题") String title,
@RequestParam(value = "hasUsed",required = false) @ApiParam("标题") Boolean hasUsed, @RequestParam(value = "hasUsed", required = false) @ApiParam("标题") Boolean hasUsed,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage, @RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage @RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException; ) throws BizException, PermissionException;
...@@ -74,7 +76,36 @@ public interface AdNewsFacade { ...@@ -74,7 +76,36 @@ public interface AdNewsFacade {
@PostMapping("/addAdNewsWechat") @PostMapping("/addAdNewsWechat")
ResponseDto<?> addAdNewsWechat( ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "wechatName") @ApiParam("公众号id/微信号") String wechatName @RequestParam(value = "wechatName") @ApiParam("公众号名称") String wechatName
) throws BizException,PermissionException; ) throws BizException, PermissionException;
@ApiOperation("添加编辑选择的公众号")
@PostMapping("/createAdNewsWechatChooseBatch")
ResponseDto<?> createAdNewsWechatChooseBatch(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("选择的公众号主键") List<Long> adNewsWechatIds
) throws BizException, PermissionException;
@ApiOperation("移除编辑已选择的公众号")
@PostMapping("/deleteAdNewsWechatChoose")
ResponseDto<?> deleteAdNewsWechatChoose(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "adNewsWechatId") @ApiParam("公众号主键") Long adNewsWechatId
) throws BizException, PermissionException;
@ApiOperation("获取编辑已选择的公众号")
@GetMapping("/getAdNewsWechatChooseList")
ResponseDto<?> getAdNewsWechatChooseList(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException;
@ApiOperation("获取所有的公众号列表")
@GetMapping("/getAdNewsWechatList")
ResponseDto<?> getAdNewsWechatList(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException;
} }
...@@ -85,10 +85,10 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -85,10 +85,10 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
@RequestBody @ApiParam("新闻id集合") List<Long> adNewsIds @RequestBody @ApiParam("新闻id集合") List<Long> adNewsIds
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID); Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (ListUtils.isEmpty(adNewsIds)){ if (ListUtils.isEmpty(adNewsIds)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误");
} }
adNewsBiz.createAdNewsChooseBatch(adNewsIds,partyId); adNewsBiz.createAdNewsChooseBatch(adNewsIds, partyId);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -112,7 +112,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -112,7 +112,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
@Override @Override
public ResponseDto<?> getAdNewsList( public ResponseDto<?> getAdNewsList(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title, @RequestParam(value = "title", required = false) @ApiParam("标题") String title,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage, @RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage @RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException { ) throws BizException, PermissionException {
...@@ -123,7 +123,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -123,7 +123,7 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
if (numPerPage == null || numPerPage <= 0) { if (numPerPage == null || numPerPage <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "每页条数不能为空且必须大于0!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR, "每页条数不能为空且必须大于0!");
} }
return new ResponseDto<>(adNewsBiz.getAdNewsList(title,partyId,currentPage,numPerPage)); return new ResponseDto<>(adNewsBiz.getAdNewsList(title, partyId, currentPage, numPerPage));
} }
@ApiOperation("获取编辑选择的早晚报素材库") @ApiOperation("获取编辑选择的早晚报素材库")
...@@ -131,8 +131,8 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -131,8 +131,8 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
@Override @Override
public ResponseDto<?> getAdNewsChooseList( public ResponseDto<?> getAdNewsChooseList(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "title",required = false) @ApiParam("标题") String title, @RequestParam(value = "title", required = false) @ApiParam("标题") String title,
@RequestParam(value = "hasUsed",required = false) @ApiParam("使用状态") Boolean hasUsed, @RequestParam(value = "hasUsed", required = false) @ApiParam("使用状态") Boolean hasUsed,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage, @RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage @RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException { ) throws BizException, PermissionException {
...@@ -152,9 +152,69 @@ public class AdNewsFacadeImpl implements AdNewsFacade { ...@@ -152,9 +152,69 @@ public class AdNewsFacadeImpl implements AdNewsFacade {
public ResponseDto<?> addAdNewsWechat( public ResponseDto<?> addAdNewsWechat(
@RequestHeader("token") @ApiParam("token信息") String token, @RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "wechatName") @ApiParam("公众号id/微信号") String wechatName @RequestParam(value = "wechatName") @ApiParam("公众号id/微信号") String wechatName
) throws BizException,PermissionException{ ) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token,SessionUtil.PARTY_ID); Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
AdNewsWechat adNewsWechat = new AdNewsWechat(null,wechatName,partyId,false); AdNewsWechat adNewsWechat = new AdNewsWechat(null, wechatName, partyId, false);
return new ResponseDto<>(adNewsBiz.addAdNewsWechat(adNewsWechat)); return new ResponseDto<>(adNewsBiz.addAdNewsWechat(adNewsWechat));
} }
@ApiOperation("添加编辑选择的公众号")
@PostMapping("/createAdNewsWechatChooseBatch")
@Override
public ResponseDto<?> createAdNewsWechatChooseBatch(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("选择的公众号主键") List<Long> adNewsWechatIds
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
adNewsBiz.createAdNewsWechatChooseBatch(adNewsWechatIds,partyId);
return new ResponseDto<>();
}
@Override
@ApiOperation("移除编辑已选择的公众号")
@PostMapping("/deleteAdNewsWechatChoose")
public ResponseDto<?> deleteAdNewsWechatChoose(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam(value = "adNewsWechatId") @ApiParam("公众号主键") Long adNewsWechatId
) throws BizException, PermissionException{
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
adNewsBiz.deleteAdNewsWechatChoose(adNewsWechatId,partyId);
return new ResponseDto<>();
}
@Override
@ApiOperation("获取编辑已选择的公众号")
@GetMapping("/getAdNewsWechatChooseList")
public ResponseDto<?> getAdNewsWechatChooseList(
@RequestHeader("token") @ApiParam("token信息") String token,
@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.getAdNewsWechatChooseList(partyId, currentPage, numPerPage));
}
@Override
@ApiOperation("获取所有的公众号列表")
@GetMapping("/getAdNewsWechatList")
public ResponseDto<?> getAdNewsWechatList(
@RequestHeader("token") @ApiParam("token信息") String token,
@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.getAdNewsWechatList(currentPage, numPerPage));
}
} }
...@@ -100,6 +100,15 @@ ...@@ -100,6 +100,15 @@
where ad_news_wechat_id=#{adNewsWechatId} where ad_news_wechat_id=#{adNewsWechatId}
</update> </update>
<!--根据编辑id删除-->
<update id="deleteAdNewsWechatChooseByPartyId" parameterType="map">
update ad_news_wechat_choose set
is_delete=1,
update_user=#{partyId},
update_time=now()
where adviser_id=#{partyId}
</update>
<!--根据条件获取数量--> <!--根据条件获取数量-->
<select id="getCountByAdNewsWechatIdsAndPartyId" parameterType="map" resultType="Integer"> <select id="getCountByAdNewsWechatIdsAndPartyId" parameterType="map" resultType="Integer">
select count(1) from ad_news_wechat_choose where select count(1) from ad_news_wechat_choose where
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
a.update_time a.update_time
FROM FROM
ad_news_wechat a ad_news_wechat a
LEFT JOIN ad_news_wechat_choose b ON b.ad_news_wechat_id = b.id INNER JOIN ad_news_wechat_choose b ON b.ad_news_wechat_id = a.id
AND b.is_delete = 0 AND b.is_delete = 0
AND b.adviser_id = #{partyId} AND b.adviser_id = #{partyId}
WHERE WHERE
......
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