Commit ae3d58a8 by Administrator

Merge branch 'feature/1002988' into 'master'

feat: [1002988] 书刊数据地图

See merge request rays/pcloud-book!772
parents 7e736d73 11a48f14
......@@ -349,4 +349,8 @@ public class BookConstant {
public static final Long[] TEST_ADVISERS = new Long[]{1404L,1001195L};
public static final String HANZI = "哈或";
public static final String countryRegionCode = "100000";
public static final Integer countryAreaCode = 0;
}
package com.pcloud.book.record.entity;
import com.pcloud.common.entity.BaseEntity;
import java.util.Date;
import lombok.Data;
@Data
public class BookBrowseRecord extends BaseEntity {
private Long sceneId;
private Long bookId;
private Long bookAdviserId;
private String bookName;
private Long adviserId;
private Long agentId;
private String isbn;
private Long userId;
private String province;
private String provinceCode;
private String city;
private String cityCode;
private String district;
private String districtCode;
private Long graLabelId;
private Long subLabelId;
private Long firstClassifyId;
private Long secondClassifyId;
private Long bookClassifyId;
private String ip;
}
\ No newline at end of file
package com.pcloud.book.record.service.impl;
import com.aliyun.oss.HttpMethod;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.common.dto.ResponseDto;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(value = "pcloud-service-book", qualifier = "bookBrowseRecordPcloud", path = "book/v1.0/bookBrowseRecordService")
public interface BookBrowseRecordService {
@RequestMapping(value = "addBookRecord", method = RequestMethod.POST)
public void addBookRecord(@RequestBody BookBrowseRecord bookBrowseRecord);
}
......@@ -8,6 +8,7 @@ import com.pcloud.book.applet.entity.AppletBookClassify;
import com.pcloud.book.applet.entity.AppletUserLabelRelation;
import java.util.List;
import java.util.Map;
/**
* 小程序书刊分类
......@@ -110,4 +111,14 @@ public interface AppletBookClassifyBiz {
* * @param null
*/
List<AssistTempletDTO> getChildTempletList(Long appletBookClassifyId);
/**
* 根据一级分类id获取书籍分类id
* @param firstClassifyId
* @return
*/
Long getAppletBookClassifyId(Long firstClassifyId);
Map<Long, AppletBookClassifyDTO> getBookClassifyByIds(List<Long> bookAdviserIds);
}
......@@ -273,4 +273,14 @@ public class AppletBookClassifyBizImpl implements AppletBookClassifyBiz {
return assistTempletConsr.getChildTempletList(templetIds);
}
@Override
public Long getAppletBookClassifyId(Long firstClassifyId) {
return appletBookClassifyDao.getAppletBookClassifyId(firstClassifyId);
}
@Override
public Map<Long, AppletBookClassifyDTO> getBookClassifyByIds(List<Long> bookAdviserIds) {
return appletBookClassifyDao.getBookClassifyByIds(bookAdviserIds);
}
}
......@@ -6,6 +6,7 @@ import com.pcloud.book.applet.entity.AppletBookClassify;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* 小程序客户端书刊分类(AppletBookClassify)表数据库访问层
......@@ -46,4 +47,13 @@ public interface AppletBookClassifyDao extends BaseDao<AppletBookClassify>{
* * @param null
*/
List<Long> getRelationBookTempletByBookClassify(Long bookClassifyId);
/**
* 根据一级分类id获取书籍分类id
* @param firstClassifyId
* @return
*/
Long getAppletBookClassifyId(Long firstClassifyId);
Map<Long, AppletBookClassifyDTO> getBookClassifyByIds(List<Long> bookAdviserIds);
}
\ No newline at end of file
......@@ -43,4 +43,13 @@ public class AppletBookClassifyDaoImpl extends BaseDaoImpl<AppletBookClassify> i
public List<Long> getRelationBookTempletByBookClassify(Long bookClassifyId) {
return getSessionTemplate().selectList(getStatement("getRelationBookTempletByBookClassify"), bookClassifyId);
}
@Override
public Long getAppletBookClassifyId(Long firstClassifyId) {
return getSessionTemplate().selectOne(getStatement("getAppletBookClassifyId"), firstClassifyId);
}
@Override
public Map<Long, AppletBookClassifyDTO> getBookClassifyByIds(List<Long> bookAdviserIds) {
return getSessionTemplate().selectMap(getStatement("getBookClassifyByIds"),bookAdviserIds,"id"); }
}
......@@ -261,4 +261,6 @@ public interface BookAdviserDao extends BaseDao<BookAdviser> {
* @return
*/
BookAdviserDto getOneMainBook(Long bookId);
Map<Long, BookAdviserDto> getByBookAdviserIds(List<Long> bookAdviserIds);
}
......@@ -263,4 +263,10 @@ public class BookAdviserDaoImpl extends BaseDaoImpl<BookAdviser> implements Book
public BookAdviserDto getOneMainBook(Long bookId) {
return getSessionTemplate().selectOne(getStatement("getOneMainBook"),bookId);
}
@Override
public Map<Long, BookAdviserDto> getByBookAdviserIds(List<Long> bookAdviserIds) {
return super.getSqlSession().selectMap(this.getStatement("getByBookAdviserIds"), bookAdviserIds, "bookAdviserId");
}
}
......@@ -4,6 +4,7 @@
package com.pcloud.book.consumer.user;
import com.pcloud.channelcenter.base.exceptions.ChannelBizException;
import com.pcloud.channelcenter.qrcode.service.QrcodeSceneService;
import com.pcloud.channelcenter.wechat.service.MessageService;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
......@@ -34,6 +35,8 @@ public class ChannelConsr {
private ChannelService channelService;
@Autowired
private MessageService messageService;
@Autowired
private QrcodeSceneService qrcodeSceneService;
/**
* 获取渠道名称
......@@ -141,4 +144,19 @@ public class ChannelConsr {
throw new ChannelBizException(ChannelBizException.PARAM_IS_NULL, "运营不存在");
}
}
public Long getBookId4SceneId(Long sceneId) {
Long bookId = null;
LOGGER.info("根据sceneId获取bookId,<START>.[sceneId]=" + sceneId);
try {
bookId = ResponseHandleUtil.parseResponse(qrcodeSceneService.getBookId4SceneId(sceneId), Long.class);
if (null == bookId) {
throw new ChannelBizException(ChannelBizException.PARAM_IS_NULL, "bookId为空");
}
return bookId;
} catch (Exception e) {
LOGGER.error("根据sceneId获取bookId" + e.getMessage(), e);
throw new ChannelBizException(ChannelBizException.PARAM_IS_NULL, "bookId为空");
}
}
}
......@@ -60,7 +60,6 @@ import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
......@@ -794,9 +793,10 @@ public interface BookGroupBiz {
/**
* 获取小程序码
* @param bookGroupId
* @param requestIp
* @return
*/
public BookAppletSceneDTO getBookGroupAppletByBookGroupId(Long bookGroupId);
public BookAppletSceneDTO getBookGroupAppletByBookGroupId(Long bookGroupId, String requestIp);
/**
* 更新小睿分类
......
......@@ -159,6 +159,8 @@ import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.push.enums.AltTypeEnum;
import com.pcloud.book.reading.dao.ReadingUserDao;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
......@@ -403,6 +405,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
private AppletUserBookcaseBiz appletUserBookcaseBiz;
@Autowired
private AppletGroupSearchRecordBiz appletGroupSearchRecordBiz;
@Autowired
private BookBrowseRecordBiz bookBrowseRecordBiz;
private static final ThreadPoolExecutor PLATFORM_STATISTICS_EXPORT_THREAD = new ThreadPoolExecutor(2, 2,
0, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
......@@ -4782,13 +4786,18 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
@Override
public BookAppletSceneDTO getBookGroupAppletByBookGroupId( Long bookGroupId ) {
public BookAppletSceneDTO getBookGroupAppletByBookGroupId(Long bookGroupId, String requestIp) {
BookAppletScene bookAppletScene = bookAppletSceneDao.getByBookGroupId(bookGroupId);
BookAppletSceneDTO dto = new BookAppletSceneDTO();
if (null != bookAppletScene) {
BeanUtils.copyProperties(bookAppletScene, dto);
}
BookGroupDTO bookGroupDTO = bookGroupDao.getBookBaseInfoById(bookGroupId);
// 新增埋点
BookBrowseRecord bookBrowseRecord = new BookBrowseRecord();
bookBrowseRecord.setBookId(bookGroupDTO.getBookId());
bookBrowseRecord.setIp(requestIp);
bookBrowseRecordBiz.addBookRecord4BookId(bookBrowseRecord);
if (bookGroupDTO.getOpenWeapp()) {//1v1走小睿流程
return dto;
} else {
......
......@@ -337,4 +337,5 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
*/
Map<Long,BookGroupDTO> mapDTOByIds(List<Long> ids);
Map<Long, BookGroupDTO> getBookBaseInfoByAdviserBookIds(List<Long> bookAdviserId);
}
......@@ -411,4 +411,9 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
map.put("list",ids);
return getSessionTemplate().selectMap(getStatement("mapDTOByIds"),map,"id");
}
@Override
public Map<Long, BookGroupDTO> getBookBaseInfoByAdviserBookIds(List<Long> bookAdviserIds) {
return getSessionTemplate().selectMap(getStatement("getBookBaseInfoByAdviserBookIds"),bookAdviserIds,"bookAdviserId");
}
}
......@@ -315,6 +315,16 @@ public class BookGroupDTO extends BaseDto {
private Long adviserId;
private Long bookAdviserId;
public Long getBookAdviserId() {
return bookAdviserId;
}
public void setBookAdviserId(Long bookAdviserId) {
this.bookAdviserId = bookAdviserId;
}
public Long getAdviserId() {
return adviserId;
}
......
......@@ -22,6 +22,7 @@ import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import javax.servlet.http.HttpServletRequest;
import org.codehaus.jackson.JsonParseException;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.CookieValue;
......@@ -74,7 +75,7 @@ public interface BookGroupFacade {
@ApiImplicitParam(name = "bookGroupId", value = "群二维码ID", dataType = "long", paramType = "query")
})
@RequestMapping(value = "getBookGroupInfo4Wechat", method = RequestMethod.GET)
ResponseDto<?> getBookGroupInfo4Wechat(@RequestParam(value = "bookGroupId", required = false) Long bookGroupId)
ResponseDto<?> getBookGroupInfo4Wechat(@RequestParam(value = "bookGroupId", required = false) Long bookGroupId, HttpServletRequest request)
throws BizException, PermissionException, JsonParseException;
@ApiOperation(value = "获取社群书群二维码信息", httpMethod = "GET")
......@@ -700,7 +701,8 @@ public interface BookGroupFacade {
@ApiOperation("根据获取社群书小程序信息")
@ApiImplicitParam(name = "bookGroupId", value = "bookGroupId", required = true, dataType = "long", paramType = "query")
@GetMapping("getBookGroupAppletByBookGroupId")
ResponseDto<BookAppletSceneDTO> getBookGroupAppletByBookGroupId(@RequestParam("bookGroupId") Long bookGroupId);
ResponseDto<BookAppletSceneDTO> getBookGroupAppletByBookGroupId(@RequestParam("bookGroupId") Long bookGroupId,
HttpServletRequest request);
@ApiOperation("根据临时书刊id获取社群书id")
@ApiImplicitParam(name = "raysBookId", value = "临时书刊id", required = true, dataType = "long", paramType = "query")
......
......@@ -3,6 +3,7 @@ package com.pcloud.book.group.facade.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.biz.BookGroupClassifyBiz;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dto.BookAppletSceneDTO;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.ChangeQrCodeTypeDto;
......@@ -29,6 +30,8 @@ import com.pcloud.book.group.vo.UpdateRankTypeVO;
import com.pcloud.book.group.vo.UserBookInfoVO;
import com.pcloud.book.group.vo.WxGroupStatisticVO;
import com.pcloud.book.keywords.vo.ListKeywordVO;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
......@@ -38,10 +41,12 @@ import com.pcloud.common.page.PageParam;
import com.pcloud.common.permission.PermissionException;
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 com.pcloud.wechatgroup.base.exception.WechatGroupBizException;
import com.pcloud.wechatgroup.message.enums.IsSystem;
import javax.servlet.http.HttpServletRequest;
import org.codehaus.jackson.JsonParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -78,6 +83,10 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
private BookGroupBiz bookGroupBiz;
@Autowired
private BookGroupClassifyBiz bookGroupClassifyBiz;
@Autowired
private BookGroupDao bookGroupDao;
@Autowired
private BookBrowseRecordBiz bookBrowseRecordBiz;
@SneakyThrows
@PostMapping("updateNoISBNBookGeneratorQrcode")
......@@ -118,11 +127,18 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
*/
@Override
@RequestMapping(value = "getBookGroupInfo4Wechat", method = RequestMethod.GET)
public ResponseDto<?> getBookGroupInfo4Wechat( @RequestParam(value = "bookGroupId", required = false) Long bookGroupId )
public ResponseDto<?> getBookGroupInfo4Wechat( @RequestParam(value = "bookGroupId", required = false) Long bookGroupId, HttpServletRequest request)
throws BizException, PermissionException, JsonParseException {
if (null == bookGroupId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数有误!");
}
String requestIp = NginxUtils.getClientIp(request);
// 新增埋点
BookBrowseRecord bookBrowseRecord = new BookBrowseRecord();
BookGroupDTO bookGroupDTO = bookGroupDao.getBookBaseInfoById(bookGroupId);
bookBrowseRecord.setBookId(bookGroupDTO.getBookId());
bookBrowseRecord.setIp(requestIp);
bookBrowseRecordBiz.addBookRecord4BookId(bookBrowseRecord);
return new ResponseDto<>(bookGroupBiz.getBookGroupInfo4Wechat(bookGroupId));
}
......@@ -1131,11 +1147,12 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
@Override
@GetMapping("getBookGroupAppletByBookGroupId")
public ResponseDto<BookAppletSceneDTO> getBookGroupAppletByBookGroupId( @RequestParam("bookGroupId") Long bookGroupId ) {
public ResponseDto<BookAppletSceneDTO> getBookGroupAppletByBookGroupId( @RequestParam("bookGroupId") Long bookGroupId, HttpServletRequest request) {
if (null == bookGroupId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "bookGroupId不能为空!");
}
return new ResponseDto<>(bookGroupBiz.getBookGroupAppletByBookGroupId(bookGroupId));
String requestIp = NginxUtils.getClientIp(request);
return new ResponseDto<>(bookGroupBiz.getBookGroupAppletByBookGroupId(bookGroupId, requestIp));
}
@Override
......
package com.pcloud.book.record.biz;
import com.pcloud.book.record.entity.AreaStatistics;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.book.record.entity.BookDetail;
import com.pcloud.book.record.entity.BookDetailDTO;
import com.pcloud.book.record.entity.BookMapStatistics;
import com.pcloud.book.record.entity.MapData;
import com.pcloud.book.record.entity.RegionMap;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import java.util.List;
import java.util.Map;
public interface BookBrowseRecordBiz {
void addBookRecord(BookBrowseRecord bookBrowseRecord);
void addBookRecord4BookId(BookBrowseRecord bookBrowseRecord);
List<BookMapStatistics> getBookCount4Country(String regionCode);
AreaStatistics getAreaStatistics(String regionCode, Integer areaCode);
PageBeanNew<BookDetail> getBookDetail(String regionCode, Integer areaCode, PageParam pageParam,
String bookName, Long agentId, Long bookClassifyId);
void addJsonData();
PageBeanNew<MapData> getJsonData(String regionCode, Integer currentPage, Integer numPerPage);
Map<String, List<RegionMap>> getCitysByPY(String keyword);
void handleOldData();
}
package com.pcloud.book.record.biz.impl;
import com.pcloud.book.applet.biz.AppletBookClassifyBiz;
import com.pcloud.book.applet.dto.AppletBookClassifyDTO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookAdviserDao;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dto.BookAdviserDto;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.consumer.analysisengine.BookScanCountConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.consumer.user.AgentConsr;
import com.pcloud.book.consumer.user.BookcaseConsr;
import com.pcloud.book.consumer.user.ChannelConsr;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
import com.pcloud.book.record.dao.BookBrowseRecordDAO;
import com.pcloud.book.record.dao.MapDataDAO;
import com.pcloud.book.record.entity.AreaStatistics;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.book.record.entity.BookDetail;
import com.pcloud.book.record.entity.BookDetailDTO;
import com.pcloud.book.record.entity.BookMapStatistics;
import com.pcloud.book.record.entity.ClassifyStatistics;
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.entity.MapData;
import com.pcloud.book.record.entity.RegionMap;
import com.pcloud.book.record.mapper.IpDataMapper;
import com.pcloud.book.record.mapper.RegionMapMapper;
import com.pcloud.book.util.common.HttpUtils;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.json.JSONUtils;
import com.pcloud.common.utils.string.StringUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @ClassName com.pcloud.book.record.biz.impl.BookBrowseRecordBizImpl
* @Author 吴博
* @Description 读者书籍埋点记录
* @Date 2020/6/12 16:04
* @Version 1.0
**/
@Service
@Slf4j
public class BookBrowseRecordBizImpl implements BookBrowseRecordBiz {
@Autowired
private ChannelConsr channelConsr;
@Autowired
private BookAdviserDao bookAdviserDao;
@Autowired
private BookBrowseRecordDAO bookBrowseRecordDAO;
@Autowired
private AppletBookClassifyBiz appletBookClassifyBiz;
@Autowired
private BookDao bookDao;
@Autowired
private AdviserConsr adviserConsr;
@Autowired
private BookGroupDao bookGroupDao;
@Autowired
private MapDataDAO mapDataDAO;
@Autowired
private AgentConsr agentConsr;
@Autowired
private RegionMapMapper regionMapMapper;
@Autowired
private IpDataMapper ipDataMapper;
@Autowired
private BookScanCountConsr bookScanCountConsr;
@Override
@ParamLog("读者书籍埋点记录")
public void addBookRecord(BookBrowseRecord bookBrowseRecord) {
Long sceneId = bookBrowseRecord.getSceneId();
if (null == sceneId) {
return;
}
// 先判断书籍是否存在
Long bookId = channelConsr.getBookId4SceneId(sceneId);
if (null == bookId) {
return;
}
bookBrowseRecord.setBookId(bookId);
addBookRecord4BookId(bookBrowseRecord);
}
@Override
@ParamLog("读者书籍埋点记录")
public void addBookRecord4BookId(BookBrowseRecord bookBrowseRecord) {
BookAdviserDto bookAdviserDto = bookAdviserDao.getOneMainBook(bookBrowseRecord.getBookId());
BookDto bookDto = bookDao.getBaseById(bookBrowseRecord.getBookId());
if (null == bookAdviserDto || null == bookDto) {
return;
}
Long agentId = null;
bookBrowseRecord.setBookAdviserId(bookAdviserDto.getBookAdviserId());
bookBrowseRecord.setBookName(bookDto.getBookName());
bookBrowseRecord.setIsbn(bookDto.getIsbn());
if (null != bookAdviserDto.getAdviserId()) {
agentId = adviserConsr.getAgentIdByAdviser(bookAdviserDto.getAdviserId());
}
bookBrowseRecord.setAdviserId(bookAdviserDto.getAdviserId());
bookBrowseRecord.setAgentId(agentId);
Long firstClassifyId = null == bookAdviserDto.getTempletId() ? 0 : bookAdviserDto.getTempletId();
Long secondClassifyId = null == bookAdviserDto.getSecondTempletId() ? 0 : bookAdviserDto.getSecondTempletId();
Long graLabelId = null == bookAdviserDto.getGraLabelId() ? 0 : bookAdviserDto.getGraLabelId();
Long subLabelId = null == bookAdviserDto.getSubLabelId() ? 0 : bookAdviserDto.getSubLabelId();
Long bookClassifyId = null;
// 根据一级分类id获取书籍分类id
if (Objects.equals(0, firstClassifyId)) {
bookClassifyId = 0L;
} else {
bookClassifyId = appletBookClassifyBiz.getAppletBookClassifyId(firstClassifyId);
}
bookBrowseRecord.setFirstClassifyId(firstClassifyId);
bookBrowseRecord.setSecondClassifyId(secondClassifyId);
bookBrowseRecord.setGraLabelId(graLabelId);
bookBrowseRecord.setSubLabelId(subLabelId);
bookBrowseRecord.setBookClassifyId(bookClassifyId);
// 根据ip获取省份和城市
getAreaByIP(bookBrowseRecord);
log.info("插入的数据是:{}", bookBrowseRecord);
if (null == bookBrowseRecord || StringUtil.isEmpty(bookBrowseRecord.getCityCode())){
return;
}
bookBrowseRecordDAO.insert(bookBrowseRecord);
}
@Override
@ParamLog("获取全国的书刊统计数据")
public List<BookMapStatistics> getBookCount4Country(String regionCode) {
return bookBrowseRecordDAO.getBookCount4Country(regionCode);
}
@Override
@ParamLog("获取某个地区的分类统计信息")
public AreaStatistics getAreaStatistics(String regionCode, Integer areaCode) {
AreaStatistics areaStatistics = bookBrowseRecordDAO.getAreaStatistics(regionCode, areaCode);
if (null == areaStatistics) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"数据库没有数据");
}
List<ClassifyStatistics> classifyStatisticsList = bookBrowseRecordDAO.getClassifyStatistics(regionCode, areaCode);
areaStatistics.setClassifyStatisticsList(classifyStatisticsList);
return areaStatistics;
}
@Override
@ParamLog(value = "获取区域详情", isAfterReturn = false)
public PageBeanNew<BookDetail> getBookDetail(String regionCode, Integer areaCode, PageParam pageParam,
String bookName, Long agentId, Long bookClassifyId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("regionCode", regionCode);
paramMap.put("areaCode", areaCode);
paramMap.put("bookName", bookName);
paramMap.put("agentId", agentId);
paramMap.put("bookClassifyId", bookClassifyId);
PageBeanNew<BookDetail> pageBeanNew = bookBrowseRecordDAO.listPageNew(pageParam, paramMap, "getBookDetail");
if (null != pageBeanNew && !ListUtils.isEmpty(pageBeanNew.getRecordList())) {
List<BookDetail> bookDetails = pageBeanNew.getRecordList();
List<Long> bookAdviserIds = bookDetails.stream().map(e -> e.getBookAdviserId()).collect(Collectors.toList());
List<Long> bookClassifyIds = bookDetails.stream().map(e -> e.getBookClassifyId()).collect(Collectors.toList());
List<Long> adviserIds = bookDetails.stream().map(e -> e.getAdviserId()).collect(Collectors.toList());
List<Long> agentIds = bookDetails.stream().map(e -> e.getAgentId()).collect(Collectors.toList());
if (ListUtils.isEmpty(bookAdviserIds)) {
return new PageBeanNew<>(pageParam.getPageNum(), pageBeanNew.getNumPerPage(), new ArrayList<>());
}
//获取书刊社群相关信息
Map<Long, BookGroupDTO> bookGroupDTOMap = bookGroupDao.getBookBaseInfoByAdviserBookIds(bookAdviserIds);
//获取分类标签
Map<Long, AppletBookClassifyDTO> appletBookClassifyDTOMap = new HashMap<>();
if (!ListUtils.isEmpty(bookClassifyIds)) {
appletBookClassifyDTOMap = appletBookClassifyBiz.getBookClassifyByIds(bookClassifyIds);
}
//获取编辑以及出版社名称
Map<Long, String> adviserMap = new HashMap<>();
Map<Long, String> agentMap = new HashMap<>();
if (!ListUtils.isEmpty(adviserIds)){
adviserMap = adviserConsr.getNames(adviserIds);
}
if (!ListUtils.isEmpty(agentIds)) {
agentMap = agentConsr.getNames(agentIds);
}
for (BookDetail bookDetail : bookDetails) {
if (MapUtils.isNotEmpty(bookGroupDTOMap) && bookGroupDTOMap.containsKey(bookDetail.getBookAdviserId())
&& null != bookGroupDTOMap.get(bookDetail.getBookAdviserId())) {
BookGroupDTO bookGroupDTO = bookGroupDTOMap.get(bookDetail.getBookAdviserId());
bookDetail.setBookGroupName(bookGroupDTO.getGroupQrcodeName());
bookDetail.setCreateTime(bookGroupDTO.getCreateTime());
bookDetail.setBookGroupUrl(bookGroupDTO.getGroupQrcodeUrl());
}
if (MapUtils.isNotEmpty(adviserMap) && adviserMap.containsKey(bookDetail.getAdviserId())
&& null != adviserMap.get(bookDetail.getAdviserId())) {
bookDetail.setAdviserName(adviserMap.get(bookDetail.getAdviserId()));
}
if (MapUtils.isNotEmpty(agentMap) && agentMap.containsKey(bookDetail.getAgentId())
&& null != agentMap.get(bookDetail.getAgentId())) {
bookDetail.setAgentName(agentMap.get(bookDetail.getAgentId()));
}
if (MapUtils.isNotEmpty(appletBookClassifyDTOMap) && appletBookClassifyDTOMap.containsKey(bookDetail.getBookClassifyId())
&& null != appletBookClassifyDTOMap.get(bookDetail.getBookClassifyId())) {
bookDetail.setBookClassifyName(appletBookClassifyDTOMap.get(bookDetail.getBookClassifyId()).getClassifyName());
}
}
}
return pageBeanNew;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addJsonData() {
String filepath = "C:\\Users\\Administrator\\Documents\\WXWork\\1688851019478260\\Cache\\File\\2020-06\\coordinate\\coordinate";
List<MapData> mapDatas = new ArrayList<>();
File file = new File(filepath);
if (!file.isDirectory()) {
System.out.println("文件");
System.out.println("path=" + file.getPath());
System.out.println("absolutepath=" + file.getAbsolutePath());
System.out.println("name=" + file.getName());
} else if (file.isDirectory()) {
System.out.println("文件夹");
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
File readfile = new File(filepath + "\\" + filelist[i]);
String fileName = readfile.getName();
String[] fileNames = fileName.split("\\.");
String code = fileNames[0];
StringBuilder line= new StringBuilder();
try{
BufferedReader in=new BufferedReader(new FileReader(readfile.getAbsolutePath()));
while(in.readLine() != null){
line.append(in.readLine());
}
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch(IOException e){
e.printStackTrace();
}
MapData mapData = new MapData();
mapData.setRegionCode(code);
mapData.setContent(line.toString());
mapDatas.add(mapData);
mapDataDAO.insert(mapData);
}
}
}
@Override
public PageBeanNew<MapData> getJsonData(String regionCode, Integer currentPage, Integer numPerPage) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("regionCode", regionCode);
return mapDataDAO.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "getJsonData");
}
@Override
@ParamLog("获取地图数据")
public Map<String, List<RegionMap>> getCitysByPY(String keyword) {
List<RegionMap> regionMaps = regionMapMapper.getCitysByPY(keyword);
Map<String, List<RegionMap>> regionMap = new HashMap<>();
if (!ListUtils.isEmpty(regionMaps)){
regionMap = regionMaps.stream().collect(Collectors.groupingBy(RegionMap::getAlphabet));
}
return regionMap;
}
@Override
@ParamLog("处理旧的书刊读者数据")
public void handleOldData() {
}
private void getAreaByIP(BookBrowseRecord bookBrowseRecord) {
String host = "https://api01.aliyun.venuscn.com";
String path = "/ip";
String method = "GET";
String appcode = "7936c69d4d0943f398bc73b3b3406fe2";
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode);
Map<String, String> querys = new HashMap<String, String>();
querys.put("ip", bookBrowseRecord.getIp());
//先从数据库查询,没有再查询第三方
IpData ipData = ipDataMapper.selectByIp(bookBrowseRecord.getIp());
if (null == ipData) {
try {
HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
log.info("查询ip返回的数据是response:{}", response);
String entityString = EntityUtils.toString(response.getEntity());
IpResponse ipResponse = null;
if (StringUtil.isEmpty(entityString)) {
return;
}
ipResponse = JSONUtils.jsonToBean(entityString, IpResponse.class);
if (null == ipResponse || null == ipResponse.getData()) {
return;
}
IpData4Third ipData4Third = ipResponse.getData();
if (!Objects.equals("200", ipResponse.getRet())) {
return;
}
if (null == ipData4Third || null == ipData4Third.getCity_id()) {
return;
}
ipData = new IpData();
ipData.setIp(bookBrowseRecord.getIp());
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:{}", bookBrowseRecord.getIp());
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "获取ip失败");
}
}
bookBrowseRecord.setProvince(ipData.getRegion());
bookBrowseRecord.setProvinceCode(ipData.getRegionId());
bookBrowseRecord.setCity(ipData.getCity());
bookBrowseRecord.setCityCode(ipData.getCityId());
}
}
\ No newline at end of file
package com.pcloud.book.record.dao;
import com.pcloud.book.record.entity.AreaStatistics;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.book.record.entity.BookMapStatistics;
import com.pcloud.book.record.entity.ClassifyStatistics;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
public interface BookBrowseRecordDAO extends BaseDao<BookBrowseRecord> {
int deleteByPrimaryKey(Long id);
int insertSelective(BookBrowseRecord record);
BookBrowseRecord selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(BookBrowseRecord record);
int updateByPrimaryKey(BookBrowseRecord record);
List<BookMapStatistics> getBookCount4Country(String regionCode);
AreaStatistics getAreaStatistics(String regionCode, Integer areaCode);
List<ClassifyStatistics> getClassifyStatistics(String regionCode, Integer areaCode);
void getBookDetail(Map<String, Object> paramMap);
}
package com.pcloud.book.record.dao;
import com.pcloud.book.record.entity.MapData;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
public interface MapDataDAO extends BaseDao<MapData> {
MapData selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(MapData record);
int updateByPrimaryKeyWithBLOBs(MapData record);
int updateByPrimaryKey(MapData record);
}
\ No newline at end of file
package com.pcloud.book.record.dao.impl;
import com.pcloud.book.record.dao.BookBrowseRecordDAO;
import com.pcloud.book.record.entity.AreaStatistics;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.book.record.entity.BookMapStatistics;
import com.pcloud.book.record.entity.ClassifyStatistics;
import com.pcloud.common.core.dao.BaseDaoImpl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
/**
* @ClassName com.pcloud.book.record.dao.impl.BookBrowseRecordDAOImpl
* @Author 吴博
* @Description 书刊浏览记录DAO
* @Date 2020/6/16 10:49
* @Version 1.0
**/
@Repository("bookBrowseRecord")
public class BookBrowseRecordDAOImpl extends BaseDaoImpl<BookBrowseRecord> implements BookBrowseRecordDAO {
@Override
public int deleteByPrimaryKey(Long id) {
return getSessionTemplate().delete(getStatement("deleteByPrimaryKey"), id);
}
@Override
public int insertSelective(BookBrowseRecord record) {
return getSessionTemplate().insert(getStatement("insertSelective"), record);
}
@Override
public BookBrowseRecord selectByPrimaryKey(Long id) {
return getSessionTemplate().selectOne(getStatement("selectByPrimaryKey"),id);
}
@Override
public int updateByPrimaryKeySelective(BookBrowseRecord record) {
return getSessionTemplate().update(getStatement("updateByPrimaryKeySelective"), record);
}
@Override
public int updateByPrimaryKey(BookBrowseRecord record) {
return getSessionTemplate().update(getStatement("updateByPrimaryKey"), record);
}
@Override
public List<BookMapStatistics> getBookCount4Country(String regionCode) {
return getSessionTemplate().selectList(getStatement("getBookCount4Country"), regionCode);
}
@Override
public AreaStatistics getAreaStatistics(String regionCode, Integer areaCode) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("regionCode", regionCode);
paramMap.put("areaCode", areaCode);
return getSessionTemplate().selectOne(getStatement("getAreaStatistics"), paramMap);
}
@Override
public List<ClassifyStatistics> getClassifyStatistics(String regionCode, Integer areaCode) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("regionCode", regionCode);
paramMap.put("areaCode", areaCode);
return getSessionTemplate().selectList(getStatement("getClassifyStatistics"), paramMap);
}
@Override
public void getBookDetail(Map<String, Object> paramMap) {
getSessionTemplate().selectList(getStatement("getBookDetail"), paramMap);
}
}
\ No newline at end of file
package com.pcloud.book.record.dao.impl;
import com.pcloud.book.record.dao.MapDataDAO;
import com.pcloud.book.record.entity.MapData;
import com.pcloud.common.core.dao.BaseDaoImpl;
import java.util.List;
import org.springframework.stereotype.Repository;
/**
* @ClassName com.pcloud.book.record.dao.impl.MapDataDAOImpl
* @Author 吴博
* @Description 地图渲染数据
* @Date 2020/6/16 16:22
* @Version 1.0
**/
@Repository("mapDataDAO")
public class MapDataDAOImpl extends BaseDaoImpl<MapData> implements MapDataDAO {
@Override
public MapData selectByPrimaryKey(Long id) {
return null;
}
@Override
public int updateByPrimaryKeySelective(MapData record) {
return 0;
}
@Override
public int updateByPrimaryKeyWithBLOBs(MapData record) {
return 0;
}
@Override
public int updateByPrimaryKey(MapData record) {
return 0;
}
}
\ No newline at end of file
package com.pcloud.book.record.entity;
import java.util.List;
import lombok.Data;
/**
* @ClassName com.pcloud.book.record.entity.ClassifyStatistics
* @Author 吴博
* @Description 书刊分类统计
* @Date 2020/6/15 18:07
* @Version 1.0
**/
@Data
public class AreaStatistics {
//当前统筹区code string类型
private String regionCode;
private String regionName;
private Integer bookCount;
private List<ClassifyStatistics> classifyStatisticsList;
}
package com.pcloud.book.record.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import lombok.Data;
/**
* @ClassName com.pcloud.book.record.entity.BookDetail
* @Author 吴博
* @Description 书刊详情
* @Date 2020/6/16 9:42
* @Version 1.0
**/
@Data
public class BookDetail {
private Long bookId;
private Long bookAdviserId;
private String bookName;
private String isbn;
private Long adviserId;
private String adviserName;
private Long agentId;
private String agentName;
private Long bookClassifyId;
private String bookClassifyName;
private String bookGroupName;
private String bookGroupUrl;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}
\ No newline at end of file
package com.pcloud.book.record.entity;
import java.util.List;
import lombok.Data;
/**
* @ClassName com.pcloud.book.record.entity.BookDetailDTO
* @Author 吴博
* @Description 书刊详情DTO
* @Date 2020/6/16 10:33
* @Version 1.0
**/
@Data
public class BookDetailDTO {
private Long regionId;
private String regionName;
private List<BookDetail> bookDetailList;
}
\ No newline at end of file
package com.pcloud.book.record.entity;
import lombok.Data;
/**
* @ClassName com.pcloud.book.record.entity.BookStatistics
* @Author 吴博
* @Description 书刊统计
* @Date 2020/6/15 17:24
* @Version 1.0
**/
@Data
public class BookMapStatistics {
private String province;
private String provinceCode;
private String city;
private String cityCode;
private Integer bookCount;
}
\ No newline at end of file
package com.pcloud.book.record.entity;
import lombok.Data;
/**
* @ClassName com.pcloud.book.record.entity.ClassifyStatistics
* @Author 吴博
* @Description 书刊分类统计
* @Date 2020/6/15 18:07
* @Version 1.0
**/
@Data
public class ClassifyStatistics {
private Long classifyId;
private String classifyName;
private String bookCount;
}
package com.pcloud.book.record.entity;
import java.util.Date;
import lombok.Data;
@Data
public class IpData {
private Long id;
private String ip;
private String region;
private String regionId;
private String city;
private String cityId;
private Date createTime;
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.record.entity;
import lombok.Data;
/**
* @ClassName com.pcloud.book.record.entity.IpData4Third
* @Author 吴博
* @Description 第三方查询ip
* @Date 2020/6/22 9:08
* @Version 1.0
**/
@Data
public class IpData4Third {
private String ip;
private String region;
private String region_id;
private String city;
private String city_id;
}
\ No newline at end of file
package com.pcloud.book.record.entity;
import lombok.Data;
/**
* @ClassName com.pcloud.book.record.entity.IpResponse
* @Author 吴博
* @Description ip返回数据
* @Date 2020/6/15 12:46
* @Version 1.0
**/
@Data
public class IpResponse {
private IpData4Third data;
private String msg;
private String ret;
private String log_id;
}
\ No newline at end of file
package com.pcloud.book.record.entity;
import com.pcloud.common.entity.BaseEntity;
public class MapData extends BaseEntity {
private String regionCode;
private String content;
public String getRegionCode() {
return regionCode;
}
public void setRegionCode(String regionCode) {
this.regionCode = regionCode;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
}
\ No newline at end of file
package com.pcloud.book.record.entity;
public class RegionMap {
private Long id;
private Integer regionCode;
private Integer level;
private String regionName;
private String alphabet;
private Integer parentId;
private String shortName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getRegionCode() {
return regionCode;
}
public void setRegionCode(Integer regionCode) {
this.regionCode = regionCode;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getRegionName() {
return regionName;
}
public void setRegionName(String regionName) {
this.regionName = regionName == null ? null : regionName.trim();
}
public String getAlphabet() {
return alphabet;
}
public void setAlphabet(String alphabet) {
this.alphabet = alphabet == null ? null : alphabet.trim();
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName == null ? null : shortName.trim();
}
}
\ No newline at end of file
package com.pcloud.book.record.facade;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
import com.pcloud.book.record.entity.AreaStatistics;
import com.pcloud.book.record.entity.BookDetail;
import com.pcloud.book.record.entity.BookDetailDTO;
import com.pcloud.book.record.entity.BookMapStatistics;
import com.pcloud.book.record.entity.MapData;
import com.pcloud.book.record.entity.RegionMap;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.erp.project.dto.BookDTO;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName com.pcloud.book.record.facade.BookBrowseRecordFacade
* @Author 吴博
* @Description 书籍地图facade
* @Date 2020/6/15 13:48
* @Version 1.0
**/
@RestController
@RequestMapping("bookBrowseRecord")
public class BookBrowseRecordFacade {
@Autowired
private BookBrowseRecordBiz bookBrowseRecordBiz;
@GetMapping("getBookCount")
public ResponseDto<List<BookMapStatistics>> getBookCount4Country(@RequestHeader("token") String token,
@RequestParam(value = "regionCode",required = false) String regionCode) {
SessionUtil.getToken4Redis(token);
if (Objects.equals(BookConstant.countryRegionCode, regionCode)){
regionCode = null;
}
return new ResponseDto<List<BookMapStatistics>>(bookBrowseRecordBiz.getBookCount4Country(regionCode));
}
@GetMapping("getAreaStatistics")
public ResponseDto<AreaStatistics> getAreaStatistics(@RequestHeader("token") String token,
@RequestParam(value = "regionCode" ,required = false) String regionCode,
@RequestParam("areaCode") Integer areaCode) {
SessionUtil.getToken4Redis(token);
if (Objects.equals(BookConstant.countryRegionCode, regionCode)){
areaCode = BookConstant.countryAreaCode;
regionCode = null;
}
return new ResponseDto<AreaStatistics>(bookBrowseRecordBiz.getAreaStatistics(regionCode, areaCode));
}
@GetMapping("getBookDetail")
public ResponseDto<PageBeanNew<BookDetail>> getBookDetail(@RequestHeader("token") String token,
@RequestParam("regionCode") String regionCode,
@RequestParam("areaCode") Integer areaCode,
@RequestParam(value = "currentPage") Integer currentPage,
@RequestParam(value = "numPerPage") Integer numPerPage,
@RequestParam(value = "bookName", required = false) String bookName,
@RequestParam(value = "agentId", required = false) Long agentId,
@RequestParam(value = "bookClassifyId", required = false) Long bookClassifyId) {
SessionUtil.getToken4Redis(token);
if (Objects.equals(BookConstant.countryRegionCode, regionCode)){
areaCode = BookConstant.countryAreaCode;
regionCode = null;
}
return new ResponseDto<PageBeanNew<BookDetail>>(bookBrowseRecordBiz.getBookDetail(regionCode, areaCode, new PageParam(currentPage,
numPerPage), bookName, agentId, bookClassifyId));
}
@GetMapping("addJsonData")
public ResponseDto<?> addJsonData(@RequestHeader("token") String token){
SessionUtil.getToken4Redis(token);
bookBrowseRecordBiz.addJsonData();
return new ResponseDto<>();
}
@GetMapping("getJsonData")
public ResponseDto<PageBeanNew<MapData>> getJsonData(@RequestHeader("token") String token,
@RequestParam(value = "regionCode", required = false) String regionCode,
@RequestParam(value = "currentPage") Integer currentPage,
@RequestParam(value = "numPerPage") Integer numPerPage){
SessionUtil.getToken4Redis(token);
PageBeanNew<MapData> mapDataPageBeanNew = bookBrowseRecordBiz.getJsonData(regionCode, currentPage, numPerPage);
return new ResponseDto<>(mapDataPageBeanNew);
}
@ApiOperation(value = "根据期刊社首字母分组", httpMethod = "GET")
@RequestMapping(value = "getCitysByPY", method = RequestMethod.GET)
ResponseDto<Map<String,List<RegionMap>>> getCitysByPY(@RequestHeader("token") String token,
@RequestParam(value = "keyword", required = false) String keyword) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
Map<String,List<RegionMap>> map= bookBrowseRecordBiz.getCitysByPY(keyword);
return new ResponseDto<>(map);
}
@ApiOperation(value = "处理旧的书刊读者数据", httpMethod = "GET")
@RequestMapping(value = "handleOldData", method = RequestMethod.GET)
ResponseDto<?> handleOldData(@RequestHeader("token") String token) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
bookBrowseRecordBiz.handleOldData();
return new ResponseDto<>();
}
}
\ No newline at end of file
package com.pcloud.book.record.mapper;
import com.pcloud.book.record.entity.AreaStatistics;
import com.pcloud.book.record.entity.BookBrowseRecord;
import com.pcloud.book.record.entity.BookMapStatistics;
import com.pcloud.book.record.entity.ClassifyStatistics;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BookBrowseRecordMapper {
}
\ No newline at end of file
package com.pcloud.book.record.mapper;
import com.pcloud.book.record.entity.IpData;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface IpDataMapper {
int deleteByPrimaryKey(Long id);
int insert(IpData record);
int insertSelective(IpData record);
IpData selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(IpData record);
int updateByPrimaryKey(IpData record);
IpData selectByIp(String ip);
}
\ No newline at end of file
package com.pcloud.book.record.mapper;
import com.pcloud.book.record.entity.RegionMap;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface RegionMapMapper {
int deleteByPrimaryKey(Long id);
int insert(RegionMap record);
int insertSelective(RegionMap record);
RegionMap selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(RegionMap record);
int updateByPrimaryKey(RegionMap record);
List<RegionMap> getCitysByPY(@Param("keyword") String keyword);
}
\ No newline at end of file
package com.pcloud.book.record.service.impl;
import com.pcloud.book.book.entity.Book;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
import com.pcloud.book.record.entity.BookBrowseRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @ClassName com.pcloud.book.record.service.impl.BookBrowseRecordServiceImpl
* @Author 吴博
* @Description 书籍浏览埋点内部接口实现类
* @Date 2020/6/12 16:10
* @Version 1.0
**/
@RestController
@RequestMapping("bookBrowseRecordService")
public class BookBrowseRecordServiceImpl implements BookBrowseRecordService {
@Autowired
private BookBrowseRecordBiz bookBrowseRecordBiz;
@Override
@RequestMapping(value = "addBookRecord", method = RequestMethod.POST)
public void addBookRecord(@RequestBody BookBrowseRecord bookBrowseRecord) {
bookBrowseRecordBiz.addBookRecord(bookBrowseRecord);
}
}
\ No newline at end of file
......@@ -16,18 +16,18 @@
connectionURL="jdbc:mysql://192.168.92.41:3306/book" userId="root"
password="LGSC2016.lgsc"/>
<javaModelGenerator targetPackage="com.pcloud.book.custom.entity"
<javaModelGenerator targetPackage="com.pcloud.book.record.entity"
targetProject="src\main\java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="mapper.custom"
<sqlMapGenerator targetPackage="mapper.record"
targetProject="src\main\resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator targetPackage="com.pcloud.book.custom.mapper"
<javaClientGenerator targetPackage="com.pcloud.book.record.mapper"
targetProject="src\main\java" type="XMLMAPPER">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
......@@ -38,7 +38,7 @@
selectByExampleQueryId="false">
</table>-->
<table tableName="custom_rights_item_description" domainObjectName="CustomRightsItemDescription"
<table tableName="ip_data" domainObjectName="IpData"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
......
......@@ -72,4 +72,28 @@
WHERE applet_book_classify_id = #{bookClassifyId}
</select>
<select id="getAppletBookClassifyId" parameterType="long" resultType="long">
select
applet_book_classify_id
from
applet_book_classify_relation
where
book_templet_id = #{firstClassifyId}
</select>
<select id="getBookClassifyByIds" parameterType="list" resultType="com.pcloud.book.applet.dto.AppletBookClassifyDTO">
select
id, classify, classify_name classifyName, seq, pic, show_state showState
from book.applet_book_classify
<where>
<if test="list != null">
id in
<foreach collection="list" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
order by seq asc, id asc
</select>
</mapper>
\ No newline at end of file
......@@ -700,4 +700,20 @@
</if>
group by t.BOOK_ID
</select>
<select id="getByBookAdviserIds" resultMap="bookAdviserMap" parameterType="list">
SELECT a.BOOK_ADVISER_ID,a.BOOK_ID, a.ADVISER_ID, a.CHANNEL_ID,a.IS_MAIN_EDITOR
b.isbn,
FROM BOOK_ADVISER a
left book b on a.book_Id = b.book_id
WHERE
BOOK_ID IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
${item}
</foreach>
AND
IS_DELETE = 0
GROUP BY BOOK_ID
</select>
</mapper>
\ No newline at end of file
......@@ -1033,4 +1033,24 @@
id = #{id}
</update>
<select id="getBookBaseInfoByAdviserBookIds" parameterType="list" resultType="com.pcloud.book.group.dto.BookGroupDTO">
SELECT
g.id bookGroupId,
g.book_id bookId,
a.book_adviser_id bookAdviserId,
g.group_qrcode_name groupQrcodeName,
g.group_qrcode_url groupQrcodeUrl,
g.create_time createTime,
join_group_type joinGroupType
FROM
book_group g
left join book_adviser a on a.book_id = g.book_id
WHERE
a.book_adviser_Id
in
<foreach collection="list" open="(" close=")" item="item" separator=",">
#{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" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.record.dao.impl.BookBrowseRecordDAOImpl" >
<resultMap id="BaseResultMap" type="com.pcloud.book.record.entity.BookBrowseRecord" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="book_adviser_id" property="bookAdviserId" jdbcType="BIGINT" />
<result column="isbn" property="isbn" jdbcType="VARCHAR" />
<result column="user_id" property="userId" jdbcType="BIGINT" />
<result column="province" property="province" jdbcType="VARCHAR" />
<result column="province_code" property="provinceCode" jdbcType="VARCHAR" />
<result column="city" property="city" jdbcType="VARCHAR" />
<result column="city_code" property="cityCode" jdbcType="VARCHAR" />
<result column="district" property="district" jdbcType="VARCHAR" />
<result column="district_code" property="districtCode" jdbcType="VARCHAR" />
<result column="gra_Label__id" property="graLabelId" jdbcType="BIGINT" />
<result column="sub_Label_Id" property="subLabelId" jdbcType="BIGINT" />
<result column="first_Classify_Id" property="firstClassifyId" jdbcType="BIGINT" />
<result column="second_Classify_Id" property="secondClassifyId" jdbcType="BIGINT" />
<result column="book_classify_id" property="bookClassifyId" jdbcType="BIGINT" />
<result column="ip" property="ip" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, book_adviser_id, isbn, user_id, province, province_code, city, city_code, district,
district_code, gra_Label__id, sub_Label_Id, first_Classify_Id, second_Classify_Id,
book_classify_id, ip, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from book_browse_record
where id = #{id,jdbcType=BIGINT}
</select>
<select id="getBookCount4Country" resultType="com.pcloud.book.record.entity.BookMapStatistics" parameterType="string">
select
count((book_adviser_id)) bookCount,
province,
province_code provinceCode,
city,
city_code cityCode
from
book_browse_record
<choose>
<when test="_parameter != null">
where province_code = #{_parameter}
group by city_code
order by bookCount desc, city_code asc
</when>
<otherwise>
group by province_code
order by bookCount desc, province_code asc
</otherwise>
</choose>
</select>
<select id="getAreaStatistics" resultType="com.pcloud.book.record.entity.AreaStatistics" parameterType="map">
select
(case when #{areaCode} = 1 then province_code when #{areaCode} = 2 then city_code else 0 end) regionCode,
(case when #{areaCode} = 1 then province when #{areaCode} = 2 then city when #{areaCode} = 0 then '全国' end) regionName ,
count((book_adviser_id)) bookCount
from book_browse_record b
<where>
<choose>
<when test= 'areaCode == "1"'>
province_code = #{regionCode}
</when>
<when test = 'areaCode == "2"'>
city_code = #{regionCode}
</when>
</choose>
</where>
</select>
<select id="getClassifyStatistics" resultType="com.pcloud.book.record.entity.ClassifyStatistics" parameterType="map">
select
book_classify_id classifyId,
a.classify_name classifyName,
count((book_adviser_id)) bookCount
from
book_browse_record b
left join applet_book_classify a
on b.book_classify_id = a.id
<where>
<choose>
<when test= 'areaCode == "1"'>
province_code = #{regionCode}
</when>
<when test = 'areaCode == "2"'>
city_code = #{regionCode}
</when>
</choose>
</where>
group by book_classify_id
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from book_browse_record
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.record.entity.BookBrowseRecord" >
insert into book_browse_record (id, book_adviser_id, isbn,
user_id, province, province_code,
city, city_code, district,
district_code, gra_Label__id, sub_Label_Id,
first_Classify_Id, second_Classify_Id, book_classify_id,
ip, create_time, update_time, book_name, agent_id, book_id, adviser_id
)
values (#{id,jdbcType=BIGINT}, #{bookAdviserId,jdbcType=BIGINT}, #{isbn,jdbcType=VARCHAR},
#{userId,jdbcType=BIGINT}, #{province,jdbcType=VARCHAR}, #{provinceCode,jdbcType=VARCHAR},
#{city,jdbcType=VARCHAR}, #{cityCode,jdbcType=VARCHAR}, #{district,jdbcType=VARCHAR},
#{districtCode,jdbcType=VARCHAR}, #{graLabelId,jdbcType=BIGINT}, #{subLabelId,jdbcType=BIGINT},
#{firstClassifyId,jdbcType=BIGINT}, #{secondClassifyId,jdbcType=BIGINT}, #{bookClassifyId,jdbcType=BIGINT},
#{ip,jdbcType=VARCHAR}, now(), now(), #{bookName}, #{agentId}, #{bookId}, #{adviserId}
)
on duplicate key
update
update_time=NOW(),
user_id = #{userId,jdbcType=BIGINT},
district = #{district,jdbcType=VARCHAR},
district_code = #{districtCode,jdbcType=VARCHAR},
gra_Label__id = #{graLabelId,jdbcType=BIGINT},
sub_Label_Id = #{subLabelId,jdbcType=BIGINT},
first_Classify_Id = #{firstClassifyId,jdbcType=BIGINT},
second_Classify_Id = #{secondClassifyId,jdbcType=BIGINT},
book_classify_id = #{bookClassifyId,jdbcType=BIGINT},
ip = #{ip,jdbcType=VARCHAR},
book_name = #{bookName},
agent_id = #{agentId},
adviser_id = #{adviserId}
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.record.entity.BookBrowseRecord" >
insert into book_browse_record
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="bookAdviserId != null" >
book_adviser_id,
</if>
<if test="isbn != null" >
isbn,
</if>
<if test="userId != null" >
user_id,
</if>
<if test="province != null" >
province,
</if>
<if test="provinceCode != null" >
province_code,
</if>
<if test="city != null" >
city,
</if>
<if test="cityCode != null" >
city_code,
</if>
<if test="district != null" >
district,
</if>
<if test="districtCode != null" >
district_code,
</if>
<if test="graLabelId != null" >
gra_Label__id,
</if>
<if test="subLabelId != null" >
sub_Label_Id,
</if>
<if test="firstClassifyId != null" >
first_Classify_Id,
</if>
<if test="secondClassifyId != null" >
second_Classify_Id,
</if>
<if test="bookClassifyId != null" >
book_classify_id,
</if>
<if test="ip != null" >
ip,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="bookAdviserId != null" >
#{bookAdviserId,jdbcType=BIGINT},
</if>
<if test="isbn != null" >
#{isbn,jdbcType=VARCHAR},
</if>
<if test="userId != null" >
#{userId,jdbcType=BIGINT},
</if>
<if test="province != null" >
#{province,jdbcType=VARCHAR},
</if>
<if test="provinceCode != null" >
#{provinceCode,jdbcType=VARCHAR},
</if>
<if test="city != null" >
#{city,jdbcType=VARCHAR},
</if>
<if test="cityCode != null" >
#{cityCode,jdbcType=VARCHAR},
</if>
<if test="district != null" >
#{district,jdbcType=VARCHAR},
</if>
<if test="districtCode != null" >
#{districtCode,jdbcType=VARCHAR},
</if>
<if test="graLabelId != null" >
#{graLabelId,jdbcType=BIGINT},
</if>
<if test="subLabelId != null" >
#{subLabelId,jdbcType=BIGINT},
</if>
<if test="firstClassifyId != null" >
#{firstClassifyId,jdbcType=BIGINT},
</if>
<if test="secondClassifyId != null" >
#{secondClassifyId,jdbcType=BIGINT},
</if>
<if test="bookClassifyId != null" >
#{bookClassifyId,jdbcType=BIGINT},
</if>
<if test="ip != null" >
#{ip,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.record.entity.BookBrowseRecord" >
update book_browse_record
<set >
<if test="bookAdviserId != null" >
book_adviser_id = #{bookAdviserId,jdbcType=BIGINT},
</if>
<if test="isbn != null" >
isbn = #{isbn,jdbcType=VARCHAR},
</if>
<if test="userId != null" >
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="province != null" >
province = #{province,jdbcType=VARCHAR},
</if>
<if test="provinceCode != null" >
province_code = #{provinceCode,jdbcType=VARCHAR},
</if>
<if test="city != null" >
city = #{city,jdbcType=VARCHAR},
</if>
<if test="cityCode != null" >
city_code = #{cityCode,jdbcType=VARCHAR},
</if>
<if test="district != null" >
district = #{district,jdbcType=VARCHAR},
</if>
<if test="districtCode != null" >
district_code = #{districtCode,jdbcType=VARCHAR},
</if>
<if test="graLabelId != null" >
gra_Label__id = #{graLabelId,jdbcType=BIGINT},
</if>
<if test="subLabelId != null" >
sub_Label_Id = #{subLabelId,jdbcType=BIGINT},
</if>
<if test="firstClassifyId != null" >
first_Classify_Id = #{firstClassifyId,jdbcType=BIGINT},
</if>
<if test="secondClassifyId != null" >
second_Classify_Id = #{secondClassifyId,jdbcType=BIGINT},
</if>
<if test="bookClassifyId != null" >
book_classify_id = #{bookClassifyId,jdbcType=BIGINT},
</if>
<if test="ip != null" >
ip = #{ip,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.record.entity.BookBrowseRecord" >
update book_browse_record
set book_adviser_id = #{bookAdviserId,jdbcType=BIGINT},
isbn = #{isbn,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=BIGINT},
province = #{province,jdbcType=VARCHAR},
province_code = #{provinceCode,jdbcType=VARCHAR},
city = #{city,jdbcType=VARCHAR},
city_code = #{cityCode,jdbcType=VARCHAR},
district = #{district,jdbcType=VARCHAR},
district_code = #{districtCode,jdbcType=VARCHAR},
gra_Label__id = #{graLabelId,jdbcType=BIGINT},
sub_Label_Id = #{subLabelId,jdbcType=BIGINT},
first_Classify_Id = #{firstClassifyId,jdbcType=BIGINT},
second_Classify_Id = #{secondClassifyId,jdbcType=BIGINT},
book_classify_id = #{bookClassifyId,jdbcType=BIGINT},
ip = #{ip,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getBookDetail" parameterType="map" resultType="com.pcloud.book.record.entity.BookDetail">
select
book_adviser_id bookAdviserId,
book_name bookName,
isbn,
agent_id agentId,
adviser_id adviserId,
book_classify_id bookClassifyId
from
book_browse_record
<where>
<choose>
<when test= 'areaCode == "1"'>
province_code = #{regionCode}
</when>
<when test = 'areaCode == "2"'>
city_code = #{regionCode}
</when>
</choose>
<if test="bookClassifyId != null">
and book_classify_id = #{bookClassifyId}
</if>
<if test="bookName != null">
and book_name like concat("%", #{bookName}, "%")
</if>
<if test="agentId != null">
and agent_id = #{agentId}
</if>
and book_adviser_id is not null
group by book_adviser_id
order by update_time desc
</where>
</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" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.record.mapper.IpDataMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.record.entity.IpData" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="ip" property="ip" jdbcType="VARCHAR" />
<result column="region" property="region" jdbcType="VARCHAR" />
<result column="region_id" property="regionId" jdbcType="VARCHAR" />
<result column="city" property="city" jdbcType="VARCHAR" />
<result column="city_id" property="cityId" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, ip, region, region_id, city, city_id, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from ip_data
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectByIp" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
ip_data
where
ip = #{ip}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from ip_data
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.record.entity.IpData" >
insert into ip_data (ip, region,
region_id, city, city_id,
create_time, update_time)
values (#{ip,jdbcType=VARCHAR}, #{region,jdbcType=VARCHAR},
#{regionId,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{cityId,jdbcType=VARCHAR},
now(), now())
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.record.entity.IpData" >
insert into ip_data
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="ip != null" >
ip,
</if>
<if test="region != null" >
region,
</if>
<if test="regionId != null" >
region_id,
</if>
<if test="city != null" >
city,
</if>
<if test="cityId != null" >
city_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="ip != null" >
#{ip,jdbcType=VARCHAR},
</if>
<if test="region != null" >
#{region,jdbcType=VARCHAR},
</if>
<if test="regionId != null" >
#{regionId,jdbcType=VARCHAR},
</if>
<if test="city != null" >
#{city,jdbcType=VARCHAR},
</if>
<if test="cityId != null" >
#{cityId,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.record.entity.IpData" >
update ip_data
<set >
<if test="ip != null" >
ip = #{ip,jdbcType=VARCHAR},
</if>
<if test="region != null" >
region = #{region,jdbcType=VARCHAR},
</if>
<if test="regionId != null" >
region_id = #{regionId,jdbcType=VARCHAR},
</if>
<if test="city != null" >
city = #{city,jdbcType=VARCHAR},
</if>
<if test="cityId != null" >
city_id = #{cityId,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.record.entity.IpData" >
update ip_data
set ip = #{ip,jdbcType=VARCHAR},
region = #{region,jdbcType=VARCHAR},
region_id = #{regionId,jdbcType=VARCHAR},
city = #{city,jdbcType=VARCHAR},
city_id = #{cityId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.record.dao.impl.MapDataDAOImpl" >
<resultMap id="BaseResultMap" type="com.pcloud.book.record.entity.MapData" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="region_code" property="regionCode" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.pcloud.book.record.entity.MapData" extends="BaseResultMap" >
<result column="content" property="content" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, region_code, create_time, content
</sql>
<sql id="Blob_Column_List" >
content
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from map
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from map
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.record.entity.MapData" >
insert into map (region_code, create_time,
content)
values (#{regionCode,jdbcType=VARCHAR}, #{createtTime,jdbcType=TIMESTAMP},
#{content,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.record.entity.MapData" >
insert into map
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="regionCode != null" >
region_code,
</if>
<if test="createtTime != null" >
create_time,
</if>
<if test="content != null" >
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="regionCode != null" >
#{regionCode,jdbcType=VARCHAR},
</if>
<if test="createtTime != null" >
#{createtTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null" >
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.record.entity.MapData" >
update map
<set >
<if test="regionCode != null" >
region_code = #{regionCode,jdbcType=VARCHAR},
</if>
<if test="createtTime != null" >
create_time = #{createtTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null" >
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.pcloud.book.record.entity.MapData" >
update map
set region_code = #{regionCode,jdbcType=VARCHAR},
create_time = #{createtTime,jdbcType=TIMESTAMP},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.record.entity.MapData" >
update map
set region_code = #{regionCode,jdbcType=VARCHAR},
create_time = #{createtTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<insert id="batchInsert" parameterType="com.pcloud.book.record.entity.MapData" >
insert into map (region_code, create_time,
content)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.regionCode,jdbcType=VARCHAR}, now(),
#{item.content,jdbcType=LONGVARCHAR})
</foreach>
</insert>
<select id="getJsonData" parameterType="map" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List"/>
from
map
<where>
<if test="regionCode != null">
region_code = #{regionCode}
</if>
</where>
order by region_code asc
</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" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.record.mapper.RegionMapMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.record.entity.RegionMap" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="region_code" property="regionCode" jdbcType="INTEGER" />
<result column="level" property="level" jdbcType="INTEGER" />
<result column="region_name" property="regionName" jdbcType="VARCHAR" />
<result column="alphabet" property="alphabet" jdbcType="CHAR" />
<result column="parent_id" property="parentId" jdbcType="INTEGER" />
<result column="short_name" property="shortName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, region_code, level, region_name, alphabet, parent_id, short_name
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from region_map
where id = #{id,jdbcType=BIGINT}
</select>
<select id="getCitysByPY" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
region_map
<where>
<if test="keyword != null">
region_name like concat("%",#{keyword},"%")
</if>
</where>
order by region_code
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from region_map
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.record.entity.RegionMap" >
insert into region_map (id, region_code, level,
region_name, alphabet, parent_id,
short_name)
values (#{id,jdbcType=BIGINT}, #{regionCode,jdbcType=INTEGER}, #{level,jdbcType=INTEGER},
#{regionName,jdbcType=VARCHAR}, #{alphabet,jdbcType=CHAR}, #{parentId,jdbcType=INTEGER},
#{shortName,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.record.entity.RegionMap" >
insert into region_map
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="regionCode != null" >
region_code,
</if>
<if test="level != null" >
level,
</if>
<if test="regionName != null" >
region_name,
</if>
<if test="alphabet != null" >
alphabet,
</if>
<if test="parentId != null" >
parent_id,
</if>
<if test="shortName != null" >
short_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="regionCode != null" >
#{regionCode,jdbcType=INTEGER},
</if>
<if test="level != null" >
#{level,jdbcType=INTEGER},
</if>
<if test="regionName != null" >
#{regionName,jdbcType=VARCHAR},
</if>
<if test="alphabet != null" >
#{alphabet,jdbcType=CHAR},
</if>
<if test="parentId != null" >
#{parentId,jdbcType=INTEGER},
</if>
<if test="shortName != null" >
#{shortName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.record.entity.RegionMap" >
update region_map
<set >
<if test="regionCode != null" >
region_code = #{regionCode,jdbcType=INTEGER},
</if>
<if test="level != null" >
level = #{level,jdbcType=INTEGER},
</if>
<if test="regionName != null" >
region_name = #{regionName,jdbcType=VARCHAR},
</if>
<if test="alphabet != null" >
alphabet = #{alphabet,jdbcType=CHAR},
</if>
<if test="parentId != null" >
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="shortName != null" >
short_name = #{shortName,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.record.entity.RegionMap" >
update region_map
set region_code = #{regionCode,jdbcType=INTEGER},
level = #{level,jdbcType=INTEGER},
region_name = #{regionName,jdbcType=VARCHAR},
alphabet = #{alphabet,jdbcType=CHAR},
parent_id = #{parentId,jdbcType=INTEGER},
short_name = #{shortName,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</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