Commit 55b1a1a7 by Administrator

Merge branch 'feature/1004716' into 'master'

feat: [1004716] 编辑运营优化需求

See merge request rays/pcloud-book!1301
parents 0358c48d 5d58b3c8
......@@ -49,4 +49,8 @@ public interface BookResourceService {
@RequestMapping(value = "/listByResourceId", method = RequestMethod.GET)
public ResponseEntity<ResponseDto<List<Long>>> listByResourceId(@RequestParam("resourceId") Long resourceId);
@ApiOperation(value = "获取资源关联的图书", httpMethod = "GET")
@RequestMapping(value = "/getSceneIdsByResourceId", method = RequestMethod.GET)
public ResponseEntity<ResponseDto<List<Long>>> getSceneIdsByResourceId(@RequestParam("resourceId") Long resourceId);
}
......@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.pcloud.book.book.biz.BookResourceBiz;
import com.pcloud.book.book.dto.BookResourceDto;
import com.pcloud.book.book.service.BookResourceService;
import com.pcloud.book.group.biz.ResourcePageBiz;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.utils.ResponseHandleUtil;
......@@ -29,6 +30,8 @@ public class BookResourceServiceImpl implements BookResourceService {
@Autowired
private BookResourceBiz bookResourceBiz;
@Autowired
private ResourcePageBiz resourcePageBiz;
/**
* 获取图书关联资源
......@@ -50,4 +53,13 @@ public class BookResourceServiceImpl implements BookResourceService {
public ResponseEntity<ResponseDto<List<Long>>> listByResourceId(@RequestParam("resourceId") Long resourceId) {
return ResponseHandleUtil.toResponse(bookResourceBiz.listByResourceId(resourceId));
}
/**
* 获取h5页面配了这个资源的二维码集合
*/
@Override
@RequestMapping(value = "/getSceneIdsByResourceId", method = RequestMethod.GET)
public ResponseEntity<ResponseDto<List<Long>>> getSceneIdsByResourceId(@RequestParam("resourceId") Long resourceId) {
return ResponseHandleUtil.toResponse(resourcePageBiz.getSceneIdsByResourceId(resourceId));
}
}
package com.pcloud.book.copyright.biz;
import com.pcloud.book.copyright.dto.BookExportRecordDTO;
import com.pcloud.book.copyright.entity.BookExportRecord;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
/**
* @author lily
......@@ -29,4 +32,10 @@ public interface BookExportRecordBiz {
void updateRecord(BookExportRecord bookExportRecord);
void handleExportFail();
/**
* 查看授权码生成记录
*/
PageBeanNew<BookExportRecordDTO> getGenerateCodeHistory(Long bookId, Long adviserId, Long channelId, PageParam pageParam);
}
......@@ -171,7 +171,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
Integer batchNum = bookAuthCodeBiz.getMaxBatchNum(bookId, channelId, adviserId, authBookType);// TODO
num = String.format("%04d", batchNum);
//新增导出记录
insertExportRecord(bookId, channelId, adviserId, num);
insertExportRecord(bookId, channelId, adviserId, num,codeCount,isHaveBarCode);
//获取图书名称
BookDto bookDto = bookBiz.getBaseById(bookId);
if (bookDto == null) {
......@@ -260,12 +260,14 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
}
@ParamLog("新增导出记录")
private void insertExportRecord(Long bookId, Long channelId, Long adviserId, String num) {
private void insertExportRecord(Long bookId, Long channelId, Long adviserId, String num,Integer codeCount, Integer isHaveBarCode) {
BookExportRecord bookExportRecord = new BookExportRecord();
bookExportRecord.setBookId(bookId);
bookExportRecord.setAdviserId(adviserId);
bookExportRecord.setChannelId(channelId);
bookExportRecord.setBatchNum(num);
bookExportRecord.setCodeCount(codeCount);
bookExportRecord.setIsHaveBarCode(isHaveBarCode);
bookExportRecordBiz.insertRecord(bookExportRecord);
}
......
......@@ -2,10 +2,18 @@ package com.pcloud.book.copyright.biz.impl;
import com.pcloud.book.copyright.biz.BookExportRecordBiz;
import com.pcloud.book.copyright.dao.BookExportRecordDao;
import com.pcloud.book.copyright.dto.BookExportRecordDTO;
import com.pcloud.book.copyright.entity.BookExportRecord;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author lily
* @date 2018/12/4 19:14
......@@ -41,4 +49,37 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz {
public void handleExportFail() {
bookExportRecordDao.handleExportFail();
}
@Override
public PageBeanNew<BookExportRecordDTO> getGenerateCodeHistory(Long bookId, Long adviserId, Long channelId, PageParam pageParam) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId",channelId);
paramMap.put("adviserId",adviserId);
PageBeanNew<BookExportRecordDTO> pageBeanNew = bookExportRecordDao.listPageNew(pageParam, paramMap, "getGenerateCodeHistory");
if(pageBeanNew == null || CollectionUtils.isEmpty(pageBeanNew.getRecordList())){
return pageBeanNew;
}
//填充导出格式
pageBeanNew.getRecordList().forEach(e->{
e.setImportType(getImportType(e.getIsHaveBarCode()));
});
return pageBeanNew;
}
private String getImportType(Integer type){
if(null==type){
return "";
}
switch (type){
case 0:
return "正版授权码+条形码";
case 1:
return "正版授权码";
case 2:
return "二维码";
default: return "";
}
}
}
package com.pcloud.book.copyright.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author lily
* @date 2018/12/4 19:21
*/
@ApiModel
@Data
public class BookExportRecordDTO extends BaseEntity {
@ApiModelProperty("下载地址")
private String downloadUrl;
@ApiModelProperty("生成码数量")
private Integer codeCount;
@ApiModelProperty("导出格式")
private Integer isHaveBarCode;
@ApiModelProperty("导出格式中文")
private String importType;
@ApiModelProperty("最后修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date lastModifiedDate;
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.copyright.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
......@@ -11,6 +12,7 @@ import java.util.Date;
* @date 2018/12/4 19:21
*/
@ApiModel
@Data
public class BookExportRecord extends BaseEntity {
private Long id;
......@@ -44,110 +46,11 @@ public class BookExportRecord extends BaseEntity {
@ApiModelProperty("导出状态")
private Integer exportStatus;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public Long getAdviserId() {
return adviserId;
}
public void setAdviserId(Long adviserId) {
this.adviserId = adviserId;
}
public String getBatchNum() {
return batchNum;
}
public void setBatchNum(String batchNum) {
this.batchNum = batchNum;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
public Long getCreatedUser() {
return createdUser;
}
public void setCreatedUser(Long createdUser) {
this.createdUser = createdUser;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public Long getLastModifiedUser() {
return lastModifiedUser;
}
public void setLastModifiedUser(Long lastModifiedUser) {
this.lastModifiedUser = lastModifiedUser;
}
public Date getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(Date lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
public Integer getExportStatus() {
return exportStatus;
}
public void setExportStatus(Integer exportStatus) {
this.exportStatus = exportStatus;
}
@Override
public String toString() {
return "BookExportRecord{" +
"id=" + id +
", bookId=" + bookId +
", channelId=" + channelId +
", adviserId=" + adviserId +
", batchNum='" + batchNum + '\'' +
", downloadUrl='" + downloadUrl + '\'' +
", createdUser=" + createdUser +
", createdDate=" + createdDate +
", lastModifiedUser=" + lastModifiedUser +
", lastModifiedDate=" + lastModifiedDate +
", exportStatus=" + exportStatus +
'}';
}
@ApiModelProperty("生成码数量")
private Integer codeCount;
@ApiModelProperty("导出格式")
private Integer isHaveBarCode;
}
......@@ -2,8 +2,11 @@ package com.pcloud.book.copyright.facade.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.copyright.biz.BookAuthCodeBiz;
import com.pcloud.book.copyright.biz.BookExportRecordBiz;
import com.pcloud.book.copyright.dto.BookAuthCodeDTO;
import com.pcloud.book.copyright.dto.BookExportRecordDTO;
import com.pcloud.book.copyright.dto.DeleteAuthCodeDTO;
import com.pcloud.book.copyright.entity.BookExportRecord;
import com.pcloud.book.copyright.facade.BookAuthCodeFacade;
import com.pcloud.book.copyright.vo.CheckCodeParam;
import com.pcloud.book.copyright.vo.CheckIsAuthServeParam;
......@@ -46,6 +49,9 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade {
@Autowired
private BookAuthCodeBiz bookAuthCodeBiz;
@Autowired
private BookExportRecordBiz bookExportRecordBiz;
@Override
@RequestMapping(value = "checkCode", method = RequestMethod.POST)
public ResponseDto<CodeUseStatusVO> checkCode(@CookieValue("userInfo") String userInfo, @RequestBody CheckCodeParam checkCodeParam) throws PermissionException, BizException {
......@@ -161,4 +167,19 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade {
bookAuthCodeBiz.deleteNoUsedAuthCode(deleteAuthCodeDTO,adviserId);
return new ResponseDto<>();
}
/**
* 查看授权码生成记录
*/
@GetMapping("getGenerateCodeHistory")
public ResponseDto<?> getGenerateCodeHistory(@RequestHeader("token")String token,
@RequestParam(required = false, value ="bookId") Long bookId,
@RequestParam(required = false, value ="channelId") Long channelId,
@RequestParam(required = false,value = "currentPage")Integer currentPage,
@RequestParam(required = false,value = "numPerPage")Integer numPerPage) throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
PageParam pageParam = new PageParam(currentPage,numPerPage);
PageBeanNew<BookExportRecordDTO> result=bookExportRecordBiz.getGenerateCodeHistory(bookId,adviserId,channelId,pageParam);
return new ResponseDto<>(result);
}
}
......@@ -211,4 +211,9 @@ public interface ResourcePageBiz {
* * @param null
*/
void batchUpdateSceneIdByBookGroup(List<AddBookGroupServeDTO> list);
/**
* 获取h5页面配了这个资源的二维码集合
*/
List<Long> getSceneIdsByResourceId(Long resourceId);
}
\ No newline at end of file
......@@ -100,6 +100,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import lombok.extern.slf4j.Slf4j;
/**
......@@ -1353,4 +1354,16 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
resourcePageDao.batchUpdateSceneIdByBookGroup(list);
}
@Override
public List<Long> getSceneIdsByResourceId(Long resourceId) {
//慎用。这个接口是给删除作品的时候用的
//获取的同时。会删掉配置的资源。
List<Long> result=resourcePageDao.getSceneIdsByResourceId(resourceId);
if(CollectionUtil.isNotEmpty(result)){
//删除配置的资源
resourcePageItemDao.deleteByServeId(resourceId);
}
return result;
}
}
......@@ -95,4 +95,6 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{
* * @param null
*/
ResourcePage getPageByColumnId(Long resourcePageColumnId);
List<Long> getSceneIdsByResourceId(Long resourceId);
}
\ No newline at end of file
......@@ -74,4 +74,6 @@ public interface ResourcePageItemDao extends BaseDao<ResourcePageItem>{
* * @param null
*/
ResourcePageItemVO checkOneServeItemByPageId(Long resourcePageId);
void deleteByServeId(Long resourceId);
}
\ No newline at end of file
......@@ -73,4 +73,9 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re
public ResourcePage getPageByColumnId(Long resourcePageColumnId) {
return getSessionTemplate().selectOne(getStatement("getPageByColumnId"), resourcePageColumnId);
}
@Override
public List<Long> getSceneIdsByResourceId(Long resourceId) {
return getSessionTemplate().selectList(getStatement("getSceneIdsByResourceId"), resourceId);
}
}
......@@ -71,4 +71,9 @@ public class ResourcePageItemDaoImpl extends BaseDaoImpl<ResourcePageItem> imple
public ResourcePageItemVO checkOneServeItemByPageId(Long resourcePageId) {
return getSessionTemplate().selectOne(getStatement("checkOneServeItemByPageId"), resourcePageId);
}
@Override
public void deleteByServeId(Long resourceId) {
getSessionTemplate().delete(getStatement("deleteByServeId"), resourceId);
}
}
......@@ -4,10 +4,10 @@
<insert id="insert" useGeneratedKeys="true" parameterType="bookExportRecord">
INSERT INTO BOOK_EXPORT_RECORD(
BOOK_ID, CHANNEL_ID,ADVISER_ID, BATCH_NUM, CREATED_USER, CREATED_DATE)
BOOK_ID, CHANNEL_ID,ADVISER_ID, BATCH_NUM, CREATED_USER, CREATED_DATE,code_count,is_have_bar_code)
VALUES
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},#{batchNum},
#{adviserId}, NOW())
#{adviserId}, NOW(),#{codeCount},#{isHaveBarCode})
</insert>
<update id="updateRecordStatus" parameterType="bookAuthInfo" flushCache="true">
......@@ -51,6 +51,19 @@
WHERE EXPORT_STATUS = 0
</update>
<select id="getGenerateCodeHistory" parameterType="map" resultType="com.pcloud.book.copyright.dto.BookExportRecordDTO">
SELECT
download_url downloadUrl,
code_count codeCount,
is_have_bar_code isHaveBarCode,
last_modified_date lastModifiedDate
FROM
BOOK_EXPORT_RECORD
WHERE
book_id = #{bookId}
AND channel_id = #{channelId}
AND adviser_id = #{adviserId}
order by created_date desc
</select>
</mapper>
\ No newline at end of file
......@@ -188,4 +188,15 @@
c.id = #{resourcePageColumnId}
</select>
<select id="getSceneIdsByResourceId" resultType="Long" parameterType="long">
SELECT DISTINCT
b.scene_id
FROM
resource_page_item a
INNER JOIN resource_page b ON a.resource_page_id = b.id
WHERE
a.serve_type = "PRODUCT"
AND a.serve_id = #{resourceId}
</select>
</mapper>
\ No newline at end of file
......@@ -211,4 +211,8 @@
COUNT(i.id) = 1
AND i.serve_type IN ("APP", "PRODUCT")
</select>
<delete id="deleteByServeId" parameterType="long">
delete from book.resource_page_item where serve_id = #{resourceId} and serve_type="PRODUCT"
</delete>
</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