Commit c0e95b29 by 李莉

Merge branch 'dw/C1360' into 'master'

版权保护添加【正版专享】

See merge request rays/pcloud-book!1
parents 9e24a4d6 bb661b08
package com.pcloud.book.copyright.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.CollectionUtils;
import java.io.Serializable;
import java.util.List;
/**
* @author lily
* @date 2018/12/26 15:35
*/
@ApiModel
public class BookAuthServerDTO implements Serializable {
private static final long serialVersionUID = 9178152999605620185L;
@ApiModelProperty("图书id")
private Long bookId;
@ApiModelProperty("运营标识")
private Long channelId;
@ApiModelProperty("编辑标识")
private Long adviserId;
@ApiModelProperty("服务标识")
private List<Long> serveIds;
public Boolean check(){
return null == bookId || null == channelId || null == adviserId || CollectionUtils.isEmpty(serveIds);
}
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 List<Long> getServeIds() {
return serveIds;
}
public void setServeIds(List<Long> serveIds) {
this.serveIds = serveIds;
}
@Override
public String toString() {
return "BookAuthServerDTO{" +
"bookId=" + bookId +
", channelId=" + channelId +
", adviserId=" + adviserId +
", serveIds=" + serveIds +
'}';
}
}
package com.pcloud.book.copyright.service; package com.pcloud.book.copyright.service;
import com.pcloud.book.book.dto.BookAuthServeStatusParam; import com.pcloud.book.book.dto.BookAuthServeStatusParam;
import com.pcloud.book.copyright.dto.BookAuthServerDTO;
import com.pcloud.book.copyright.dto.QrcodeAuthServeDTO; import com.pcloud.book.copyright.dto.QrcodeAuthServeDTO;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
...@@ -8,6 +9,7 @@ import io.swagger.annotations.Api; ...@@ -8,6 +9,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -33,4 +35,9 @@ public interface BookAuthServeService { ...@@ -33,4 +35,9 @@ public interface BookAuthServeService {
ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIdsAndQrcode(@RequestBody QrcodeAuthServeDTO qrcodeAuthServeDTO) ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIdsAndQrcode(@RequestBody QrcodeAuthServeDTO qrcodeAuthServeDTO)
throws BizException; throws BizException;
@ApiOperation(value = "获取应用是否开启版权保护", httpMethod = "POST")
@PostMapping("listIsOpen4ServeIdsAndBookId")
ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIdsAndBookId(@RequestBody BookAuthServerDTO bookAuthServerDTO)
throws BizException;
} }
...@@ -39,4 +39,9 @@ public interface BookAuthServeBiz { ...@@ -39,4 +39,9 @@ public interface BookAuthServeBiz {
* @return * @return
*/ */
Map<String,Boolean> listIsOpen4ServeIdsAndQrcode(Long sceneId, List<Long> serveIds); Map<String,Boolean> listIsOpen4ServeIdsAndQrcode(Long sceneId, List<Long> serveIds);
/**
* 获取图书是否开启版权保护
*/
Map<String,Boolean> listIsOpen4ServeIdsAndBookId(Long bookId, Long adviserId, Long channelId, List<Long> serveIds);
} }
...@@ -55,6 +55,7 @@ public class BookAuthServeBizImpl implements BookAuthServeBiz { ...@@ -55,6 +55,7 @@ public class BookAuthServeBizImpl implements BookAuthServeBiz {
/** /**
* 是否设置应用授权 return key : typeCode_serveId * 是否设置应用授权 return key : typeCode_serveId
*/ */
@Override
@ParamLog("是否设置应用授权") @ParamLog("是否设置应用授权")
public Map<String, Boolean> isSetServeAuth(Long bookId, Long channelId, Long adviserId, List<Long> serveIds) { public Map<String, Boolean> isSetServeAuth(Long bookId, Long channelId, Long adviserId, List<Long> serveIds) {
if (bookId == null || channelId == null || adviserId == null || ListUtils.isEmpty(serveIds)) { if (bookId == null || channelId == null || adviserId == null || ListUtils.isEmpty(serveIds)) {
...@@ -98,6 +99,18 @@ public class BookAuthServeBizImpl implements BookAuthServeBiz { ...@@ -98,6 +99,18 @@ public class BookAuthServeBizImpl implements BookAuthServeBiz {
return null; return null;
} }
@Override
@ParamLog("listIsOpen4ServeIdsAndBookId")
public Map<String, Boolean> listIsOpen4ServeIdsAndBookId(Long bookId,Long adviserId, Long channelId, List<Long> serveIds) {
BookInfoAndAuthStatusDTO baseAndAuthStatus = bookBiz.getBaseAndAuthStatus(bookId, channelId, adviserId);
final boolean boo = baseAndAuthStatus != null && BookStatusEnum.PROTECT.value.equals(baseAndAuthStatus.getBookStatus())
&& BookStatusEnum.BookDeleteStatus.NOT_DELETE.value.equals(baseAndAuthStatus.getIsDelete());
if (boo) {
return isSetServeAuth(bookId, channelId, adviserId, serveIds);
}
return null;
}
private List<BookAuthServe> changeToBookAuthServe(List<ServeVO> serves, Long bookId, Long channelId, Long adviserId) { private List<BookAuthServe> changeToBookAuthServe(List<ServeVO> serves, Long bookId, Long channelId, Long adviserId) {
List<BookAuthServe> bookAuthServes = new ArrayList<>(); List<BookAuthServe> bookAuthServes = new ArrayList<>();
......
...@@ -2,8 +2,8 @@ package com.pcloud.book.copyright.service.impl; ...@@ -2,8 +2,8 @@ package com.pcloud.book.copyright.service.impl;
import com.pcloud.book.book.dto.BookAuthServeStatusParam; import com.pcloud.book.book.dto.BookAuthServeStatusParam;
import com.pcloud.book.copyright.biz.BookAuthServeBiz; import com.pcloud.book.copyright.biz.BookAuthServeBiz;
import com.pcloud.book.copyright.dto.BookAuthServerDTO;
import com.pcloud.book.copyright.dto.QrcodeAuthServeDTO; import com.pcloud.book.copyright.dto.QrcodeAuthServeDTO;
import com.pcloud.book.copyright.entity.BookAuthServe;
import com.pcloud.book.copyright.service.BookAuthServeService; import com.pcloud.book.copyright.service.BookAuthServeService;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
...@@ -32,7 +32,7 @@ public class BookAuthServeServiceImpl implements BookAuthServeService { ...@@ -32,7 +32,7 @@ public class BookAuthServeServiceImpl implements BookAuthServeService {
@PostMapping("listIsOpen4ServeIds") @PostMapping("listIsOpen4ServeIds")
public ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIds(@RequestBody BookAuthServeStatusParam bookAuthServeStatusParam) throws BizException { public ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIds(@RequestBody BookAuthServeStatusParam bookAuthServeStatusParam) throws BizException {
Map<String, Boolean> isOpen4ServeIds = null; Map<String, Boolean> isOpen4ServeIds = null;
if(bookAuthServeStatusParam != null) { if (bookAuthServeStatusParam != null) {
isOpen4ServeIds = bookAuthServeBiz.isSetServeAuth(bookAuthServeStatusParam.getBookId(), bookAuthServeStatusParam.getChannelId(), bookAuthServeStatusParam.getAdviserId(), bookAuthServeStatusParam.getServeIds()); isOpen4ServeIds = bookAuthServeBiz.isSetServeAuth(bookAuthServeStatusParam.getBookId(), bookAuthServeStatusParam.getChannelId(), bookAuthServeStatusParam.getAdviserId(), bookAuthServeStatusParam.getServeIds());
} }
return ResponseHandleUtil.toResponse(isOpen4ServeIds); return ResponseHandleUtil.toResponse(isOpen4ServeIds);
...@@ -42,8 +42,19 @@ public class BookAuthServeServiceImpl implements BookAuthServeService { ...@@ -42,8 +42,19 @@ public class BookAuthServeServiceImpl implements BookAuthServeService {
@PostMapping("listIsOpen4ServeIdsAndQrcode") @PostMapping("listIsOpen4ServeIdsAndQrcode")
public ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIdsAndQrcode(@RequestBody QrcodeAuthServeDTO qrcodeAuthServeDTO) throws BizException { public ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIdsAndQrcode(@RequestBody QrcodeAuthServeDTO qrcodeAuthServeDTO) throws BizException {
Map<String, Boolean> isOpen4ServeIds = null; Map<String, Boolean> isOpen4ServeIds = null;
if(qrcodeAuthServeDTO != null) { if (qrcodeAuthServeDTO != null) {
isOpen4ServeIds = bookAuthServeBiz.listIsOpen4ServeIdsAndQrcode(qrcodeAuthServeDTO.getSceneId(),qrcodeAuthServeDTO.getServeIds()); isOpen4ServeIds = bookAuthServeBiz.listIsOpen4ServeIdsAndQrcode(qrcodeAuthServeDTO.getSceneId(), qrcodeAuthServeDTO.getServeIds());
}
return ResponseHandleUtil.toResponse(isOpen4ServeIds);
}
@Override
@PostMapping("listIsOpen4ServeIdsAndBookId")
public ResponseEntity<ResponseDto<Map<String, Boolean>>> listIsOpen4ServeIdsAndBookId(@RequestBody BookAuthServerDTO bookAuthServerDTO)
throws BizException {
Map<String, Boolean> isOpen4ServeIds = null;
if (bookAuthServerDTO != null && !bookAuthServerDTO.check()) {
isOpen4ServeIds = bookAuthServeBiz.listIsOpen4ServeIdsAndBookId(bookAuthServerDTO.getBookId(), bookAuthServerDTO.getAdviserId(), bookAuthServerDTO.getChannelId(), bookAuthServerDTO.getServeIds());
} }
return ResponseHandleUtil.toResponse(isOpen4ServeIds); return ResponseHandleUtil.toResponse(isOpen4ServeIds);
} }
......
...@@ -114,14 +114,14 @@ public class CopyrightTools { ...@@ -114,14 +114,14 @@ public class CopyrightTools {
String zipFilePath = ZIP_FILE_PATH + tempZipName + ".zip"; String zipFilePath = ZIP_FILE_PATH + tempZipName + ".zip";
String fileFolderPath = FILE_LOCAL_PATH + tempZipName; String fileFolderPath = FILE_LOCAL_PATH + tempZipName;
FileUtils.isDir(fileFolderPath); FileUtils.isDir(fileFolderPath);
UploadResultInfo uploadResultInfo = null; UploadResultInfo uploadResultInfo;
try { try {
for (BookAuthCode bookAuthCode : bookAuthCodes) { for (BookAuthCode bookAuthCode : bookAuthCodes) {
BufferedImage bi = null; BufferedImage bi;
JBarcode productBarcode = new JBarcode(Code128Encoder.getInstance(), WidthCodedPainter.getInstance(), EAN13TextPainter.getInstance()); JBarcode productBarcode = new JBarcode(Code128Encoder.getInstance(), WidthCodedPainter.getInstance(), EAN13TextPainter.getInstance());
productBarcode.setXDimension(Double.valueOf(0.5)); productBarcode.setXDimension(0.5);
productBarcode.setBarHeight(Double.valueOf(30)); productBarcode.setBarHeight(30d);
productBarcode.setWideRatio(Double.valueOf(30.0D)); productBarcode.setWideRatio(30.0D);
productBarcode.setShowText(true); productBarcode.setShowText(true);
productBarcode.setTextPainter(BaseLineTextPainter.getInstance()); productBarcode.setTextPainter(BaseLineTextPainter.getInstance());
bi = productBarcode.createBarcode(bookAuthCode.getFullCode()); bi = productBarcode.createBarcode(bookAuthCode.getFullCode());
...@@ -190,20 +190,42 @@ public class CopyrightTools { ...@@ -190,20 +190,42 @@ public class CopyrightTools {
} }
return last6Months; return last6Months;
} }
// public static void paintText(BufferedImage barCodeImage, String text) {
// //绘图
// Graphics g2d = barCodeImage.getGraphics();
// //创建字体
// Font font = new Font("console", Font.PLAIN, 15 );
// g2d.setFont(font);
// FontMetrics fm = g2d.getFontMetrics();
// int height = fm.getHeight();
// int center = (barCodeImage.getWidth() - fm.stringWidth(text)) / 2;
// g2d.setColor(Color.WHITE);
// g2d.fillRect(0, 0, barCodeImage.getWidth(), barCodeImage.getHeight() * 1 / 20);
// g2d.fillRect(0, barCodeImage.getHeight() - (height * 9 / 10), barCodeImage.getWidth(), (height * 9 / 10));
// g2d.setColor(Color.BLACK);
// g2d.drawString(text, center, barCodeImage.getHeight() - (height / 10) - 2);
// }
public static void paintText(BufferedImage barCodeImage, String text) { public static void paintText(BufferedImage barCodeImage, String text) {
//绘图 //绘图
Graphics g2d = barCodeImage.getGraphics(); Graphics g2d = barCodeImage.getGraphics();
//创建字体 //创建字体
Font font = new Font("console", Font.PLAIN, 15 ); Font font = new Font("console", Font.PLAIN, 25);
g2d.setFont(font); g2d.setFont(font);
FontMetrics fm = g2d.getFontMetrics(); FontMetrics fm = g2d.getFontMetrics();
int height = fm.getHeight(); int height = fm.getHeight();
int center = (barCodeImage.getWidth() - fm.stringWidth(text)) / 2; // int center = (barCodeImage.getWidth() - fm.stringWidth(text)) / 2;
g2d.setColor(Color.WHITE); g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, barCodeImage.getWidth(), barCodeImage.getHeight() * 1 / 20); g2d.fillRect(0, 0, barCodeImage.getWidth(), barCodeImage.getHeight() / 20);
g2d.fillRect(0, barCodeImage.getHeight() - (height * 9 / 10), barCodeImage.getWidth(), (height * 9 / 10)); g2d.fillRect(0, barCodeImage.getHeight() - (height * 9 / 10), barCodeImage.getWidth(), (height * 9 / 10));
g2d.setColor(Color.BLACK); g2d.setColor(Color.BLACK);
g2d.drawString(text, center, barCodeImage.getHeight() - (height / 10) - 2); //g2d.drawString(text, center, barCodeImage.getHeight() - (height / 10) - 2);
int start = 17;
int length = (barCodeImage.getWidth() - 2 * start) / text.length();
for (int i = 0; i < text.length(); i++) {
g2d.drawString(text.substring(i, i + 1), start + i * length, barCodeImage.getHeight() - (height / 10) - 2);
}
} }
} }
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