Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zcq
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
zcq
Commits
dbdf2e22
提交
dbdf2e22
authored
5月 28, 2019
作者:
yucaiwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
29b3a0ac
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
266 行增加
和
7 行删除
+266
-7
Redis.java
...er/src/main/java/com/zrqx/member/commons/redis/Redis.java
+14
-0
FgPermissionsController.java
...m/zrqx/member/fg/permissions/FgPermissionsController.java
+6
-6
FgPrivateMessageServiceImpl.java
...rqx/member/fg/pm/service/FgPrivateMessageServiceImpl.java
+23
-1
FgRecordController.java
.../zrqx/member/fg/record/controller/FgRecordController.java
+55
-0
FgRecordMapper.java
...java/com/zrqx/member/fg/record/mapper/FgRecordMapper.java
+40
-0
FgRecordService.java
...va/com/zrqx/member/fg/record/service/FgRecordService.java
+29
-0
FgRecordServiceImpl.java
...om/zrqx/member/fg/record/service/FgRecordServiceImpl.java
+99
-0
没有找到文件。
com.zrqx.member/src/main/java/com/zrqx/member/commons/redis/Redis.java
浏览文件 @
dbdf2e22
...
...
@@ -7,6 +7,8 @@ import java.util.concurrent.TimeUnit;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.jedis.JedisConnectionFactory
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
...
...
@@ -27,6 +29,7 @@ import com.zrqx.core.util.JsonUtil.JsonUtil;
*/
@Component
public
class
Redis
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Redis
.
class
);
private
static
final
String
FG_TOKEN
=
"y-token"
;
private
static
final
String
BG_TOKEN
=
"x-token"
;
...
...
@@ -61,6 +64,17 @@ public class Redis {
public
String
fmtObj
(
Object
obj
)
throws
IOException
{
return
obj
instanceof
String
?
obj
.
toString
():
JsonUtil
.
bean2Json
(
obj
);
}
public
boolean
isExistMember
()
{
try
{
String
token
=
getToken
(
FG_TOKEN
);
String
userInfo
=
get
(
token
);
return
StringUtils
.
isNotEmpty
(
userInfo
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"未登录"
);
}
return
false
;
}
/**
* 添加到redis
* @param token
...
...
com.zrqx.member/src/main/java/com/zrqx/member/fg/permissions/FgPermissionsController.java
浏览文件 @
dbdf2e22
...
...
@@ -350,18 +350,18 @@ public class FgPermissionsController {
}
redis
.
delete
(
form
.
getPhone
());
if
(
mService
.
isExistByAccount
(
null
,
form
.
getAccount
()))
{
throw
new
BaseException
(
99
,
"已被注册"
);
throw
new
BaseException
(
99
,
"
账号
已被注册"
);
}
if
(
mService
.
isExistByPhone
(
null
,
form
.
getPhone
()))
{
throw
new
BaseException
(
99
,
"已被使用"
);
throw
new
BaseException
(
99
,
"
手机号
已被使用"
);
}
// 新增
synchronized
(
this
)
{
if
(
mService
.
isExistByAccount
(
null
,
form
.
getAccount
()))
{
throw
new
BaseException
(
99
,
"已被注册"
);
throw
new
BaseException
(
99
,
"
账号
已被注册"
);
}
if
(
mService
.
isExistByPhone
(
null
,
form
.
getPhone
()))
{
throw
new
BaseException
(
99
,
"已被使用"
);
throw
new
BaseException
(
99
,
"
手机号
已被使用"
);
}
Member
m
=
new
Member
();
BeanUtils
.
copyProperties
(
form
,
m
);
...
...
@@ -391,12 +391,12 @@ public class FgPermissionsController {
throw
new
BaseException
(
14
,
"该机构可使用次数不足"
);
}
if
(
mService
.
isExistByAccount
(
null
,
form
.
getAccount
()))
{
throw
new
BaseException
(
99
,
"已存在"
);
throw
new
BaseException
(
99
,
"
账号
已存在"
);
}
// 新增
synchronized
(
this
)
{
if
(
mService
.
isExistByAccount
(
null
,
form
.
getAccount
()))
{
throw
new
BaseException
(
99
,
"已存在"
);
throw
new
BaseException
(
99
,
"
账号
已存在"
);
}
Member
m
=
new
Member
();
BeanUtils
.
copyProperties
(
form
,
m
);
...
...
com.zrqx.member/src/main/java/com/zrqx/member/fg/pm/service/FgPrivateMessageServiceImpl.java
浏览文件 @
dbdf2e22
package
com
.
zrqx
.
member
.
fg
.
pm
.
service
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.member.PrivateMessage
;
import
com.zrqx.core.service.BaseServiceImpl
;
import
com.zrqx.core.util.datatype.ArrayUtils
;
import
com.zrqx.core.util.page.PageInfo
;
import
com.zrqx.core.util.page.PageParam
;
import
com.zrqx.core.vo.member.fg.pm.FgPrivateMessageListVO
;
...
...
@@ -27,6 +31,24 @@ public class FgPrivateMessageServiceImpl extends BaseServiceImpl<PrivateMessage,
@Override
public
PageInfo
<
FgPrivateMessageListVO
>
page
(
Integer
memberId
,
PageParam
pageParam
)
{
startPage
(
pageParam
);
return
new
PageInfo
<
FgPrivateMessageListVO
>(
mapper
.
page
(
memberId
));
List
<
FgPrivateMessageListVO
>
list
=
mapper
.
page
(
memberId
);
this
.
regEx
(
list
);
return
new
PageInfo
<
FgPrivateMessageListVO
>(
list
);
}
/**
* 去标签
* @param list
* @author ycw
* @date: 2019年4月18日 上午11:57:55
*/
private
void
regEx
(
List
<
FgPrivateMessageListVO
>
list
){
if
(
ArrayUtils
.
isNotEmpty
(
list
)){
list
.
forEach
(
li
->
{
if
(
StringUtils
.
isNotBlank
(
li
.
getContent
())){
li
.
setContent
(
li
.
getContent
().
replaceAll
(
"\\<.*?>"
,
""
));
}
});
}
}
}
com.zrqx.member/src/main/java/com/zrqx/member/fg/record/controller/FgRecordController.java
0 → 100644
浏览文件 @
dbdf2e22
package
com
.
zrqx
.
member
.
fg
.
record
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
tk.mybatis.mapper.entity.Example
;
import
com.zrqx.core.constant.resource.ResourceRequestPath
;
import
com.zrqx.core.form.resource.fg.record.FgSaveRecordForm
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.vo.resource.fg.record.FgMyRecordVO
;
import
com.zrqx.member.commons.redis.Redis
;
import
com.zrqx.member.fg.record.service.FgRecordService
;
@RestController
@RequestMapping
(
ResourceRequestPath
.
FG
+
ResourceRequestPath
.
RECORD
)
@Api
(
description
=
"前台-浏览记录"
)
public
class
FgRecordController
{
@Autowired
private
FgRecordService
service
;
@Autowired
private
Redis
redis
;
@ApiOperation
(
value
=
"我的浏览记录"
,
notes
=
"我的浏览记录"
)
@GetMapping
(
value
=
ResourceRequestPath
.
LIST
)
public
CallBack
<
List
<
FgMyRecordVO
>>
getMyRecord
()
{
return
CallBack
.
success
(
service
.
getMyRecord
());
}
@ApiOperation
(
value
=
"批量删除"
,
notes
=
"删除浏览记录"
)
@PostMapping
(
value
=
ResourceRequestPath
.
BATCH_DELETE
)
public
CallBack
<
List
<
FgMyRecordVO
>>
batechDeleteMyRecord
(
@RequestBody
List
<
Integer
>
ids
)
{
Example
example
=
service
.
createExample
();
example
.
createCriteria
().
andIn
(
"id"
,
ids
);
service
.
deleteByExample
(
example
);
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"添加浏览记录(跨服务调用)"
,
notes
=
"添加浏览记录"
)
@PostMapping
(
value
=
ResourceRequestPath
.
ADD
)
public
CallBack
<
Boolean
>
addRecord
(
@RequestBody
FgSaveRecordForm
form
)
{
return
CallBack
.
success
(
service
.
saveOrUpdateRecord
(
form
));
}
}
com.zrqx.member/src/main/java/com/zrqx/member/fg/record/mapper/FgRecordMapper.java
0 → 100644
浏览文件 @
dbdf2e22
package
com
.
zrqx
.
member
.
fg
.
record
.
mapper
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Delete
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.member.Record
;
/**
* 浏览记录
* @author ycw
* @date 2019年2月12日下午2:42:01
*/
public
interface
FgRecordMapper
extends
BaseMapper
<
Record
>
{
@Delete
(
"<script>"
+
"DELETE FROM res_record WHERE "
+
"id NOT IN (SELECT t.id from (SELECT b.id FROM res_record b WHERE b.memberId = #{memberId} ORDER BY b.createTime DESC LIMIT 15) as t)"
+
"</script>"
)
boolean
deleteOtherRecord
(
Integer
memberId
);
/**
* 个人中心-为你推荐
* @param memberId
* @param goodsType
* @return
* @author ycw
* @date: 2019年2月18日 下午3:39:30
*/
@Select
(
"<script>"
+
"SELECT id,objectId,objectType,createTime "
+
"FROM res_record "
+
"WHERE b.memberId = #{memberId} "
+
"and goodsType = #{goodsType} "
+
"</script>"
)
List
<
Record
>
queryRecommendByAlgorithm
(
@Param
(
"memberId"
)
Integer
memberId
,
@Param
(
"goodsType"
)
String
goodsType
);
}
com.zrqx.member/src/main/java/com/zrqx/member/fg/record/service/FgRecordService.java
0 → 100644
浏览文件 @
dbdf2e22
package
com
.
zrqx
.
member
.
fg
.
record
.
service
;
import
java.util.List
;
import
com.zrqx.core.form.resource.fg.record.FgSaveRecordForm
;
import
com.zrqx.core.model.member.Record
;
import
com.zrqx.core.service.BaseService
;
import
com.zrqx.core.vo.resource.fg.record.FgMyRecordVO
;
public
interface
FgRecordService
extends
BaseService
<
Record
,
Integer
>
{
/**
* 保存浏览记录
* @param form
* @return
* @author ycw
* @date: 2019年2月12日 下午3:02:55
*/
boolean
saveOrUpdateRecord
(
FgSaveRecordForm
form
);
/**
* 我的浏览记录
* @return
* @author ycw
* @date: 2019年2月12日 下午4:16:19
*/
List
<
FgMyRecordVO
>
getMyRecord
();
}
com.zrqx.member/src/main/java/com/zrqx/member/fg/record/service/FgRecordServiceImpl.java
0 → 100644
浏览文件 @
dbdf2e22
package
com
.
zrqx
.
member
.
fg
.
record
.
service
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.github.pagehelper.PageHelper
;
import
com.zrqx.core.form.resource.fg.record.FgSaveRecordForm
;
import
com.zrqx.core.mapper.BaseMapper
;
import
com.zrqx.core.model.member.Record
;
import
com.zrqx.core.service.BaseServiceImpl
;
import
com.zrqx.core.util.bean.BeanUtils
;
import
com.zrqx.core.vo.resource.fg.record.FgMyRecordVO
;
import
com.zrqx.member.commons.redis.Redis
;
import
com.zrqx.member.fg.record.mapper.FgRecordMapper
;
/**
* 浏览记录
* @author ycw
* @date 2019年2月12日下午2:41:27
*/
@Service
public
class
FgRecordServiceImpl
extends
BaseServiceImpl
<
Record
,
Integer
>
implements
FgRecordService
{
@Autowired
private
FgRecordMapper
mapper
;
@Autowired
private
Redis
redis
;
@Override
public
BaseMapper
<
Record
>
getMapper
()
{
return
mapper
;
}
/**
* 保存浏览记录
* @param goodsId
* @param goodsType 资源类型 电子书2-1 文章2-2
* @return
* @author ycw
* @date: 2019年2月12日 下午3:02:55
*/
@Override
public
boolean
saveOrUpdateRecord
(
FgSaveRecordForm
form
)
{
if
(!
redis
.
isExistMember
()){
return
false
;
}
Record
re
=
new
Record
();
re
.
setObjectId
(
form
.
getObjectId
());
re
.
setObjectType
(
form
.
getObjectType
());
re
.
setMemberId
(
redis
.
getMember
().
getId
());
re
.
setType
(
form
.
getType
());
// 删除旧浏览记录
mapper
.
delete
(
re
);
// 插入新记录
Record
record
=
BeanUtils
.
copy
(
form
,
Record
.
class
);
record
.
setCreateTime
(
new
Date
());
record
.
setMemberId
(
redis
.
getMember
().
getId
());
mapper
.
insertSelective
(
record
);
//如果浏览记录超过15条,按照浏览时间降序排列,删除多余的浏览记录
Record
myRecord
=
new
Record
();
myRecord
.
setMemberId
(
redis
.
getMember
().
getId
());
if
(
mapper
.
selectCount
(
myRecord
)
>
15
){
mapper
.
deleteOtherRecord
(
redis
.
getMember
().
getId
());
}
return
true
;
}
/**
* 我的浏览记录
* @param pageParam
* @return
* @author ycw
* @date: 2019年2月12日 下午4:17:49
*/
@Override
public
List
<
FgMyRecordVO
>
getMyRecord
(){
PageHelper
.
startPage
(
1
,
15
,
"createTime desc"
);
Record
record
=
new
Record
();
record
.
setMemberId
(
redis
.
getMember
().
getId
());
List
<
Record
>
list
=
mapper
.
select
(
record
);
if
(
list
!=
null
&&
list
.
size
()
>
0
){
List
<
FgMyRecordVO
>
vos
=
BeanUtils
.
copyList
(
list
,
FgMyRecordVO
.
class
,
vo
->
{
if
(
StringUtils
.
isNotBlank
(
vo
.
getIntro
())){
vo
.
setIntro
(
vo
.
getIntro
().
replaceAll
(
"\\<.*?>"
,
""
));
}
});
return
vos
;
}
return
null
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论