Commit ed52b7be by lili

版权保护导出修改

parent 836d3b34
......@@ -109,4 +109,33 @@ public enum BookStatusEnum {
this.value = value;
}
}
public enum BookExportStatus{
/**
* 进行中
*/
ON(0),
/**
* 已完成
*/
SUCCESS(1),
/**
* 失败
*/
FAIL(2);
public final Integer value;
/**
* 构造
*
* @param value
*/
BookExportStatus(Integer value) {
this.value = value;
}
}
}
package com.pcloud.book;
import com.alibaba.druid.pool.DruidDataSource;
import com.pcloud.book.copyright.biz.BookAuthOrderBiz;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.common.core.constant.MQTopicProducer;
import com.pcloud.common.core.mq.RabbitMQFactory;
import com.pcloud.facade.tradecenter.entity.Genuine;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -14,7 +12,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
......@@ -29,7 +26,6 @@ import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.sql.DataSource;
import java.math.BigDecimal;
import java.util.ArrayList;
@SpringBootApplication
......
......@@ -68,4 +68,8 @@ public interface BookAuthInfoBiz {
* 获取图书授权基本信息
*/
BookAuthInfoVO getAuthBookInfo(Long bookId, Long channelId, Long adviserId, Long sceneId);
/**
* 获取是否有正在导出的
*/
Boolean isHaveExport(Long bookId, Long channelId, Long adviserId);
}
......@@ -9,7 +9,24 @@ import com.pcloud.book.copyright.entity.BookExportRecord;
public interface BookExportRecordBiz {
/**
* 新增到处记录
* 新增导出记录
*/
void insertRecord(BookExportRecord bookExportRecord);
/**
* 更新导出记录
*/
void updateRecordStatus(BookExportRecord bookExportRecord);
/**
* 获取是否有正在到处的数据
*/
Boolean isHaveExport(Long bookId, Long channelId, Long adviserId);
/**
* 更新导出记录
*/
void updateRecord(BookExportRecord bookExportRecord);
void handleExportFail();
}
......@@ -21,4 +21,24 @@ public class BookExportRecordBizImpl implements BookExportRecordBiz {
public void insertRecord(BookExportRecord bookExportRecord) {
bookExportRecordDao.insert(bookExportRecord);
}
@Override
public void updateRecordStatus(BookExportRecord bookExportRecord) {
bookExportRecordDao.updateRecordStatus(bookExportRecord);
}
@Override
public Boolean isHaveExport(Long bookId, Long channelId, Long adviserId) {
return bookExportRecordDao.isHaveExport(bookId, channelId, adviserId);
}
@Override
public void updateRecord(BookExportRecord bookExportRecord) {
bookExportRecordDao.updateRecord(bookExportRecord);
}
@Override
public void handleExportFail() {
bookExportRecordDao.handleExportFail();
}
}
......@@ -8,4 +8,24 @@ import com.pcloud.common.core.dao.BaseDao;
* @date 2018/12/4 19:20
*/
public interface BookExportRecordDao extends BaseDao<BookExportRecord> {
/**
* 更新导出记录
*/
void updateRecordStatus(BookExportRecord bookExportRecord);
/**
* 获取是否有正在导出的数据
*/
Boolean isHaveExport(Long bookId, Long channelId, Long adviserId);
/**
* 更新导出记录
*/
void updateRecord(BookExportRecord bookExportRecord);
/**
* 处理导出
*/
void handleExportFail();
}
......@@ -5,10 +5,37 @@ import com.pcloud.book.copyright.entity.BookExportRecord;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author lily
* @date 2018/12/4 19:20
*/
@Component("bookExportRecordDao")
public class BookExportRecordDaoImpl extends BaseDaoImpl<BookExportRecord> implements BookExportRecordDao {
@Override
public void updateRecordStatus(BookExportRecord bookExportRecord) {
this.getSqlSession().update(this.getStatement("updateRecordStatus"), bookExportRecord);
}
@Override
public Boolean isHaveExport(Long bookId, Long channelId, Long adviserId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("bookId",bookId);
paramMap.put("channelId",channelId);
paramMap.put("adviserId",adviserId);
return this.getSqlSession().selectOne(this.getStatement("isHaveExport"), paramMap);
}
@Override
public void updateRecord(BookExportRecord bookExportRecord) {
this.getSqlSession().update(this.getStatement("updateRecord"), bookExportRecord);
}
@Override
public void handleExportFail() {
this.getSqlSession().update(this.getStatement("handleExportFail"));
}
}
......@@ -33,9 +33,17 @@ public class BookExportRecord extends BaseEntity {
@ApiModelProperty("创建人")
private Long createdUser;
@ApiModelProperty("创建时间不带时分秒")
@ApiModelProperty("创建时间")
private Date createdDate;
@ApiModelProperty("最后修改人")
private Long lastModifiedUser;
@ApiModelProperty("最后修改时间")
private Date lastModifiedDate;
@ApiModelProperty("导出状态")
private Integer exportStatus;
@Override
public Long getId() {
return id;
......@@ -102,6 +110,30 @@ public class BookExportRecord extends BaseEntity {
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{" +
......@@ -113,6 +145,9 @@ public class BookExportRecord extends BaseEntity {
", downloadUrl='" + downloadUrl + '\'' +
", createdUser=" + createdUser +
", createdDate=" + createdDate +
", lastModifiedUser=" + lastModifiedUser +
", lastModifiedDate=" + lastModifiedDate +
", exportStatus=" + exportStatus +
'}';
}
}
......@@ -68,4 +68,10 @@ public interface BookAuthInfoFacade {
@RequestMapping(value = "listHaveSetAuthBook", method = RequestMethod.POST)
ResponseDto<PageBeanNew> listHaveSetAuthBook(@RequestHeader("token") String token, @RequestBody ListHaveAuthBookParam listHaveAuthBookParam)
throws PermissionException, BizException;
@ApiOperation(value = "是否有可以导出的", httpMethod = "GET")
@RequestMapping(value = "isHaveExport", method = RequestMethod.GET)
ResponseDto<Boolean> isHaveExport(@RequestHeader("token") String token, @RequestParam("bookId") Long bookId, @RequestParam("channelId") Long channelId)
throws PermissionException, BizException;
}
......@@ -101,4 +101,13 @@ public class BookAuthInfoFacadeImpl implements BookAuthInfoFacade {
PageBeanNew pageBeanNew = bookAuthInfoBiz.listHaveSetAuthBook(listHaveAuthBookParam, adviserId) ;
return new ResponseDto<>(pageBeanNew);
}
@Override
@GetMapping("isHaveExport")
public ResponseDto<Boolean> isHaveExport(@RequestHeader("token") String token, @RequestParam("bookId") Long bookId, @RequestParam("channelId") Long channelId)
throws PermissionException, BizException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
Boolean isCanExport = bookAuthInfoBiz.isHaveExport(bookId, channelId, adviserId);
return new ResponseDto<>(isCanExport == null ? false : isCanExport);
}
}
/**
*
*/
package com.pcloud.book.mq.event;
import com.pcloud.book.copyright.biz.BookExportRecordBiz;
import com.pcloud.common.utils.string.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
/**
* @author:songx
* @date:2018年5月16日,下午5:11:03
*/
@Component("bookEvent")
public class BookEvent implements ApplicationListener<ContextRefreshedEvent> {
/**
*
*/
private final static Logger LOGGER = LoggerFactory.getLogger(BookEvent.class);
@Autowired
private BookExportRecordBiz bookExportRecordBiz;
/**
* 目的:防止onApplicationEvent方法重复执行两次
*/
private boolean bool = false;
public void onApplicationEvent(ContextRefreshedEvent event) {
if (bool || !StringUtil.isEmpty(event.getApplicationContext().getParent().getApplicationName())) {
return;
}
bool = true;
//处理由于服务重启导致导出失败的文件
handleExportFail();
}
private void handleExportFail() {
bookExportRecordBiz.handleExportFail();
}
}
......@@ -4,9 +4,53 @@
<insert id="insert" useGeneratedKeys="true" parameterType="bookExportRecord">
INSERT INTO BOOK_EXPORT_RECORD(
BOOK_ID, CHANNEL_ID,ADVISER_ID,BATCH_NUM,DOWNLOAD_URL,CREATED_USER, CREATED_DATE)
BOOK_ID, CHANNEL_ID,ADVISER_ID, BATCH_NUM, CREATED_USER, CREATED_DATE)
VALUES
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},
#{batchNum}, #{downloadUrl}, #{adviserId}, NOW())
(#{bookId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT}, #{adviserId,jdbcType=BIGINT},#{batchNum},
#{adviserId}, NOW())
</insert>
<update id="updateRecordStatus" parameterType="bookAuthInfo" flushCache="true">
UPDATE BOOK_EXPORT_RECORD
SET
EXPORT_STATUS = #{exportStatus},
LAST_MODIFIED_DATE = NOW(),
LAST_MODIFIED_USER = #{lastModifiedUser}
WHERE
BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum}
</update>
<update id="updateRecord" parameterType="bookAuthInfo" flushCache="true">
UPDATE BOOK_EXPORT_RECORD
SET
EXPORT_STATUS = #{exportStatus},
download_url = #{downloadUrl},
LAST_MODIFIED_DATE = NOW(),
LAST_MODIFIED_USER = #{lastModifiedUser}
WHERE
BOOK_ID = #{bookId} AND CHANNEL_ID = #{channelId} AND ADVISER_ID = #{adviserId} AND BATCH_NUM = #{batchNum}
</update>
<select id="isHaveExport" resultType="Boolean" parameterType="map">
SELECT
COUNT(1)
FROM
BOOK_EXPORT_RECORD
WHERE
BOOK_ID = #{bookId, jdbcType=BIGINT}
AND
CHANNEL_ID = #{channelId, jdbcType=BIGINT}
AND
ADVISER_ID = #{adviserId, jdbcType=BIGINT}
AND EXPORT_STATUS = 0
</select>
<update id="handleExportFail" >
UPDATE BOOK_EXPORT_RECORD
SET EXPORT_STATUS = 2
WHERE EXPORT_STATUS = 0
</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