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
332c9009
Commit
332c9009
authored
Apr 01, 2020
by
阮思源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【ID1002690】读者书刊搜索优化:/search/getUserSearchList4H5
parent
92a0073d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
281 additions
and
46 deletions
+281
-46
SearchBiz.java
...ook/src/main/java/com/pcloud/book/book/biz/SearchBiz.java
+2
-0
SearchBizImpl.java
...ain/java/com/pcloud/book/book/biz/impl/SearchBizImpl.java
+26
-1
SearchRecordDisDao.java
...ain/java/com/pcloud/book/book/dao/SearchRecordDisDao.java
+12
-0
SearchRecordDisDaoImpl.java
...com/pcloud/book/book/dao/impl/SearchRecordDisDaoImpl.java
+38
-0
SearchRecordDis.java
...ain/java/com/pcloud/book/book/entity/SearchRecordDis.java
+51
-0
BookKeywordBizImpl.java
...com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
+4
-0
SearchRecord.xml
...vice-book/src/main/resources/mapper/book/SearchRecord.xml
+0
-45
SearchRecordDis.xml
...e-book/src/main/resources/mapper/book/SearchRecordDis.xml
+148
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/book/biz/SearchBiz.java
View file @
332c9009
...
@@ -34,4 +34,6 @@ public interface SearchBiz {
...
@@ -34,4 +34,6 @@ public interface SearchBiz {
List
<
String
>
getBookSearchUserList4H5
(
Long
bookId
);
List
<
String
>
getBookSearchUserList4H5
(
Long
bookId
);
List
<
BookSearchTopVO
>
getBookSearchTop
(
Integer
top
);
List
<
BookSearchTopVO
>
getBookSearchTop
(
Integer
top
);
void
createSearchRecordDis
(
SearchRecord
searchRecord
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/book/biz/impl/SearchBizImpl.java
View file @
332c9009
...
@@ -5,9 +5,11 @@ import com.pcloud.book.book.biz.SearchBiz;
...
@@ -5,9 +5,11 @@ import com.pcloud.book.book.biz.SearchBiz;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.dao.HotBookDao
;
import
com.pcloud.book.book.dao.HotBookDao
;
import
com.pcloud.book.book.dao.SearchRecordDao
;
import
com.pcloud.book.book.dao.SearchRecordDao
;
import
com.pcloud.book.book.dao.SearchRecordDisDao
;
import
com.pcloud.book.book.dto.BookDto
;
import
com.pcloud.book.book.dto.BookDto
;
import
com.pcloud.book.book.entity.HotBook
;
import
com.pcloud.book.book.entity.HotBook
;
import
com.pcloud.book.book.entity.SearchRecord
;
import
com.pcloud.book.book.entity.SearchRecord
;
import
com.pcloud.book.book.entity.SearchRecordDis
;
import
com.pcloud.book.book.vo.BookSearchTopVO
;
import
com.pcloud.book.book.vo.BookSearchTopVO
;
import
com.pcloud.book.book.vo.SearchBookVO
;
import
com.pcloud.book.book.vo.SearchBookVO
;
import
com.pcloud.book.consumer.common.ExportConsr
;
import
com.pcloud.book.consumer.common.ExportConsr
;
...
@@ -19,6 +21,7 @@ import com.pcloud.book.util.common.ThreadPoolUtils;
...
@@ -19,6 +21,7 @@ import com.pcloud.book.util.common.ThreadPoolUtils;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.page.PageParam
;
import
com.pcloud.common.utils.BeanUtils
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtil
;
...
@@ -58,6 +61,8 @@ public class SearchBizImpl implements SearchBiz {
...
@@ -58,6 +61,8 @@ public class SearchBizImpl implements SearchBiz {
private
MessageConsr
messageConsr
;
private
MessageConsr
messageConsr
;
@Autowired
@Autowired
private
BookDao
bookDao
;
private
BookDao
bookDao
;
@Autowired
private
SearchRecordDisDao
searchRecordDisDao
;
@ParamLog
(
"创建热门书"
)
@ParamLog
(
"创建热门书"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -137,6 +142,7 @@ public class SearchBizImpl implements SearchBiz {
...
@@ -137,6 +142,7 @@ public class SearchBizImpl implements SearchBiz {
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"内容长度不能超过!"
);
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"内容长度不能超过!"
);
}
}
searchRecordDao
.
insert
(
searchRecord
);
searchRecordDao
.
insert
(
searchRecord
);
createSearchRecordDis
(
searchRecord
);
}
}
@ParamLog
(
"获取热门搜索列表"
)
@ParamLog
(
"获取热门搜索列表"
)
...
@@ -297,6 +303,21 @@ public class SearchBizImpl implements SearchBiz {
...
@@ -297,6 +303,21 @@ public class SearchBizImpl implements SearchBiz {
return
list
;
return
list
;
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ParamLog
(
"查询dis表有没有相同数据,没有就新增,有就更新"
)
@Override
public
void
createSearchRecordDis
(
SearchRecord
searchRecord
)
{
SearchRecordDis
searchRecordDisOld
=
searchRecordDisDao
.
getByCondition
(
searchRecord
.
getWechatUserId
(),
searchRecord
.
getWxId
(),
searchRecord
.
getContent
());
if
(
searchRecordDisOld
==
null
){
SearchRecordDis
searchRecordDis
=
new
SearchRecordDis
();
BeanUtils
.
copyProperties
(
searchRecord
,
searchRecordDis
);
searchRecordDisDao
.
insert
(
searchRecordDis
);
}
else
{
searchRecordDisDao
.
update
(
searchRecordDisOld
);
}
}
@ParamLog
(
"导出"
)
@ParamLog
(
"导出"
)
private
void
exportSRL
(
List
<
SearchRecord
>
list
,
String
systemCode
,
Long
partyId
)
{
private
void
exportSRL
(
List
<
SearchRecord
>
list
,
String
systemCode
,
Long
partyId
)
{
if
(
ListUtils
.
isEmpty
(
list
))
{
if
(
ListUtils
.
isEmpty
(
list
))
{
...
@@ -341,7 +362,7 @@ public class SearchBizImpl implements SearchBiz {
...
@@ -341,7 +362,7 @@ public class SearchBizImpl implements SearchBiz {
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wxId"
,
wxId
);
map
.
put
(
"wxId"
,
wxId
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"wechatUserId"
,
wechatUserId
);
PageBeanNew
<
SearchRecord
>
page
=
searchRecordDao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
map
,
"getUserSearchList4H5"
,
"countUserSearchList4H5"
);
PageBeanNew
<
SearchRecord
>
page
=
searchRecordD
isD
ao
.
listPageNew
(
new
PageParam
(
currentPage
,
numPerPage
),
map
,
"getUserSearchList4H5"
,
"countUserSearchList4H5"
);
return
page
;
return
page
;
}
}
...
@@ -354,9 +375,13 @@ public class SearchBizImpl implements SearchBiz {
...
@@ -354,9 +375,13 @@ public class SearchBizImpl implements SearchBiz {
}
}
if
(!
StringUtil
.
isEmpty
(
wxId
)){
if
(!
StringUtil
.
isEmpty
(
wxId
)){
searchRecordDao
.
updateUserDeleteByWxId
(
wxId
,
true
);
searchRecordDao
.
updateUserDeleteByWxId
(
wxId
,
true
);
//同时删除去重表
searchRecordDisDao
.
updateUserDeleteByWxId
(
wxId
,
true
);
}
}
if
(
wechatUserId
!=
null
){
if
(
wechatUserId
!=
null
){
searchRecordDao
.
updateUserDeleteByWechatUserId
(
wechatUserId
,
true
);
searchRecordDao
.
updateUserDeleteByWechatUserId
(
wechatUserId
,
true
);
//同时删除去重表
searchRecordDisDao
.
updateUserDeleteByWechatUserId
(
wechatUserId
,
true
);
}
}
}
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/book/dao/SearchRecordDisDao.java
0 → 100644
View file @
332c9009
package
com
.
pcloud
.
book
.
book
.
dao
;
import
com.pcloud.book.book.entity.SearchRecordDis
;
import
com.pcloud.common.core.dao.BaseDao
;
public
interface
SearchRecordDisDao
extends
BaseDao
<
SearchRecordDis
>
{
SearchRecordDis
getByCondition
(
Long
wechatUserId
,
String
wxId
,
String
content
);
void
updateUserDeleteByWxId
(
String
wxId
,
Boolean
userDelete
);
void
updateUserDeleteByWechatUserId
(
Long
wechatUserId
,
Boolean
userDelete
);
}
pcloud-service-book/src/main/java/com/pcloud/book/book/dao/impl/SearchRecordDisDaoImpl.java
0 → 100644
View file @
332c9009
package
com
.
pcloud
.
book
.
book
.
dao
.
impl
;
import
com.pcloud.book.book.dao.SearchRecordDisDao
;
import
com.pcloud.book.book.entity.SearchRecordDis
;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
@Component
(
"searchRecordDisDao"
)
public
class
SearchRecordDisDaoImpl
extends
BaseDaoImpl
<
SearchRecordDis
>
implements
SearchRecordDisDao
{
@Override
public
SearchRecordDis
getByCondition
(
Long
wechatUserId
,
String
wxId
,
String
content
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"wxId"
,
wxId
);
map
.
put
(
"content"
,
content
);
return
super
.
getSqlSession
().
selectOne
(
super
.
getStatement
(
"getByCondition"
),
map
);
}
@Override
public
void
updateUserDeleteByWxId
(
String
wxId
,
Boolean
userDelete
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wxId"
,
wxId
);
map
.
put
(
"userDelete"
,
userDelete
);
super
.
getSqlSession
().
update
(
super
.
getStatement
(
"updateUserDeleteByWxId"
),
map
);
}
@Override
public
void
updateUserDeleteByWechatUserId
(
Long
wechatUserId
,
Boolean
userDelete
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"wechatUserId"
,
wechatUserId
);
map
.
put
(
"userDelete"
,
userDelete
);
super
.
getSqlSession
().
update
(
super
.
getStatement
(
"updateUserDeleteByWechatUserId"
),
map
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/book/entity/SearchRecordDis.java
0 → 100644
View file @
332c9009
package
com
.
pcloud
.
book
.
book
.
entity
;
import
com.pcloud.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
"搜索记录(搜索内容去重)"
)
public
class
SearchRecordDis
extends
BaseEntity
{
@ApiModelProperty
(
"搜索内容"
)
private
String
content
;
@ApiModelProperty
(
"书籍id"
)
private
Long
bookId
;
@ApiModelProperty
(
"书名"
)
private
String
bookName
;
@ApiModelProperty
(
"出版社id"
)
private
Long
agentId
;
@ApiModelProperty
(
"出版社名称"
)
private
String
agentName
;
@ApiModelProperty
(
"用户wxId"
)
private
String
wxId
;
@ApiModelProperty
(
"微信id"
)
private
Long
wechatUserId
;
@ApiModelProperty
(
"头像"
)
private
String
headUrl
;
@ApiModelProperty
(
"昵称"
)
private
String
nickName
;
@ApiModelProperty
(
"性别"
)
private
Integer
sex
;
@ApiModelProperty
(
"热门关键词id"
)
private
Long
hotBookId
;
@ApiModelProperty
(
"用户是否删除"
)
private
Boolean
userDelete
;
@ApiModelProperty
(
"搜索次数"
)
private
Integer
searchCount
;
}
pcloud-service-book/src/main/java/com/pcloud/book/keywords/biz/impl/BookKeywordBizImpl.java
View file @
332c9009
...
@@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
...
@@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
import
com.pcloud.appcenter.app.dto.AppDto
;
import
com.pcloud.appcenter.app.dto.AppDto
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.book.biz.BookKeywordWarehouseBiz
;
import
com.pcloud.book.book.biz.BookKeywordWarehouseBiz
;
import
com.pcloud.book.book.biz.SearchBiz
;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.dao.BookDao
;
import
com.pcloud.book.book.dao.SearchRecordDao
;
import
com.pcloud.book.book.dao.SearchRecordDao
;
import
com.pcloud.book.book.dto.BookDto
;
import
com.pcloud.book.book.dto.BookDto
;
...
@@ -255,6 +256,8 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -255,6 +256,8 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private
PersonalStageJumpBiz
personalStageJumpBiz
;
private
PersonalStageJumpBiz
personalStageJumpBiz
;
@Autowired
@Autowired
private
SendWeixinRequestTools
sendWeixinRequestTools
;
private
SendWeixinRequestTools
sendWeixinRequestTools
;
@Autowired
private
SearchBiz
searchBiz
;
/**
/**
* 字符串切割长度
* 字符串切割长度
...
@@ -676,6 +679,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
...
@@ -676,6 +679,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
log
.
error
(
"长度大于50"
+
bookName
);
log
.
error
(
"长度大于50"
+
bookName
);
}
else
{
}
else
{
searchRecordDao
.
insert
(
searchRecord
);
searchRecordDao
.
insert
(
searchRecord
);
searchBiz
.
createSearchRecordDis
(
searchRecord
);
}
}
}
}
}
}
...
...
pcloud-service-book/src/main/resources/mapper/book/SearchRecord.xml
View file @
332c9009
...
@@ -68,51 +68,6 @@
...
@@ -68,51 +68,6 @@
</if>
</if>
</select>
</select>
<select
id=
"getUserSearchList4H5"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
FROM
search_record
WHERE
id IN (
SELECT
MAX(id)
FROM
search_record
WHERE user_delete = 0
<if
test=
"wxId!=null"
>
and wx_id = #{wxId}
</if>
<if
test=
"wechatUserId!=null"
>
and wechat_user_id = #{wechatUserId}
</if>
GROUP BY
content
) ORDER by id DESC
</select>
<select
id=
"countUserSearchList4H5"
parameterType=
"map"
resultType=
"integer"
>
select
count(1)
FROM
search_record
WHERE
id IN (
SELECT
MAX(id)
FROM
search_record
WHERE user_delete = 0
<if
test=
"wxId!=null"
>
and wx_id = #{wxId}
</if>
<if
test=
"wechatUserId!=null"
>
and wechat_user_id = #{wechatUserId}
</if>
GROUP BY
content
)
</select>
<delete
id=
"deleteByWxId"
parameterType=
"string"
>
<delete
id=
"deleteByWxId"
parameterType=
"string"
>
delete from search_record
delete from search_record
...
...
pcloud-service-book/src/main/resources/mapper/book/SearchRecordDis.xml
0 → 100644
View file @
332c9009
<?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.book.dao.impl.SearchRecordDisDaoImpl"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.book.entity.SearchRecordDis"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"content"
property=
"content"
jdbcType=
"VARCHAR"
/>
<result
column=
"book_id"
property=
"bookId"
jdbcType=
"BIGINT"
/>
<result
column=
"agent_id"
property=
"agentId"
jdbcType=
"BIGINT"
/>
<result
column=
"wx_id"
property=
"wxId"
jdbcType=
"VARCHAR"
/>
<result
column=
"wechat_user_id"
property=
"wechatUserId"
jdbcType=
"BIGINT"
/>
<result
column=
"hot_book_id"
property=
"hotBookId"
jdbcType=
"BIGINT"
/>
<result
column=
"user_delete"
property=
"userDelete"
jdbcType=
"BOOLEAN"
/>
<result
column=
"search_count"
property=
"searchCount"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"INTEGER"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<resultMap
id=
"SearchRecordResultMap"
type=
"com.pcloud.book.book.entity.SearchRecord"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"content"
property=
"content"
jdbcType=
"VARCHAR"
/>
<result
column=
"book_id"
property=
"bookId"
jdbcType=
"BIGINT"
/>
<result
column=
"agent_id"
property=
"agentId"
jdbcType=
"BIGINT"
/>
<result
column=
"wx_id"
property=
"wxId"
jdbcType=
"VARCHAR"
/>
<result
column=
"wechat_user_id"
property=
"wechatUserId"
jdbcType=
"BIGINT"
/>
<result
column=
"hot_book_id"
property=
"hotBookId"
jdbcType=
"BIGINT"
/>
<result
column=
"user_delete"
property=
"userDelete"
jdbcType=
"BOOLEAN"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"INTEGER"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id,content,book_id,agent_id,wx_id,wechat_user_id,hot_book_id,user_delete,search_count,create_time,update_time
</sql>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.book.entity.SearchRecordDis"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into search_record_dis
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
content,
book_id,
agent_id,
wx_id,
wechat_user_id,
hot_book_id,
create_time,
update_time
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
#{content,jdbcType=VARCHAR},
#{bookId,jdbcType=BIGINT},
#{agentId,jdbcType=BIGINT},
#{wxId,jdbcType=VARCHAR},
#{wechatUserId,jdbcType=BIGINT},
#{hotBookId,jdbcType=BIGINT},
NOW(),
NOW()
</trim>
</insert>
<select
id=
"getByCondition"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from search_record_dis
where user_delete=0
and content=#{content}
<if
test=
"wechatUserId!=null"
>
and wechat_user_id=#{wechatUserId}
</if>
<if
test=
"wxId!=null"
>
and wx_id=#{wxId}
</if>
limit 1
</select>
<update
id=
"update"
parameterType=
"com.pcloud.book.book.entity.SearchRecordDis"
>
update search_record_dis
<set>
<if
test=
"content != null"
>
content = #{content},
</if>
<if
test=
"bookId != null"
>
book_id = #{bookId},
</if>
<if
test=
"agentId != null"
>
agent_id = #{agentId},
</if>
<if
test=
"wxId != null"
>
wx_id = #{wxId},
</if>
<if
test=
"wechatUserId != null"
>
wechat_user_id = #{wechatUserId},
</if>
<if
test=
"hotBookId != null"
>
hot_book_id = #{hotBookId},
</if>
<if
test=
"userDelete != null"
>
user_delete = #{userDelete},
</if>
search_count=search_count+1,
update_time=now()
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update
id=
"updateUserDeleteByWxId"
parameterType=
"map"
>
update search_record_dis
set user_delete=#{userDelete}
where wx_id=#{wxId}
</update>
<update
id=
"updateUserDeleteByWechatUserId"
parameterType=
"map"
>
update search_record_dis
set user_delete=#{userDelete}
where wechat_user_id=#{wechatUserId}
</update>
<select
id=
"getUserSearchList4H5"
parameterType=
"map"
resultMap=
"SearchRecordResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
FROM
search_record_dis
WHERE
user_delete = 0
<if
test=
"wxId!=null"
>
and wx_id = #{wxId}
</if>
<if
test=
"wechatUserId!=null"
>
and wechat_user_id = #{wechatUserId}
</if>
ORDER by update_time DESC
</select>
<select
id=
"countUserSearchList4H5"
parameterType=
"map"
resultType=
"integer"
>
select
count(1)
FROM
search_record_dis
WHERE
user_delete = 0
<if
test=
"wxId!=null"
>
and wx_id = #{wxId}
</if>
<if
test=
"wechatUserId!=null"
>
and wechat_user_id = #{wechatUserId}
</if>
</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