Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
9a571a9f
Commit
9a571a9f
authored
Jul 19, 2019
by
zhangdongwei-intern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版权保护查看序列号生成记录以及使用情况
parent
bb8231c7
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
786 additions
and
8 deletions
+786
-8
BookAuthCodeDTO.java
...n/java/com/pcloud/book/copyright/dto/BookAuthCodeDTO.java
+187
-0
BookAuthCodeBiz.java
...n/java/com/pcloud/book/copyright/biz/BookAuthCodeBiz.java
+32
-0
BookAuthCodeBizImpl.java
...m/pcloud/book/copyright/biz/impl/BookAuthCodeBizImpl.java
+262
-1
BookAuthInfoBizImpl.java
...m/pcloud/book/copyright/biz/impl/BookAuthInfoBizImpl.java
+13
-5
CopyrightConstants.java
...m/pcloud/book/copyright/constants/CopyrightConstants.java
+38
-0
BookAuthCodeDao.java
...n/java/com/pcloud/book/copyright/dao/BookAuthCodeDao.java
+26
-0
BookAuthCodeDaoImpl.java
...m/pcloud/book/copyright/dao/impl/BookAuthCodeDaoImpl.java
+20
-0
BookAuthCode.java
...n/java/com/pcloud/book/copyright/entity/BookAuthCode.java
+12
-0
BookAuthCodeFacade.java
.../com/pcloud/book/copyright/facade/BookAuthCodeFacade.java
+53
-0
BookAuthCodeFacadeImpl.java
...ud/book/copyright/facade/impl/BookAuthCodeFacadeImpl.java
+66
-0
BookAuthCode.Mapper.xml
...c/main/resources/mapper/copyright/BookAuthCode.Mapper.xml
+77
-2
No files found.
pcloud-facade-book/src/main/java/com/pcloud/book/copyright/dto/BookAuthCodeDTO.java
0 → 100644
View file @
9a571a9f
package
com
.
pcloud
.
book
.
copyright
.
dto
;
import
com.pcloud.common.dto.BaseDto
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.util.Date
;
/**
* @author hzk
* @date 2019/7/11 17:02
*/
@ApiModel
public
class
BookAuthCodeDTO
extends
BaseDto
{
private
static
final
long
serialVersionUID
=
-
2646713544720373882L
;
private
Long
id
;
@ApiModelProperty
(
"图书标识"
)
private
Long
bookId
;
@ApiModelProperty
(
"运营标识"
)
private
Long
channelId
;
@ApiModelProperty
(
"编辑标识"
)
private
Long
adviserId
;
@ApiModelProperty
(
"授权码"
)
private
String
authCode
;
@ApiModelProperty
(
"批次号"
)
private
String
batchNum
;
@ApiModelProperty
(
"完整授权码"
)
private
String
fullCode
;
@ApiModelProperty
(
"使用次数"
)
private
Integer
useCount
;
@ApiModelProperty
(
"创建方式"
)
private
Integer
createType
;
@ApiModelProperty
(
"创建人"
)
private
Long
createdUser
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createdDate
;
@ApiModelProperty
(
"最后修改人"
)
private
Long
lastModifiedUser
;
@ApiModelProperty
(
"最后修改时间"
)
private
Date
lastModifiedDate
;
public
String
getFullCode
()
{
return
fullCode
;
}
public
void
setFullCode
(
String
fullCode
)
{
this
.
fullCode
=
fullCode
;
}
public
Long
getId
()
{
return
id
;
}
public
String
getBatchNum
()
{
return
batchNum
;
}
public
void
setBatchNum
(
String
batchNum
)
{
this
.
batchNum
=
batchNum
;
}
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
getAuthCode
()
{
return
authCode
;
}
public
void
setAuthCode
(
String
authCode
)
{
this
.
authCode
=
authCode
;
}
public
Integer
getUseCount
()
{
return
useCount
;
}
public
void
setUseCount
(
Integer
useCount
)
{
this
.
useCount
=
useCount
;
}
public
Integer
getCreateType
()
{
return
createType
;
}
public
void
setCreateType
(
Integer
createType
)
{
this
.
createType
=
createType
;
}
@Override
public
Long
getCreatedUser
()
{
return
createdUser
;
}
@Override
public
void
setCreatedUser
(
Long
createdUser
)
{
this
.
createdUser
=
createdUser
;
}
@Override
public
Date
getCreatedDate
()
{
return
createdDate
;
}
@Override
public
void
setCreatedDate
(
Date
createdDate
)
{
this
.
createdDate
=
createdDate
;
}
@Override
public
Long
getLastModifiedUser
()
{
return
lastModifiedUser
;
}
@Override
public
void
setLastModifiedUser
(
Long
lastModifiedUser
)
{
this
.
lastModifiedUser
=
lastModifiedUser
;
}
@Override
public
Date
getLastModifiedDate
()
{
return
lastModifiedDate
;
}
@Override
public
void
setLastModifiedDate
(
Date
lastModifiedDate
)
{
this
.
lastModifiedDate
=
lastModifiedDate
;
}
@Override
public
String
toString
()
{
return
"BookAuthCode{"
+
"id="
+
id
+
", bookId="
+
bookId
+
", channelId="
+
channelId
+
", adviserId="
+
adviserId
+
", authCode='"
+
authCode
+
'\''
+
", batchNum='"
+
batchNum
+
'\''
+
", fullCode='"
+
fullCode
+
'\''
+
", useCount="
+
useCount
+
", createType="
+
createType
+
", createdUser="
+
createdUser
+
", createdDate="
+
createdDate
+
", lastModifiedUser="
+
lastModifiedUser
+
", lastModifiedDate="
+
lastModifiedDate
+
'}'
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/BookAuthCodeBiz.java
View file @
9a571a9f
package
com
.
pcloud
.
book
.
copyright
.
biz
;
import
com.pcloud.book.copyright.dto.BookAuthCodeDTO
;
import
com.pcloud.book.copyright.entity.BookAuthCode
;
import
com.pcloud.book.copyright.vo.CheckCodeParam
;
import
com.pcloud.book.copyright.vo.CheckIsAuthServeParam
;
...
...
@@ -7,8 +8,10 @@ import com.pcloud.book.copyright.vo.FileVO;
import
com.pcloud.book.copyright.vo.ImportRecordVO
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author lily
...
...
@@ -51,4 +54,33 @@ public interface BookAuthCodeBiz {
* @Date:2019/5/22 18:02
*/
PageBeanNew
<
ImportRecordVO
>
importCodeRecord
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
Integer
currentPage
,
Integer
numPerPage
);
/**
* 获取正版授权码
* @param bookId
* @param channelId
* @param keyword
* @param state
* @param pageParam
* @return
*/
PageBeanNew
<
BookAuthCodeDTO
>
getCodeList
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
keyword
,
Integer
state
,
PageParam
pageParam
);
/**
* 批量删除正版授权码
* @param ids
*/
void
batchDeleteCode
(
List
<
Long
>
ids
);
/**
* 导出授权码
* @param bookId
* @param codeIds
* @param channelId
* @param status
* @param systemCode
* @param partyId
* @return
*/
Map
<
String
,
Object
>
getCodeExcel
(
Long
bookId
,
String
codeIds
,
Long
channelId
,
Long
status
,
String
systemCode
,
Long
partyId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/impl/BookAuthCodeBizImpl.java
View file @
9a571a9f
...
...
@@ -6,14 +6,17 @@ import com.pcloud.book.base.exception.BookBizException;
import
com.pcloud.book.book.biz.BookBiz
;
import
com.pcloud.book.book.dto.BookDto
;
import
com.pcloud.book.consumer.channel.QrcodeSceneConsr
;
import
com.pcloud.book.consumer.common.ExportConsr
;
import
com.pcloud.book.consumer.reader.ReaderConsr
;
import
com.pcloud.book.copyright.biz.BookAuthCodeBiz
;
import
com.pcloud.book.copyright.biz.BookAuthInfoBiz
;
import
com.pcloud.book.copyright.biz.BookAuthServeBiz
;
import
com.pcloud.book.copyright.biz.BookAuthUserBiz
;
import
com.pcloud.book.copyright.constants.CopyrightConstants
;
import
com.pcloud.book.copyright.constants.ImportAuthCodeStatus
;
import
com.pcloud.book.copyright.dao.BookAuthCodeDao
;
import
com.pcloud.book.copyright.dao.BookAuthCodeImportRecordDao
;
import
com.pcloud.book.copyright.dto.BookAuthCodeDTO
;
import
com.pcloud.book.copyright.entity.BookAuthCode
;
import
com.pcloud.book.copyright.entity.BookAuthCodeImportRecord
;
import
com.pcloud.book.copyright.entity.BookAuthUser
;
...
...
@@ -28,27 +31,52 @@ import com.pcloud.common.core.biz.MessageBiz;
import
com.pcloud.common.core.constant.SystemCode
;
import
com.pcloud.common.core.dto.SendNotifyDto
;
import
com.pcloud.common.core.enums.NotifyOriginTypeEnum
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.ExportException
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.aliyun.OssUtils
;
import
com.pcloud.common.utils.json.JSONUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.readercenter.wechat.entity.WechatUser
;
import
com.pcloud.resourcecenter.base.exceptions.ResBizException
;
import
com.pcloud.settlementcenter.record.exceptions.RecordException
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.streaming.SXSSFCell
;
import
org.apache.poi.xssf.streaming.SXSSFRow
;
import
org.apache.poi.xssf.streaming.SXSSFSheet
;
import
org.apache.poi.xssf.streaming.SXSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
static
com
.
pcloud
.
book
.
util
.
common
.
ExcelUtils
.
getColumnTopStyle
;
import
static
com
.
pcloud
.
book
.
util
.
common
.
ExcelUtils
.
getDataStyle
;
/**
* @author lily
* @date 2018/12/4 19:11
...
...
@@ -78,6 +106,8 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
private
BookBiz
bookBiz
;
@Autowired
private
MessageBiz
messageBiz
;
@Autowired
private
ExportConsr
exportConsr
;
@Override
@ParamLog
(
value
=
"批量插入授权码"
,
isBefore
=
false
)
...
...
@@ -149,7 +179,9 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
List
<
Long
>
serveIds
=
new
ArrayList
<>();
serveIds
.
add
(
serveId
);
Map
<
String
,
Boolean
>
isHaveServe
=
qrcodeSceneConsr
.
listIsInBook
(
bookId
,
channelId
,
adviserId
,
serveIds
);
if
(
isHaveServe
==
null
)
return
false
;
if
(
isHaveServe
==
null
)
{
return
false
;
}
//校验服务是否需要授权
Boolean
isNeedAuth
=
bookAuthServeBiz
.
checkIsNeedAuth
(
bookId
,
channelId
,
adviserId
,
serveId
,
serveType
);
if
(!
isNeedAuth
)
{
...
...
@@ -195,6 +227,7 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
bookAuthCode
.
setBatchNum
(
fullCode
.
substring
(
0
,
4
));
bookAuthCode
.
setAuthCode
(
fullCode
.
substring
(
4
,
data
[
i
][
1
].
length
()));
bookAuthCode
.
setUseCount
(
0
);
bookAuthCode
.
setCreateType
(
1
);
bookAuthCode
.
setCreatedUser
(
adviserId
);
bookAuthCodes
.
add
(
bookAuthCode
);
}
...
...
@@ -259,4 +292,232 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
bookAuthUserBiz
.
insert
(
bookAuthUser
);
}
/**
* 获取正版授权码
* @param bookId
* @param channelId
* @param keyword
* @param state
* @param pageParam
* @return
*/
@Override
@ParamLog
(
"获取正版授权码"
)
public
PageBeanNew
<
BookAuthCodeDTO
>
getCodeList
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
keyword
,
Integer
state
,
PageParam
pageParam
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"bookId"
,
bookId
);
paramMap
.
put
(
"channelId"
,
channelId
);
paramMap
.
put
(
"adviserId"
,
adviserId
);
paramMap
.
put
(
"keyword"
,
StringUtil
.
isEmpty
(
keyword
)?
null
:
keyword
);
paramMap
.
put
(
"state"
,
state
);
return
bookAuthCodeDao
.
listPageNew
(
pageParam
,
paramMap
,
"getCodeList"
);
}
/**
* 批量删除正版授权码
* @param ids
*/
@Override
@ParamLog
(
"批量删除正版授权码"
)
public
void
batchDeleteCode
(
List
<
Long
>
ids
)
{
bookAuthCodeDao
.
batchDeleteCode
(
ids
);
}
@Override
@ParamLog
(
"导出授权码"
)
public
Map
<
String
,
Object
>
getCodeExcel
(
Long
bookId
,
String
codeIds
,
Long
channelId
,
Long
status
,
String
systemCode
,
Long
partyId
)
{
//获取书的基本信息
BookDto
bookDto
=
bookBiz
.
getBaseById
(
bookId
);
if
(
null
==
bookDto
||
null
==
bookDto
.
getBookId
()){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"授权码所对应的书不存在"
);
}
//表名
String
title
=
"《"
+
bookDto
.
getBookName
()
+
"》"
+
"的授权码"
;
String
[]
rowsName
=
{
"序号"
,
"授权码"
,
"完整授权码"
,
"生成方式"
,
"状态"
,
"创建时间"
};
String
fileUrl
=
""
;
String
finalTitle
=
title
;
//不管是全部导出还是导出部分,都使用异步处理
if
(
status
==
0
)
{
EXECUTOR_SERVICE
.
execute
(()
->
{
String
filePath
=
this
.
exportAllFreeCode
(
finalTitle
,
rowsName
,
bookId
,
channelId
,
partyId
);
//发送站内信
SendNotifyDto
sendNotifyDto
=
new
SendNotifyDto
();
sendNotifyDto
.
setCreatedTime
(
new
Date
());
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"commitTime"
,
DateUtils
.
getSysDateTimeString
());
content
.
put
(
"type"
,
StringUtil
.
addBracket
(
bookDto
.
getBookName
()));
sendNotifyDto
.
setNotifyContent
(
content
.
toJSONString
());
sendNotifyDto
.
setToId
(
partyId
);
sendNotifyDto
.
setFromId
(
partyId
);
sendNotifyDto
.
setSystemCode
(
systemCode
);
sendNotifyDto
.
setTypeCode
(
"genuine_qrcord_download"
);
sendNotifyDto
.
setFileName
(
bookDto
.
getBookName
());
sendNotifyDto
.
setResourceId
(
filePath
);
messageBiz
.
sendLetter
(
sendNotifyDto
);
});
}
else
if
(
status
==
1
)
{
EXECUTOR_SERVICE
.
execute
(()
->
{
String
filePath
=
this
.
exportFreeCodeSelected
(
finalTitle
,
rowsName
,
codeIds
);
//发送站内信
SendNotifyDto
sendNotifyDto
=
new
SendNotifyDto
();
sendNotifyDto
.
setCreatedTime
(
new
Date
());
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"commitTime"
,
DateUtils
.
getSysDateTimeString
());
map
.
put
(
"type"
,
StringUtil
.
addBracket
(
bookDto
.
getBookName
()));
String
content
=
JSONUtils
.
toJsonString
(
map
);
sendNotifyDto
.
setNotifyContent
(
content
);
sendNotifyDto
.
setFileName
(
finalTitle
);
sendNotifyDto
.
setFromId
(
partyId
);
sendNotifyDto
.
setToId
(
partyId
);
sendNotifyDto
.
setSystemCode
(
systemCode
);
sendNotifyDto
.
setTypeCode
(
"genuine_qrcord_download"
);
sendNotifyDto
.
setFileName
(
bookDto
.
getBookName
());
sendNotifyDto
.
setResourceId
(
filePath
);
messageBiz
.
sendLetter
(
sendNotifyDto
);
});
}
Map
<
String
,
Object
>
returnInfo
=
new
HashMap
<>();
returnInfo
.
put
(
"fileUrl"
,
fileUrl
);
returnInfo
.
put
(
"fileName"
,
title
);
return
returnInfo
;
}
/**
* 导出选中的授权码
* @param title
* @param rowsName
* @param codeIds
* @return
*/
private
String
exportFreeCodeSelected
(
String
title
,
String
[]
rowsName
,
String
codeIds
){
//导出选中的
List
<
String
>
rowsNameList
=
Arrays
.
asList
(
rowsName
);
List
<
Object
[]>
dataList
=
new
ArrayList
<>();
String
fileUrl
=
""
;
if
(!
StringUtils
.
isBlank
(
codeIds
))
{
//切割CodeIds
String
[]
codeId
=
codeIds
.
split
(
","
);
//根据购物码id查询购物码信息
for
(
int
i
=
0
;
i
<
codeId
.
length
;
i
++)
{
BookAuthCodeDTO
bookAuthCode
=
bookAuthCodeDao
.
getBaseById
(
Long
.
parseLong
(
codeId
[
i
]));
if
(
null
==
bookAuthCode
)
{
throw
new
ResBizException
(
ResBizException
.
PARAM_IS_ERROR
,
"授权码不存在"
);
}
Object
[]
objs
=
new
Object
[
rowsNameList
.
size
()];
objs
[
0
]
=
i
+
1
;
objs
[
1
]
=
bookAuthCode
.
getAuthCode
();
objs
[
2
]
=
bookAuthCode
.
getFullCode
();
CopyrightConstants
.
CreateType
createType
=
CopyrightConstants
.
CreateType
.
CRATE_TYPE_MAP
.
get
(
bookAuthCode
.
getCreateType
());
objs
[
3
]
=
null
==
createType
?
"-"
:
createType
.
getName
();
objs
[
4
]
=
bookAuthCode
.
getUseCount
()
>
0
?
"已使用"
:
"未使用"
;
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
objs
[
5
]
=
bookAuthCode
.
getCreatedDate
()
!=
null
?
df
.
format
(
bookAuthCode
.
getCreatedDate
())
:
""
;
dataList
.
add
(
objs
);
fileUrl
=
exportConsr
.
exportExcel
(
title
,
rowsName
,
dataList
);
}
}
else
{
throw
new
ResBizException
(
ResBizException
.
PARAM_IS_ERROR
,
"授权码不存在"
);
}
return
fileUrl
;
}
/**
* 导出所有授权码
* @param title
* @param rowsName
* @param bookId
* @param channelId
* @param partyId
* @return
*/
private
String
exportAllFreeCode
(
String
title
,
String
[]
rowsName
,
Long
bookId
,
Long
channelId
,
Long
partyId
)
{
SXSSFWorkbook
wb
=
new
SXSSFWorkbook
(
200
);
int
columnNum
=
rowsName
.
length
;
int
rowIndex
=
0
;
SXSSFRow
row
;
SXSSFCell
cell
;
//设置表头样式
CellStyle
headerStyle
=
getColumnTopStyle
(
wb
);
SXSSFSheet
sheet
=
wb
.
createSheet
();
row
=
sheet
.
createRow
(
rowIndex
);
cell
=
row
.
createCell
(
0
);
//合并前两行
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
rowIndex
,
++
rowIndex
,
0
,
columnNum
-
1
));
cell
.
setCellStyle
(
headerStyle
);
cell
.
setCellValue
(
title
);
//设置属性
row
=
sheet
.
createRow
(++
rowIndex
);
for
(
int
i
=
0
;
i
<
rowsName
.
length
;
++
i
)
{
sheet
.
setColumnWidth
(
i
,
20
*
256
);
cell
=
row
.
createCell
(
i
);
cell
.
setCellStyle
(
headerStyle
);
cell
.
setCellValue
(
rowsName
[
i
]);
}
//设置数据样式
CellStyle
dataStyle
=
getDataStyle
(
wb
);
dataStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"bookId"
,
bookId
);
paramMap
.
put
(
"channelId"
,
channelId
);
paramMap
.
put
(
"adviserId"
,
partyId
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
int
k
=
1
;
//分批导出
for
(
int
j
=
0
;
true
;
j
++)
{
paramMap
.
put
(
"currentPage"
,
j
*
500
);
paramMap
.
put
(
"numPerPage"
,
500
);
List
<
BookAuthCodeDTO
>
bookAuthCodeDtos
=
bookAuthCodeDao
.
getBookAuthCodeList
(
paramMap
);
if
(!
ListUtils
.
isEmpty
(
bookAuthCodeDtos
))
{
for
(
BookAuthCodeDTO
bookAuthCodeDTO
:
bookAuthCodeDtos
)
{
SXSSFRow
srow
=
sheet
.
createRow
(++
rowIndex
);
SXSSFCell
cell0
=
srow
.
createCell
(
0
);
cell0
.
setCellStyle
(
dataStyle
);
cell0
.
setCellValue
(
k
++);
SXSSFCell
cell1
=
srow
.
createCell
(
1
);
cell1
.
setCellStyle
(
dataStyle
);
cell1
.
setCellValue
(
bookAuthCodeDTO
.
getAuthCode
());
SXSSFCell
cell2
=
srow
.
createCell
(
2
);
cell2
.
setCellStyle
(
dataStyle
);
cell2
.
setCellValue
(
bookAuthCodeDTO
.
getFullCode
());
SXSSFCell
cell3
=
srow
.
createCell
(
3
);
cell3
.
setCellStyle
(
dataStyle
);
CopyrightConstants
.
CreateType
createType
=
CopyrightConstants
.
CreateType
.
CRATE_TYPE_MAP
.
get
(
bookAuthCodeDTO
.
getCreateType
());
cell3
.
setCellValue
(
null
==
createType
?
"-"
:
createType
.
getName
());
SXSSFCell
cell4
=
srow
.
createCell
(
4
);
cell4
.
setCellStyle
(
dataStyle
);
cell4
.
setCellValue
(
bookAuthCodeDTO
.
getUseCount
()
>
0
?
"已使用"
:
"未使用"
);
SXSSFCell
cell5
=
srow
.
createCell
(
5
);
cell5
.
setCellStyle
(
dataStyle
);
cell5
.
setCellValue
(
bookAuthCodeDTO
.
getCreatedDate
()
!=
null
?
df
.
format
(
bookAuthCodeDTO
.
getCreatedDate
())
:
""
);
}
}
if
(
bookAuthCodeDtos
.
size
()
<
500
)
{
break
;
}
bookAuthCodeDtos
.
clear
();
}
//上传文件
String
fileUrl
=
""
;
try
{
String
UID
=
UUID
.
randomUUID
().
toString
();
String
path
=
UID
+
".xlsx"
;
FileOutputStream
fileOut
=
new
FileOutputStream
(
path
);
wb
.
write
(
fileOut
);
fileOut
.
flush
();
fileOut
.
close
();
wb
.
close
();
UploadResultInfo
uploadResultInfo
=
OssUtils
.
uploadLocalFile
(
path
,
"xlsx"
);
fileUrl
=
uploadResultInfo
.
getUrl
();
LOGGER
.
info
(
"=======fileUrl=========="
+
OssUtils
.
urlAddKeyLong
(
fileUrl
));
new
File
(
path
).
delete
();
}
catch
(
FileNotFoundException
e
)
{
LOGGER
.
error
(
"临时文件Excel路径找不到"
+
e
.
getMessage
(),
e
);
throw
new
ExportException
(
RecordException
.
ERROR
,
"导出Excel失败"
);
}
catch
(
IOException
e
)
{
LOGGER
.
error
(
"生成临时文件Excel异常"
+
e
.
getMessage
(),
e
);
throw
new
ExportException
(
RecordException
.
ERROR
,
"导出Excel失败"
);
}
return
fileUrl
;
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/impl/BookAuthInfoBizImpl.java
View file @
9a571a9f
...
...
@@ -162,7 +162,9 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
insertExportRecord
(
bookId
,
channelId
,
adviserId
,
num
);
//获取图书名称
BookDto
bookDto
=
bookBiz
.
getBaseById
(
bookId
);
if
(
bookDto
==
null
)
return
;
if
(
bookDto
==
null
)
{
return
;
}
//获取随机数
List
<
String
>
uuids
=
CopyrightTools
.
createShortUuidByCount
(
codeCount
);
List
<
BookAuthCode
>
bookAuthCodes
=
new
ArrayList
<>();
...
...
@@ -174,11 +176,12 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
bookAuthCode
.
setAuthCode
(
uuid
);
bookAuthCode
.
setFullCode
(
num
+
uuid
);
bookAuthCode
.
setBatchNum
(
num
);
bookAuthCode
.
setCreateType
(
0
);
bookAuthCode
.
setCreatedUser
(
adviserId
);
bookAuthCodes
.
add
(
bookAuthCode
);
}
bookAuthCodeBiz
.
insert
(
bookAuthCodes
);
String
noticeUrl
=
""
;
String
noticeUrl
;
if
(
isHaveBarCode
==
null
||
isHaveBarCode
.
equals
(
0
)){
String
url
=
generateExcel
(
bookAuthCodes
,
bookDto
.
getBookName
());
String
zipUrl
=
CopyrightTools
.
generateBar4Zip
(
bookAuthCodes
,
bookDto
.
getBookName
(),
url
);
...
...
@@ -187,7 +190,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
String
url
=
generateExcel
(
bookAuthCodes
,
bookDto
.
getBookName
());
String
zipUrl
=
CopyrightTools
.
generateQrcode4Zip
(
bookAuthCodes
,
bookDto
.
getBookName
(),
url
);
noticeUrl
=
zipUrl
;
}
else
{
}
else
{
String
url
=
generateExcel
(
bookAuthCodes
,
bookDto
.
getBookName
());
noticeUrl
=
url
;
}
...
...
@@ -249,7 +252,9 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
@ParamLog
(
"修改导出记录"
)
private
void
updateExportRecord
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
num
,
Integer
exportStatus
)
{
if
(
StringUtil
.
isEmpty
(
num
))
return
;
if
(
StringUtil
.
isEmpty
(
num
))
{
return
;
}
BookExportRecord
bookExportRecord
=
new
BookExportRecord
();
bookExportRecord
.
setBookId
(
bookId
);
bookExportRecord
.
setAdviserId
(
adviserId
);
...
...
@@ -402,7 +407,9 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
}
private
void
removeNotInbook
(
List
<
ServeVO
>
serves
,
Long
bookId
,
Long
channelId
,
Long
adviserId
)
{
if
(
ListUtils
.
isEmpty
(
serves
))
return
;
if
(
ListUtils
.
isEmpty
(
serves
))
{
return
;
}
List
<
Long
>
serveIds
=
new
ArrayList
<>();
for
(
ServeVO
serveVO
:
serves
)
{
serveIds
.
add
(
serveVO
.
getServeId
());
...
...
@@ -466,6 +473,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
return
bookAuthInfoWechatVO
;
}
@Override
@ParamLog
(
"获取授权图书信息"
)
public
BookAuthInfoVO
getAuthBookInfo
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
Long
sceneId
){
if
(
bookId
==
null
&&
adviserId
==
null
&&
sceneId
==
null
){
...
...
pcloud-service-book/src/main/java/com/pcloud/book/copyright/constants/CopyrightConstants.java
View file @
9a571a9f
...
...
@@ -2,6 +2,9 @@ package com.pcloud.book.copyright.constants;
import
com.pcloud.common.constant.CacheConstant
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author lily
* @date 2018/12/5 21:08
...
...
@@ -10,4 +13,39 @@ public class CopyrightConstants {
public
static
final
String
BOOK_AUTH_INFO
=
CacheConstant
.
BOOK
+
"BOOK_AUTH_INFO"
;
public
enum
CreateType
{
/**
* 自动创建
*/
AUTO_CREATE
(
0
,
"自动创建"
),
/**
* 批量导入
*/
BATCH_IMPORT
(
1
,
"批量导入"
);
private
Integer
value
;
private
String
name
;
CreateType
(
Integer
value
,
String
name
){
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
public
static
final
Map
<
Integer
,
CreateType
>
CRATE_TYPE_MAP
;
static
{
CRATE_TYPE_MAP
=
new
HashMap
<>();
CRATE_TYPE_MAP
.
put
(
0
,
AUTO_CREATE
);
CRATE_TYPE_MAP
.
put
(
1
,
BATCH_IMPORT
);
}
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/dao/BookAuthCodeDao.java
View file @
9a571a9f
package
com
.
pcloud
.
book
.
copyright
.
dao
;
import
com.pcloud.book.copyright.dto.BookAuthCodeDTO
;
import
com.pcloud.book.copyright.entity.BookAuthCode
;
import
com.pcloud.common.core.dao.BaseDao
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author lily
...
...
@@ -22,4 +28,24 @@ public interface BookAuthCodeDao extends BaseDao<BookAuthCode> {
* 获取码数量
*/
Boolean
getIsHaveCode
(
Long
bookId
,
Long
channelId
,
Long
adviserId
,
String
code
);
/**
* 批量删除正版授权码
* @param ids
*/
void
batchDeleteCode
(
List
<
Long
>
ids
);
/**
* 获取授权码列表
* @param paramMap
* @return
*/
List
<
BookAuthCodeDTO
>
getBookAuthCodeList
(
Map
<
String
,
Object
>
paramMap
);
/**
* 根据主键获取授权码
* @param codeId
* @return
*/
BookAuthCodeDTO
getBaseById
(
Long
codeId
);
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/dao/impl/BookAuthCodeDaoImpl.java
View file @
9a571a9f
package
com
.
pcloud
.
book
.
copyright
.
dao
.
impl
;
import
com.pcloud.book.copyright.dao.BookAuthCodeDao
;
import
com.pcloud.book.copyright.dto.BookAuthCodeDTO
;
import
com.pcloud.book.copyright.entity.BookAuthCode
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
com.pcloud.common.page.PageBeanNew
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -44,4 +47,21 @@ public class BookAuthCodeDaoImpl extends BaseDaoImpl<BookAuthCode> implements Bo
paramMap
.
put
(
"code"
,
code
);
return
this
.
getSqlSession
().
selectOne
(
this
.
getStatement
(
"getIsHaveCode"
),
paramMap
);
}
@Override
public
void
batchDeleteCode
(
List
<
Long
>
ids
)
{
this
.
getSqlSession
().
delete
(
this
.
getStatement
(
"batchDeleteCode"
),
ids
);
}
@Override
public
List
<
BookAuthCodeDTO
>
getBookAuthCodeList
(
Map
<
String
,
Object
>
paramMap
)
{
return
this
.
getSessionTemplate
().
selectList
(
this
.
getStatement
(
"getBookAuthCodeList"
),
paramMap
);
}
@Override
public
BookAuthCodeDTO
getBaseById
(
Long
codeId
)
{
return
this
.
getSessionTemplate
().
selectOne
(
this
.
getStatement
(
"getBaseById"
),
codeId
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/entity/BookAuthCode.java
View file @
9a571a9f
...
...
@@ -36,6 +36,9 @@ public class BookAuthCode extends BaseEntity {
@ApiModelProperty
(
"使用次数"
)
private
Integer
useCount
;
@ApiModelProperty
(
"创建方式"
)
private
Integer
createType
;
@ApiModelProperty
(
"创建人"
)
private
Long
createdUser
;
...
...
@@ -114,6 +117,14 @@ public class BookAuthCode extends BaseEntity {
this
.
useCount
=
useCount
;
}
public
Integer
getCreateType
()
{
return
createType
;
}
public
void
setCreateType
(
Integer
createType
)
{
this
.
createType
=
createType
;
}
public
Long
getCreatedUser
()
{
return
createdUser
;
}
...
...
@@ -157,6 +168,7 @@ public class BookAuthCode extends BaseEntity {
", batchNum='"
+
batchNum
+
'\''
+
", fullCode='"
+
fullCode
+
'\''
+
", useCount="
+
useCount
+
", createType="
+
createType
+
", createdUser="
+
createdUser
+
", createdDate="
+
createdDate
+
", lastModifiedUser="
+
lastModifiedUser
+
...
...
pcloud-service-book/src/main/java/com/pcloud/book/copyright/facade/BookAuthCodeFacade.java
View file @
9a571a9f
package
com
.
pcloud
.
book
.
copyright
.
facade
;
import
com.pcloud.book.copyright.dto.BookAuthCodeDTO
;
import
com.pcloud.book.copyright.vo.CheckCodeParam
;
import
com.pcloud.book.copyright.vo.CheckIsAuthServeParam
;
import
com.pcloud.book.copyright.vo.CodeUseStatusVO
;
...
...
@@ -10,7 +11,11 @@ import com.pcloud.common.exceptions.BizException;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.permission.PermissionException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.codehaus.jackson.JsonParseException
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
...
...
@@ -18,6 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
/**
* @author lily
* @date 2018/11/29 16:58
...
...
@@ -44,4 +51,50 @@ public interface BookAuthCodeFacade {
@RequestMapping
(
value
=
"importCodeRecord"
,
method
=
RequestMethod
.
GET
)
ResponseDto
<
PageBeanNew
<
ImportRecordVO
>>
importCodeRecord
(
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
"bookId"
)
Long
bookId
,
@RequestParam
(
"channelId"
)
Long
channelId
,
@RequestParam
(
"currentPage"
)
Integer
currenPage
,
@RequestParam
(
"numPerPage"
)
Integer
numPerPage
)
throws
PermissionException
,
BizException
;
@ApiOperation
(
value
=
"获取授权码列表"
,
httpMethod
=
"GET"
)
@RequestMapping
(
value
=
"getCodeList"
,
method
=
RequestMethod
.
GET
)
ResponseDto
<
PageBeanNew
<
BookAuthCodeDTO
>>
getCodeList
(
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
"bookId"
)
Long
bookId
,
@RequestParam
(
"channelId"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
value
=
"keyword"
)
String
keyword
,
@RequestParam
(
required
=
false
,
value
=
"state"
)
Integer
state
,
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"numPerPage"
)
Integer
numPerPage
)
throws
PermissionException
,
BizException
;
@ApiOperation
(
value
=
"批量删除正版授权码"
,
httpMethod
=
"POST"
)
@RequestMapping
(
value
=
"batchDeleteCode"
,
method
=
RequestMethod
.
POST
)
ResponseDto
<
PageBeanNew
<
BookAuthCodeDTO
>>
batchDeleteCode
(
@RequestHeader
(
"token"
)
String
token
,
@RequestBody
List
<
Long
>
ids
)
throws
PermissionException
,
BizException
;
/**
* 导出授权码
* @param token
* @param bookId
* @param codeIds
* @param channelId
* @param status
* @return
* @throws PermissionException
* @throws JsonParseException
* @throws BizException
*/
@ApiOperation
(
value
=
"导出授权码"
,
httpMethod
=
"GET"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"token"
,
value
=
"token"
,
dataType
=
"String"
,
paramType
=
"header"
),
@ApiImplicitParam
(
name
=
"bookId"
,
value
=
"书ID"
,
dataType
=
"long"
,
paramType
=
"query"
),
@ApiImplicitParam
(
name
=
"codeIds"
,
value
=
"授权码ID(用“,”隔开)"
,
dataType
=
"String"
,
paramType
=
"query"
),
@ApiImplicitParam
(
name
=
"channelId"
,
value
=
"商品ID"
,
dataType
=
"long"
,
paramType
=
"query"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"查询状态(0-全部导出,1-部分导出)"
,
dataType
=
"long"
,
paramType
=
"query"
)
})
@RequestMapping
(
value
=
"/exportCode"
,
method
=
RequestMethod
.
GET
)
ResponseDto
<?>
exportCode
(
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
required
=
false
,
value
=
"bookId"
)
Long
bookId
,
@RequestParam
(
required
=
false
,
value
=
"codeIds"
)
String
codeIds
,
@RequestParam
(
required
=
false
,
value
=
"channelId"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
value
=
"status"
)
Long
status
)
throws
PermissionException
,
JsonParseException
,
BizException
;
}
pcloud-service-book/src/main/java/com/pcloud/book/copyright/facade/impl/BookAuthCodeFacadeImpl.java
View file @
9a571a9f
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.dto.BookAuthCodeDTO
;
import
com.pcloud.book.copyright.facade.BookAuthCodeFacade
;
import
com.pcloud.book.copyright.vo.CheckCodeParam
;
import
com.pcloud.book.copyright.vo.CheckIsAuthServeParam
;
...
...
@@ -10,9 +12,14 @@ import com.pcloud.book.copyright.vo.ImportRecordVO;
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.ListUtils
;
import
com.pcloud.common.utils.SessionUtil
;
import
com.pcloud.common.utils.cookie.Cookie
;
import
org.apache.commons.lang3.StringUtils
;
import
org.codehaus.jackson.JsonParseException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.CookieValue
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -24,6 +31,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author lily
* @date 2018/11/29 16:59
...
...
@@ -76,4 +86,60 @@ public class BookAuthCodeFacadeImpl implements BookAuthCodeFacade {
PageBeanNew
<
ImportRecordVO
>
pageBean
=
bookAuthCodeBiz
.
importCodeRecord
(
bookId
,
channelId
,
adviserId
,
currenPage
,
numPerPage
);
return
new
ResponseDto
<>(
pageBean
);
}
@Override
@GetMapping
(
"getCodeList"
)
public
ResponseDto
<
PageBeanNew
<
BookAuthCodeDTO
>>
getCodeList
(
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
required
=
false
,
value
=
"bookId"
)
Long
bookId
,
@RequestParam
(
required
=
false
,
value
=
"channelId"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
value
=
"keyword"
)
String
keyword
,
@RequestParam
(
required
=
false
,
value
=
"state"
)
Integer
state
,
@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
);
if
(
null
==
bookId
||
null
==
channelId
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数有误!"
);
}
if
(
null
==
currentPage
||
null
==
numPerPage
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数有误!"
);
}
PageParam
pageParam
=
new
PageParam
(
currentPage
,
numPerPage
);
return
new
ResponseDto
<>(
bookAuthCodeBiz
.
getCodeList
(
bookId
,
channelId
,
adviserId
,
keyword
,
state
,
pageParam
));
}
/**
* 批量删除正版授权码
* @param token
* @param ids
* @return
* @throws PermissionException
* @throws BizException
*/
@Override
public
ResponseDto
<
PageBeanNew
<
BookAuthCodeDTO
>>
batchDeleteCode
(
@RequestHeader
String
token
,
@RequestBody
List
<
Long
>
ids
)
throws
PermissionException
,
BizException
{
if
(
ListUtils
.
isEmpty
(
ids
)){
return
new
ResponseDto
<>();
}
bookAuthCodeBiz
.
batchDeleteCode
(
ids
);
return
new
ResponseDto
<>();
}
@Override
@RequestMapping
(
value
=
"/exportCode"
,
method
=
RequestMethod
.
GET
)
public
ResponseDto
<?>
exportCode
(
@RequestHeader
(
"token"
)
String
token
,
@RequestParam
(
required
=
false
,
value
=
"bookId"
)
Long
bookId
,
@RequestParam
(
required
=
false
,
value
=
"codeIds"
)
String
codeIds
,
@RequestParam
(
required
=
false
,
value
=
"channelId"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
value
=
"status"
)
Long
status
)
throws
PermissionException
,
JsonParseException
,
BizException
{
String
systemCode
=
(
String
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
SYSTEM_CODE
);
Long
partyId
=
(
Long
)
SessionUtil
.
getVlaue
(
token
,
SessionUtil
.
PARTY_ID
);
//校验参数
if
(
null
==
status
||
null
==
bookId
||
null
==
channelId
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"参数错误"
);
}
Map
<
String
,
Object
>
map
=
bookAuthCodeBiz
.
getCodeExcel
(
bookId
,
codeIds
,
channelId
,
status
,
systemCode
,
partyId
);
return
new
ResponseDto
<>(
map
);
}
}
pcloud-service-book/src/main/resources/mapper/copyright/BookAuthCode.Mapper.xml
View file @
9a571a9f
...
...
@@ -4,13 +4,13 @@
<insert
id=
"batchInsert"
useGeneratedKeys=
"true"
parameterType=
"java.util.List"
>
INSERT INTO BOOK_AUTH_CODE (
BOOK_ID, CHANNEL_ID,ADVISER_ID,BATCH_NUM,AUTH_CODE,FULL_CODE,CREATED_USER, CREATED_DATE
BOOK_ID, CHANNEL_ID,ADVISER_ID,BATCH_NUM,AUTH_CODE,FULL_CODE,CREATE
_TYPE,CREATE
D_USER, CREATED_DATE
)
VALUES
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(#{item.bookId,jdbcType=BIGINT}, #{item.channelId,jdbcType=BIGINT}, #{item.adviserId,jdbcType=BIGINT},
#{item.batchNum,jdbcType=VARCHAR},#{item.authCode,jdbcType=VARCHAR},#{item.fullCode,jdbcType=VARCHAR},
#{item.adviserId,jdbcType=BIGINT}, NOW())
#{item.
createType,jdbcType=TINYINT},#{item.
adviserId,jdbcType=BIGINT}, NOW())
</foreach>
</insert>
...
...
@@ -60,4 +60,78 @@
AND
FULL_CODE = #{code}
</select>
<select
id=
"getCodeList"
parameterType=
"map"
resultType=
"com.pcloud.book.copyright.dto.BookAuthCodeDTO"
>
SELECT
id id,
book_id bookId,
channel_id channelId,
adviser_id adviserId,
auth_code authCode,
batch_num batchNum,
full_code fullCode,
use_count useCount,
create_type createType,
created_date createdDate
FROM
book_auth_code
WHERE
book_id = #{bookId}
AND channel_id = #{channelId}
AND adviser_id = #{adviserId}
<if
test=
"keyword != null"
>
AND full_code LIKE CONCAT('%', #{keyword}, '%')
</if>
<if
test=
"state != null"
>
<choose>
<when
test=
"state == 0"
>
and use_count = 0
</when>
<otherwise>
and use_count > 0
</otherwise>
</choose>
</if>
order by created_date desc
</select>
<delete
id=
"batchDeleteCode"
parameterType=
"list"
>
DELETE FROM book_auth_code
WHERE id in
<foreach
collection=
"list"
open=
"("
item=
"item"
close=
")"
separator=
","
>
${item}
</foreach>
AND use_count = 0
</delete>
<select
id=
"getBookAuthCodeList"
parameterType=
"map"
resultType=
"com.pcloud.book.copyright.dto.BookAuthCodeDTO"
>
select
book_id bookId,
channel_id channelId,
adviser_id adviserId,
create_type createType,
auth_code authCode,
batch_num batchNum,
full_code fullCode,
use_count useCount,
created_date createdDate
from book_auth_code
where book_id= #{bookId,jdbcType=BIGINT} and channel_id = #{channelId} and adviser_id = #{adviserId}
LIMIT #{currentPage},#{numPerPage}
</select>
<select
id=
"getBaseById"
parameterType=
"long"
resultType=
"com.pcloud.book.copyright.dto.BookAuthCodeDTO"
>
select
book_id bookId,
channel_id channelId,
adviser_id adviserId,
create_type createType,
auth_code authCode,
batch_num batchNum,
full_code fullCode,
use_count useCount,
created_date createdDate
from book_auth_code
where id = #{codeId}
</select>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment