Commit ce0115a1 by 桂前礼

feat: [1003438] 权益板块里的线下活动以资讯形式地理位置标签

parent 711b5e2d
......@@ -80,12 +80,13 @@ public interface AppletNewsBiz {
* @param currentPage
* @param numPerPage
* @param name
* @param cityCode
* @return
*/
PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name,
Long firstClassify,Long secondClassify,Long gradeLabelId,
Long subjectLabelId,Long rightsClassifyId,String source,Integer showState, Long newsClassifyId,
Long customTagId);
Long firstClassify, Long secondClassify, Long gradeLabelId,
Long subjectLabelId, Long rightsClassifyId, String source, Integer showState, Long newsClassifyId,
Long customTagId, String cityCode);
/**
* 获取所有资讯栏目
......
package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletUserBookcaseBiz;
......@@ -50,8 +51,10 @@ import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.push.dao.PersonalAppletsDao;
import com.pcloud.book.push.entity.PersonalApplets;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
import com.pcloud.book.record.entity.RegionMap;
import com.pcloud.book.record.mapper.RegionMapMapper;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dao.RightsNowItemDao;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
......@@ -60,7 +63,6 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.readercenter.wechat.entity.WechatUser;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -77,8 +79,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
/**
* 小程序资讯
*/
......@@ -119,6 +119,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
private AppletThirdResourcesRelationDao thirdResourcesRelationDao;
@Autowired
private AppletThirdResourcesDao thirdResourcesDao;
@Autowired
private BookBrowseRecordBiz bookBrowseRecordBiz;
@Autowired
private RegionMapMapper regionMapMapper;
@Override
public void deleteCategoryById(Long id) {
......@@ -211,12 +215,18 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
}
appletNewsCategoryDao.deletebyNewsId(newsId);
List<AppletNewsCategory> list = new ArrayList<>();
for (AppletNewsCategory category : categoryList) {
rightsSettingBiz.setClassifyAndLabel(category);
category.setAppletNewId(newsId);
if (Objects.nonNull(category.getFirstClassify())){
rightsSettingBiz.setClassifyAndLabel(category);
category.setAppletNewId(newsId);
list.add(category);
}
}
if (CollUtil.isNotEmpty(list)){
appletNewsCategoryDao.batchCreate(list);
}
appletNewsCategoryDao.batchCreate(categoryList);
}
......@@ -311,9 +321,9 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
@Override
public PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name,
Long firstClassify, Long secondClassify, Long gradeLabelId,
Long subjectLabelId, Long rightsClassifyId, String source, Integer showState, Long newsClassifyId,
Long customTagId) {
Long firstClassify, Long secondClassify, Long gradeLabelId,
Long subjectLabelId, Long rightsClassifyId, String source, Integer showState, Long newsClassifyId,
Long customTagId, String cityCode) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("name", name);
paramMap.put("rightsClassifyId", rightsClassifyId);
......@@ -324,7 +334,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
//是否有分类筛选
Boolean classifySelect = false;
//处理分类
if (null!=firstClassify){
if (null != firstClassify) {
classifySelect = true;
BaseTempletClassify classify = new BaseTempletClassify();
classify.setFirstClassify(firstClassify);
......@@ -344,16 +354,51 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
}
}
paramMap.put("classifySelect", classifySelect);
List<String> cityCodes = null;
if (StrUtil.isNotBlank(name)) {
List<RegionMap> citysByPY = regionMapMapper.getCitysByPY(name);
if (CollUtil.isNotEmpty(citysByPY)){
cityCodes = citysByPY.stream().filter(x -> Objects.nonNull(x)).map(RegionMap::getRegionCode).distinct().collect(Collectors.toList());
}
}
paramMap.put("cityCodes", cityCodes);
paramMap.put("cityCode", cityCode);
PageBeanNew<AppletNewsDTO> pageBeanNew = appletNewsDao.listPageNew(
new PageParam(currentPage, numPerPage), paramMap, "listAppletNews");
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
//填充咨询分类
fillCategory(pageBeanNew.getRecordList());
// 填充城市名称
fillCity(pageBeanNew.getRecordList());
return pageBeanNew;
}
private void fillCity(List<AppletNewsDTO> recordList) {
if (CollUtil.isEmpty(recordList)){
return;
}
List<String> codeList = recordList.stream().filter(Objects::nonNull).map(AppletNewsDTO::getCityCode).distinct().collect(Collectors.toList());
if (CollUtil.isEmpty(codeList)) {
return;
}
Map<String, RegionMap> regionMapMap = bookBrowseRecordBiz.getCitysByCodes(codeList);
if (MapUtils.isNotEmpty(regionMapMap)){
recordList.forEach(record -> {
RegionMap regionMap = regionMapMap.get(record.getCityCode());
if (regionMapMap.containsKey(record.getCityCode()) && null != regionMap){
record.setCity(regionMap.getRegionName());
}
});
}
}
private void fillLabel(List<AppletNewsDTO> recordList) {
if (ListUtils.isEmpty(recordList)) {
return;
......@@ -583,6 +628,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
fillBusinessCard(appletNewsDTO);
// 填充城市信息
if (StrUtil.isNotBlank(appletNews.getCityCode())) {
appletNewsDTO.setCity(regionMapMapper.getCitysByCode(appletNews.getCityCode()));
}
return appletNewsDTO;
}
......@@ -748,13 +797,13 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
if(appletNewsClassifyVO == null || ListUtils.isEmpty(appletNewsClassifyVO.getAppletNewsIds())){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "参数为空");
}
if (ListUtils.isEmpty(appletNewsClassifyVO.getCategoryDTOList())) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "请选择分类");
}
rightsSettingBiz.setClassifyAndLabel(appletNewsClassifyVO);
for (Long id : appletNewsClassifyVO.getAppletNewsIds()){
this.saveAppletNewsCategory(appletNewsClassifyVO.getCategoryDTOList(), id);
List<AppletNewsCategory> categoryDTOList = appletNewsClassifyVO.getCategoryDTOList();
if (CollUtil.isNotEmpty(categoryDTOList)) {
for (Long id : appletNewsClassifyVO.getAppletNewsIds()) {
this.saveAppletNewsCategory(categoryDTOList, id);
}
}
appletNewsDao.batchUpdateClassify(appletNewsClassifyVO);
}
......@@ -1090,12 +1139,14 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
appletNewsDao.insert(appletNewsList);
for (AppletNews appletNews: appletNewsList){
AppletNewsCategory category = new AppletNewsCategory();
category.setFirstClassify(appletNews.getFirstClassify());
category.setSecondClassify(appletNews.getSecondClassify());
category.setGradeLabelId(appletNews.getGradeLabelId());
category.setSubjectLabelId(appletNews.getSubjectLabelId());
saveAppletNewsCategory(Arrays.asList(category),appletNews.getId());
if (Objects.nonNull(appletNews.getFirstClassify()) && appletNews.getFirstClassify()!=0){
AppletNewsCategory category = new AppletNewsCategory();
category.setFirstClassify(appletNews.getFirstClassify());
category.setSecondClassify(appletNews.getSecondClassify());
category.setGradeLabelId(appletNews.getGradeLabelId());
category.setSubjectLabelId(appletNews.getSubjectLabelId());
saveAppletNewsCategory(Arrays.asList(category),appletNews.getId());
}
}
}
......
package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.util.PageUtil;
import com.alibaba.druid.sql.PagerUtils;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletNewsPoolBiz;
import com.pcloud.book.applet.dao.AppletNewsDao;
......@@ -9,12 +7,10 @@ import com.pcloud.book.applet.dao.AppletNewsPoolDAO;
import com.pcloud.book.applet.dto.AppletNewsPoolDTO;
import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletNewsPool;
import com.pcloud.book.applet.enums.AppletNewsServeTypeEnum;
import com.pcloud.book.applet.enums.NewsJumpTypeEnum;
import com.pcloud.book.applet.enums.NewsTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
......@@ -26,7 +22,6 @@ import com.pcloud.readercenter.common.enums.YesOrNoNumEnum;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.security.krb5.internal.PAData;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -94,7 +89,7 @@ public class AppletNewsPoolBizImpl implements AppletNewsPoolBiz {
return;
}
appletNewsPoolIds.stream().forEach(id -> {
appletNewsPoolIds.forEach(id -> {
AppletNews appletNews = new AppletNews();
BeanUtils.copyProperties(appletNewsPoolDTO, appletNews);
rightsSettingBiz.setClassifyAndLabel(appletNews);
......@@ -104,12 +99,16 @@ public class AppletNewsPoolBizImpl implements AppletNewsPoolBiz {
}
addResource(appletNewsPool.getSource());
appletNews.setNewsName(appletNewsPool.getNewsName());
appletNews.setCityCode(appletNewsPoolDTO.getCityCode());
appletNews.setSource(appletNewsPool.getSource());
appletNews.setContent(appletNewsPool.getContent());
appletNews.setType(null == appletNewsPoolDTO.getNewsType() ? NewsTypeEnum.ONLY_PIC.code : appletNewsPoolDTO.getNewsType());
appletNews.setPic1(null == appletNewsPoolDTO.getPic1() ? BookConstant.DEFAULT_NEWS_PIC : appletNewsPoolDTO.getPic1());
appletNews.setJumpType(NewsJumpTypeEnum.NEWS_EDIT.code);
appletNews.setShowSource(null == appletNewsPoolDTO.getShowSource() ? YesOrNoNumEnum.YES.getValue() : appletNewsPoolDTO.getShowSource());
if (appletNews.getFirstClassify()!=null&&appletNews.getFirstClassify()==0){
appletNews.setFirstClassify(null);
}
appletNewsList.add(appletNews);
});
if (!ListUtils.isEmpty(appletNewsList)) {
......
......@@ -7,6 +7,7 @@ import com.pcloud.book.applet.entity.AppletNewsCustomTag;
import com.pcloud.book.applet.vo.AppletNewsClassifyVO;
import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
......@@ -164,4 +165,10 @@ public interface AppletNewsDao extends BaseDao<AppletNews> {
* @param appletNews
*/
void updateCardShowState(AppletNews appletNews);
/**
* 根据城市获取对应资讯
* @param cityId
*/
List<AppletNewsDTO> listNewsByCityCode(String cityId);
}
......@@ -8,7 +8,6 @@ import com.pcloud.book.applet.entity.AppletNewsCustomTag;
import com.pcloud.book.applet.vo.AppletNewsClassifyVO;
import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
......@@ -99,6 +98,7 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
map.put("subjectLabelId", appletNewsClassifyVO.getSubjectLabelId());
map.put("rightsClassifyId", appletNewsClassifyVO.getRightsClassifyId());
map.put("newsClassifyId", appletNewsClassifyVO.getNewsClassifyId());
map.put("cityCode", appletNewsClassifyVO.getCityCode());
getSessionTemplate().update(getStatement("batchUpdateClassify"), map);
}
......@@ -186,6 +186,12 @@ public class AppletNewsDaoImpl extends BaseDaoImpl<AppletNews> implements Applet
public void updateCardShowState(AppletNews appletNews) {
getSessionTemplate().update(getStatement("updateCardShowState"),appletNews);
}
@Override
public List<AppletNewsDTO> listNewsByCityCode(String cityId) {
return this.getSqlSession().selectList(getStatement("listNewsByCityCode"), cityId);
}
@Override
public Integer listAppletNews4WechatCount(Map<String, Object> paramMap) {
return getSessionTemplate().selectOne(getStatement("listAppletNews4WechatCount"), paramMap);
......
......@@ -138,4 +138,9 @@ public class AppletNewsDTO extends BaseDto {
@ApiModelProperty("第三方资源")
List<AppletThirdResources> thirdResourcesRelations;
@ApiModelProperty("城市编码")
private String cityCode;
@ApiModelProperty("城市名")
private String city;
}
......@@ -99,4 +99,8 @@ public class AppletNewsPoolDTO extends BaseDto {
private Integer newsType;
@ApiModelProperty("素材池id)")
private List<Long> appletNewsPoolIds;
@ApiModelProperty("城市编码")
private String cityCode;
@ApiModelProperty("城市名称")
private String city;
}
package com.pcloud.book.applet.entity;
import javax.validation.constraints.NotNull;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import java.util.List;
import org.hibernate.validator.constraints.Length;
@Data
@ApiModel("小程序资讯")
public class AppletNews extends BaseTempletClassify {
......@@ -98,6 +95,12 @@ public class AppletNews extends BaseTempletClassify {
@ApiModelProperty("修改人")
private Long updator;
@ApiModelProperty("城市编码")
private String cityCode;
@ApiModelProperty("城市")
private String city;
@ApiModelProperty("选取的服务")
List<AppletNewsServe> appletNewsServeList;
......
......@@ -498,14 +498,15 @@ public class AppletHomeFacade {
@RequestParam(value = "source", required = false) @ApiParam("来源") String source,
@RequestParam(value = "showState", required = false) @ApiParam("上架") Integer showState,
@RequestParam(value = "newsClassifyId", required = false) @ApiParam("资讯栏目id") Long newsClassifyId,
@RequestParam(value = "customTagId", required = false) @ApiParam("自定义标识id") Long customTagId
@RequestParam(value = "customTagId", required = false) @ApiParam("自定义标识id") Long customTagId,
@RequestParam(value = "cityCode", required = false) @ApiParam("城市筛选") String cityCode
) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
}
return new ResponseDto<>(appletNewsBiz.listAppletNews(currentPage, numPerPage, name, firstClassify,secondClassify,gradeLabelId,
subjectLabelId,rightsClassifyId,source,showState,newsClassifyId,customTagId));
subjectLabelId,rightsClassifyId,source,showState,newsClassifyId,customTagId, cityCode));
}
@ApiOperation("客户端资讯列表")
......
package com.pcloud.book.applet.vo;
import com.pcloud.book.applet.dto.AppletNewsCategoryDTO;
import com.pcloud.book.applet.entity.AppletNewsCategory;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import java.util.List;
/**
* @ClassName com.pcloud.book.applet.vo.AppletNewsClassifyVO
* @Author ZhengYongQiang
......@@ -30,4 +29,7 @@ public class AppletNewsClassifyVO extends BaseTempletClassify {
@ApiModelProperty("分类集合")
private List<AppletNewsCategory> categoryDTOList;
@ApiModelProperty("地区编码")
private String cityCode;
}
package com.pcloud.book.record.biz;
import com.pcloud.book.record.entity.IpData;
public interface IpDataBiz {
/**
* 根据IP获取位置信息
*
* @param ipAddress ip
* @return {@link IpData}
*/
IpData getAreaByIp(String ipAddress);
}
package com.pcloud.book.record.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.record.biz.IpDataBiz;
import com.pcloud.book.record.entity.IpData;
import com.pcloud.book.record.entity.IpData4Third;
import com.pcloud.book.record.entity.IpResponse;
import com.pcloud.book.record.mapper.IpDataMapper;
import com.pcloud.book.util.common.HttpUtils;
import com.pcloud.common.utils.json.JSONUtils;
import com.pcloud.common.utils.string.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* @author guiq
* @since 2020年8月21日
*/
@Service
@Slf4j
public class IpDataBizImpl implements IpDataBiz {
private static final String HOST = "https://api01.aliyun.venuscn.com";
private static final String PATH = "/ip";
private static final String METHOD = "GET";
@Autowired
private IpDataMapper ipDataMapper;
@Value("${ip.appcode}")
private String appCode;
@Override
public IpData getAreaByIp(String ipAddress) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appCode);
Map<String, String> queries = new HashMap<String, String>();
queries.put("ip", ipAddress);
//先从数据库查询,没有再查询第三方
IpData ipData = ipDataMapper.selectByIp(ipAddress);
if (null == ipData) {
try {
HttpResponse response = HttpUtils.doGet(HOST, PATH, METHOD, headers, queries);
log.info("查询ip返回的数据是response:{}", response);
String entityString = EntityUtils.toString(response.getEntity());
IpResponse ipResponse;
if (StringUtil.isEmpty(entityString)) {
return null;
}
ipResponse = JSONUtils.jsonToBean(entityString, IpResponse.class);
if (null == ipResponse || null == ipResponse.getData()) {
return null;
}
IpData4Third ipData4Third = ipResponse.getData();
if (!Objects.equals("200", ipResponse.getRet())) {
return null;
}
if (null == ipData4Third || null == ipData4Third.getCity_id()) {
return null;
}
ipData = new IpData();
ipData.setIp(ipAddress);
ipData.setRegion(ipData4Third.getRegion());
ipData.setRegionId(ipData4Third.getRegion_id());
ipData.setCity(ipData4Third.getCity());
ipData.setCityId(ipData4Third.getCity_id());
ipDataMapper.insert(ipData);
} catch (Exception e) {
log.error("获取ip失败,ip:{}", ipAddress);
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "获取ip失败");
}
}
return ipData;
}
}
......@@ -2,10 +2,12 @@ package com.pcloud.book.record.mapper;
import com.pcloud.book.record.entity.IpData;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper
@Component
public interface IpDataMapper {
int deleteByPrimaryKey(Long id);
......@@ -22,4 +24,5 @@ public interface IpDataMapper {
IpData selectByIp(String ip);
List<IpData> listCityByIp(List<String> ips);
}
\ No newline at end of file
package com.pcloud.book.record.mapper;
import com.pcloud.book.record.entity.RegionMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.MapKey;
......@@ -25,4 +27,6 @@ public interface RegionMapMapper {
@MapKey("regionCode")
Map<String, RegionMap> getCitysByCodes(List<String> cityCodes);
String getCitysByCode(@Param("cityCode") String cityCode);
}
\ No newline at end of file
......@@ -45,9 +45,11 @@ public interface RightsSettingBiz {
* 每周/长期权益查询
* @param rightsSettingId
* @param rightsType
* @param currentPage
* @param numPerPage
* @return
*/
List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType);
List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType, Integer currentPage, Integer numPerPage);
/**
* 小程序首页权益查询
......@@ -60,21 +62,27 @@ public interface RightsSettingBiz {
/**
* 小程序首页本周/长期权益查询
* @param cilentIp
* @param rightsSettingId
* @param wechatUserId
* @param rightsType
* @param currentPage
* @param numPerPage
* @return
*/
RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId);
RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType, Long bookId, Long adviserId, Long channelId, Integer currentPage, Integer numPerPage);
/**
* 每周/长期权益查询--小程序
* @param rightsSettingId
* @param rightsType
* @param wechatUserId
* @param cityCode
* @param currentPage
* @param numPerPage
* @return
*/
List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType, Long bookId, Long adviserId, Long channelId);
List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType, Long bookId, Long adviserId, Long channelId, String cityCode, Integer currentPage, Integer numPerPage);
/**
* 查所有权益分类
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.entity;
import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.common.entity.BaseEntity;
import com.pcloud.common.page.PageBeanNew;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
......
......@@ -10,6 +10,7 @@ import com.pcloud.common.entity.BaseEntity;
import java.util.Date;
import java.util.List;
import com.pcloud.common.page.PageBeanNew;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -61,6 +62,10 @@ public class RightsSettingItem extends BaseEntity {
* 资讯
*/
private List<AppletNewsDTO> appletNewsDTOS;
/**
* 咨询
*/
private PageBeanNew<AppletNewsDTO> appletNewsDTOS4Page;
@ApiModelProperty("本书阅读计划开关 0关闭 1开启")
private Integer isOpen;
......
......@@ -14,6 +14,7 @@ import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.nginx.NginxUtils;
import com.pcloud.common.utils.string.StringUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Min;
import java.util.List;
......@@ -130,13 +132,14 @@ public class RightsSettingFacede {
@RequestParam(value = "adviserId", required = false) Long adviserId,
@RequestParam(value = "channelId", required = false) Long channelId,
@RequestParam(value = "rightsType", required = false) String rightsType,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType
) {
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType,
@RequestParam(value = "currentPage",required = false) Integer currentPage,
@RequestParam(value = "numPerPage",required = false) Integer numPerPage) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == rightsSettingId || StringUtil.isEmpty(rightsType)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType, readType, bookId, adviserId, channelId));
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType, readType, bookId, adviserId, channelId, currentPage, numPerPage));
}
@ApiOperation("所有权益分类")
......
......@@ -32,12 +32,13 @@
<result column="business_card_id" property="businessCardId" jdbcType="BIGINT" />
<result column="business_card_type" property="businessCardType" jdbcType="TINYINT" />
<result column="business_card_isOpen" property="businessCardIsOpen" jdbcType="TINYINT" />
<result column="city_code" property="cityCode" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
news.id, news.news_name, news.source, news.news_classify_id, news.pro_label_id, news.dep_label_id, news.pur_label_id, news.type, news.digest,
pic1, pic2, pic3, news.content, show_state, news.create_time, news.update_time, news.first_classify, news.second_classify, news.grade_label_id, news.subject_label_id, news.rights_classify_id,
news.jump_type, news.jump_url, news.url_number, news.custom_tag_id, news.show_source, news.show_link,news.business_card_id,news.business_card_type,news.business_card_isOpen
news.jump_type, news.jump_url, news.url_number, news.custom_tag_id, news.show_source, news.show_link,news.business_card_id,news.business_card_type,news.business_card_isOpen,city_code
</sql>
<sql id="sql_news">
m.id,
......@@ -64,20 +65,21 @@
jumpUrl,
urlNumber,
showSource,
showLink
showLink,
cityCode
</sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletNews" useGeneratedKeys="true" keyProperty="id">
insert into applet_news(
news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest,
pic1, pic2, pic3, content, show_state, create_time, update_time , first_classify, second_classify, grade_label_id, subject_label_id, rights_classify_id,
jump_type, jump_url,url_number, custom_tag_id, show_source, show_link,business_card_id,business_card_type,business_card_isOpen
jump_type, jump_url,url_number, custom_tag_id, show_source, show_link,business_card_id,business_card_type,business_card_isOpen,city_code
)
values (
#{newsName}, #{source}, #{newsClassifyId}, #{proLabelId}, #{depLabelId}, #{purLabelId}, #{type}, #{digest},
#{pic1}, #{pic2}, #{pic3}, #{content}, #{showState}, NOW(), NOW(), #{firstClassify,jdbcType=BIGINT}, #{secondClassify,jdbcType=BIGINT},
#{gradeLabelId,jdbcType=BIGINT}, #{subjectLabelId,jdbcType=BIGINT}, #{rightsClassifyId,jdbcType=BIGINT},
#{jumpType}, #{jumpUrl}, #{urlNumber}, #{customTagId}, #{showSource}, #{showLink}, #{businessCardId}, #{businessCardType}, #{businessCardIsOpen}
#{jumpType}, #{jumpUrl}, #{urlNumber}, #{customTagId}, #{showSource}, #{showLink}, #{businessCardId}, #{businessCardType}, #{businessCardIsOpen}, #{cityCode}
)
</insert>
......@@ -121,6 +123,9 @@
<if test="showLink != null">
show_link = #{showLink},
</if>
<if test="cityCode != null">
city_code = #{cityCode},
</if>
jump_url = #{jumpUrl},
url_number = #{urlNumber},
business_card_id = #{businessCardId},
......@@ -214,6 +219,7 @@
n.jump_url jumpUrl,
n.url_number urlNumber,
n.custom_tag_id customTagId,
n.city_code cityCode,
t.custom_tag customTag,
IF(n.business_card_id is null,2,n.business_card_isOpen) businessCardIsOpen
FROM applet_news n
......@@ -224,8 +230,19 @@
LEFT JOIN applet_news_category category on n.id = category.applet_news_id
</if>
WHERE 1=1
<if test="cityCode != null">
AND n.city_code = #{cityCode}
</if>
<if test="name != null">
AND (n.news_name LIKE CONCAT("%",#{name},"%") OR n.url_number LIKE CONCAT("%",#{name},"%"))
AND (n.news_name LIKE CONCAT("%",#{name},"%")
OR n.url_number LIKE CONCAT("%",#{name},"%")
<if test="cityCodes != null">
OR n.city_code IN
<foreach collection="cityCodes" item="item" open="(" close=")" separator=",">
${item}
</foreach>
</if>
)
</if>
<if test="newsClassifyId >0">
AND n.news_classify_id = #{newsClassifyId}
......@@ -363,6 +380,7 @@
<if test="newsClassifyId != null">
news_classify_id = #{newsClassifyId},
</if>
city_code = #{cityCode},
update_time=NOW()
WHERE id IN
<foreach collection="ids" item="item" separator="," open="(" close=")">
......@@ -737,7 +755,8 @@
n.jump_url jumpUrl,
n.url_number urlNumber,
n.show_source showSource,
n.show_link showLink
n.show_link showLink,
n.city_code cityCode
FROM
applet_news n
LEFT JOIN rights_setting_item_detail d ON d.serve_id = n.id
......@@ -776,6 +795,7 @@
news_name, source, news_classify_id, pro_label_id, dep_label_id, pur_label_id, type, digest,
pic1, pic2, pic3, content, show_state, create_time, update_time , first_classify, second_classify, grade_label_id,
subject_label_id, rights_classify_id,
city_code,
jump_type, jump_url,url_number, custom_tag_id, show_source, show_link
)
values
......@@ -785,6 +805,7 @@
#{item.pic1}, #{item.pic2}, #{item.pic3}, #{item.content}, #{item.showState}, NOW(), NOW(), #{item.firstClassify,jdbcType=BIGINT},
#{item.secondClassify,jdbcType=BIGINT},
#{item.gradeLabelId,jdbcType=BIGINT}, #{item.subjectLabelId,jdbcType=BIGINT}, #{item.rightsClassifyId,jdbcType=BIGINT},
#{item.cityCode},
#{item.jumpType}, #{item.jumpUrl}, #{item.urlNumber}, #{item.customTagId}, #{item.showSource}, #{item.showLink}
)
</foreach>
......@@ -807,4 +828,38 @@
</if>
</select>
<select id="listNewsByCityCode" resultType="com.pcloud.book.applet.dto.AppletNewsDTO">
SELECT
n.id,
n.news_name newsName,
n.source,
n.news_classify_id newsClassifyId,
n.pro_label_id proLabelId,
n.dep_label_id depLabelId,
n.pur_label_id purLabelId,
n.type,
n.digest,
n.pic1,
n.pic2,
n.pic3,
n.show_state showState,
n.create_time createTime,
n.first_classify firstClassify,
n.second_classify secondClassify,
n.grade_label_id gradeLabelId,
n.subject_label_id subjectLabelId,
n.rights_classify_id rightsClassifyId,
n.jump_type jumpType,
n.jump_url jumpUrl,
n.url_number urlNumber,
n.show_source showSource,
n.city_code cityCode,
n.show_link showLink
FROM applet_news n
WHERE n.show_state = 1
AND n.city_code = #{cityId}
ORDER BY n.update_time DESC
</select>
</mapper>
......@@ -141,4 +141,5 @@
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -43,7 +43,7 @@
#{item}
</foreach>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from region_map
where id = #{id,jdbcType=BIGINT}
</delete>
......@@ -138,4 +138,8 @@
short_name = #{shortName,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getCitysByCode" resultType="java.lang.String">
select region_name from region_map where region_code =#{cityCode}
</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