Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
481b195b
Commit
481b195b
authored
Aug 14, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
5486ed29
d915aa46
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
617 additions
and
123 deletions
+617
-123
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesDao.java
+1
-4
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
...in/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
+1
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
...o/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
+10
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
...va/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
+11
-0
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/FavoritesItemsRelationMapper.xml
...es/com/wwdz/ch/db/mapper/FavoritesItemsRelationMapper.xml
+23
-12
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WxWebMvcConfiguration.java
...ain/java/com/wwdz/ch/wx/config/WxWebMvcConfiguration.java
+17
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/vo/FavoritesResponseVo.java
...in/java/com/wwdz/ch/wx/entity/vo/FavoritesResponseVo.java
+19
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/vo/ItemResponseVo.java
...rc/main/java/com/wwdz/ch/wx/entity/vo/ItemResponseVo.java
+2
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+80
-7
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+92
-42
ch-wx-api/src/main/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
...ain/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
+68
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
...rc/main/java/com/wwdz/ch/wx/service/FavoritesService.java
+1
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ItemService.java
...api/src/main/java/com/wwdz/ch/wx/service/ItemService.java
+2
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
...c/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
+124
-33
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFootprintController.java
...c/main/java/com/wwdz/ch/wx/web/WxFootprintController.java
+37
-10
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxItemController.java
...pi/src/main/java/com/wwdz/ch/wx/web/WxItemController.java
+129
-12
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesDao.java
View file @
481b195b
...
...
@@ -10,12 +10,9 @@ public interface FavoritesDao {
int
delete
(
Long
id
);
int
update
(
Favorites
record
);
Favorites
info
(
Long
id
);
List
<
Favorites
>
listByUserId
(
Long
userId
);
PageInfo
<
Favorites
>
pageByUserId
(
Long
userId
,
int
page
,
int
size
);
boolean
isExisted
(
Long
id
,
Long
userId
,
String
title
);
int
delete
(
Long
id
,
List
<
Long
>
ids
);
Favorites
defaultFavorites
(
Long
userId
);
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
View file @
481b195b
...
...
@@ -10,6 +10,7 @@ public interface FavoritesItemsRelationDao {
int
batchInsert
(
List
<
FavoritesItemsRelation
>
list
);
int
deleteByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
int
deleteByChosen
(
Long
favoritesId
,
List
<
Long
>
itemIds
);
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
);
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
FavoritesItemsRelation
selectByUserIdItemId
(
Long
userId
,
Long
itemId
);
PageInfo
<
FavoritesItemsRelation
>
pageByFavoritesId
(
Long
favoritesId
,
int
page
,
int
size
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
View file @
481b195b
...
...
@@ -59,6 +59,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andDeletedEqualTo
(
false
);
example
.
orderBy
(
"add_time desc"
);
PageHelper
.
startPage
(
page
,
size
);
List
<
Favorites
>
list
=
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
return
new
PageInfo
<>(
list
);
...
...
@@ -88,4 +89,13 @@ public class FavoritesDaoImpl implements FavoritesDao {
favorites
.
setUpdateTime
(
new
Date
());
return
favoritesMapper
.
updateByExampleSelective
(
favorites
,
example
);
}
@Override
public
Favorites
defaultFavorites
(
Long
userId
)
{
FavoritesExample
example
=
new
FavoritesExample
();
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andSortEqualTo
(
1
);
return
favoritesMapper
.
selectOneByExample
(
example
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
View file @
481b195b
...
...
@@ -2,6 +2,7 @@ package com.wwdz.ch.db.impl;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.db.domain.Favorites
;
import
com.wwdz.ch.db.mapper.FavoritesItemsRelationMapper
;
import
com.wwdz.ch.db.domain.FavoritesItemsRelation
;
import
com.wwdz.ch.db.domain.FavoritesItemsRelationExample
;
...
...
@@ -41,6 +42,16 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
criteria
.
andItemIdIn
(
itemIds
);
return
favoritesItemsRelationMapper
.
deleteByExample
(
example
);
}
@Override
public
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andItemIdEqualTo
(
itemId
);
return
favoritesItemsRelationMapper
.
deleteByExample
(
example
);
}
@Override
public
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/FavoritesItemsRelationMapper.xml
View file @
481b195b
...
...
@@ -3,6 +3,7 @@
<mapper
namespace=
"com.wwdz.ch.db.mapper.FavoritesItemsRelationMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
<result
column=
"favorites_id"
jdbcType=
"BIGINT"
property=
"favoritesId"
/>
<result
column=
"user_id"
jdbcType=
"BIGINT"
property=
"userId"
/>
<result
column=
"item_id"
jdbcType=
"BIGINT"
property=
"itemId"
/>
<result
column=
"add_time"
jdbcType=
"TIMESTAMP"
property=
"addTime"
/>
</resultMap>
...
...
@@ -65,7 +66,7 @@
</where>
</sql>
<sql
id=
"Base_Column_List"
>
favorites_id, item_id, add_time
favorites_id,
user_id,
item_id, add_time
</sql>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelationExample"
resultMap=
"BaseResultMap"
>
select
...
...
@@ -94,13 +95,13 @@
distinct
</if>
<choose>
<when
test=
"selective != null and selective.length
>
0"
>
<when
test=
"selective != null and selective.length
>
0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
favorites_id, item_id, add_time
favorites_id,
user_id,
item_id, add_time
</otherwise>
</choose>
from favorites_items_relation
...
...
@@ -118,16 +119,16 @@
</if>
</delete>
<insert
id=
"insert"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
insert into favorites_items_relation (favorites_id,
item_id, add_time
)
values (#{favoritesId,jdbcType=BIGINT}, #{
itemId,jdbcType=BIGINT}, #{addTime,jdbcType=TIMESTAMP}
)
insert into favorites_items_relation (favorites_id,
user_id, item_id,
add_time
)
values (#{favoritesId,jdbcType=BIGINT}, #{
userId,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT},
#{addTime,jdbcType=TIMESTAMP}
)
</insert>
<insert
id=
"batchInsert"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
insert into favorites_
coins_relation (favorites_id, item_id, add_time)
values
insert into favorites_
items_relation (favorites_id, user_id, item_id,
add_time)
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(#{item.favoritesId,jdbcType=BIGINT}, #{item.itemId,jdbcType=BIGINT}, #{item.addTime,jdbcType=TIMESTAMP})
(#{item.favoritesId,jdbcType=BIGINT}, #{item.
userId,jdbcType=BIGINT}, #{item.
itemId,jdbcType=BIGINT}, #{item.addTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
...
...
@@ -136,6 +137,9 @@
<if
test=
"favoritesId != null"
>
favorites_id,
</if>
<if
test=
"userId != null"
>
user_id,
</if>
<if
test=
"itemId != null"
>
item_id,
</if>
...
...
@@ -147,6 +151,9 @@
<if
test=
"favoritesId != null"
>
#{favoritesId,jdbcType=BIGINT},
</if>
<if
test=
"userId != null"
>
#{userId,jdbcType=BIGINT},
</if>
<if
test=
"itemId != null"
>
#{itemId,jdbcType=BIGINT},
</if>
...
...
@@ -167,6 +174,9 @@
<if
test=
"record.favoritesId != null"
>
favorites_id = #{record.favoritesId,jdbcType=BIGINT},
</if>
<if
test=
"record.userId != null"
>
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if
test=
"record.itemId != null"
>
item_id = #{record.itemId,jdbcType=BIGINT},
</if>
...
...
@@ -181,6 +191,7 @@
<update
id=
"updateByExample"
parameterType=
"map"
>
update favorites_items_relation
set favorites_id = #{record.favoritesId,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
item_id = #{record.itemId,jdbcType=BIGINT},
add_time = #{record.addTime,jdbcType=TIMESTAMP}
<if
test=
"_parameter != null"
>
...
...
@@ -214,13 +225,13 @@
select
'true' as QUERYID,
<choose>
<when
test=
"selective != null and selective.length
>
0"
>
<when
test=
"selective != null and selective.length
>
0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
favorites_id, item_id, add_time
favorites_id,
user_id,
item_id, add_time
</otherwise>
</choose>
from favorites_items_relation
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WxWebMvcConfiguration.java
View file @
481b195b
package
com.wwdz.ch.wx.config
;
import
java.util.List
;
import
com.wwdz.ch.wx.annotation.support.LoginUserHandlerMethodArgumentResolver
;
import
com.wwdz.ch.wx.interceptor.LoginInterceptor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
@Configuration
public
class
WxWebMvcConfiguration
implements
WebMvcConfigurer
{
@Bean
LoginInterceptor
loginInterceptor
()
{
return
new
LoginInterceptor
();
}
@Autowired
private
LoginUserHandlerMethodArgumentResolver
loginUserHandlerMethodArgumentResolver
;
...
...
@@ -17,4 +24,12 @@ public class WxWebMvcConfiguration implements WebMvcConfigurer {
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
argumentResolvers
.
add
(
loginUserHandlerMethodArgumentResolver
);
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
loginInterceptor
())
.
addPathPatterns
(
"/**"
)
.
excludePathPatterns
(
"/*.html"
,
"/**/*.html"
,
"/**/*.css"
,
"/**/*.js"
,
"/wx/user/loginByWx"
,
"/wx/user/loginByMobile"
,
"/wx/user/loginRegCaptcha"
,
"/wx/user/updateRegCaptcha"
,
"/wx/item/page"
,
"/wx/item/info"
);
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/vo/FavoritesResponseVo.java
0 → 100644
View file @
481b195b
package
com.wwdz.ch.wx.entity.vo
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
FavoritesResponseVo
implements
Entity
{
private
Long
id
;
private
String
title
;
private
String
description
;
private
Integer
sort
;
private
Date
addTime
;
private
Date
updateTime
;
private
Boolean
deleted
;
private
String
images
;
private
long
count
;
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/vo/ItemResponseVo.java
View file @
481b195b
package
com.wwdz.ch.wx.entity.vo
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
@Data
public
class
ItemResponseVo
{
public
class
ItemResponseVo
implements
Entity
{
private
Long
id
;
private
Long
itemId
;
private
Integer
cid
;
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
481b195b
This diff is collapsed.
Click to expand it.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
481b195b
This diff is collapsed.
Click to expand it.
ch-wx-api/src/main/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
0 → 100644
View file @
481b195b
package
com.wwdz.ch.wx.interceptor
;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.wx.service.UserTokenManager
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
@Component
public
class
LoginInterceptor
implements
HandlerInterceptor
{
Logger
logger
=
LoggerFactory
.
getLogger
(
LoginInterceptor
.
class
);
@Autowired
private
UserTokenManager
userTokenManager
;
/***
* 在请求处理之前进行调用(Controller方法调用之前)
*/
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
logger
.
info
(
"-------------进入拦截器"
);
logger
.
info
(
"请求头名称:"
+
JSON
.
toJSONString
(
request
.
getHeaderNames
()));
String
token
=
request
.
getHeader
(
"Authorization"
);
logger
.
info
(
"token的值是:"
+
token
);
if
(
StringUtils
.
isBlank
(
token
))
{
return
true
;
}
if
(
StringUtils
.
isNotBlank
(
token
))
{
Long
userId
=
userTokenManager
.
getUserId
(
token
);
if
(
Objects
.
nonNull
(
userId
))
{
return
true
;
}
}
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"code"
,
401
);
map
.
put
(
"success"
,
false
);
map
.
put
(
"message"
,
"未登录!"
);
map
.
put
(
"result"
,
null
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
getWriter
().
write
(
JSON
.
toJSONString
(
map
));
return
false
;
}
/***
* 请求处理之后进行调用,但是在视图被渲染之前(Controller方法调用之后)
*/
@Override
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
ModelAndView
modelAndView
)
throws
Exception
{
}
/***
* 整个请求结束之后被调用,也就是在DispatchServlet渲染了对应的视图之后执行(主要用于进行资源清理工作)
*/
@Override
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
throws
Exception
{
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
View file @
481b195b
...
...
@@ -21,6 +21,7 @@ public interface FavoritesService {
Result
delete
(
FavoritesRequestDto
dto
);
Result
batchDelete
(
FavoritesRequestDto
dto
);
Result
addItem
(
ItemRequestDto
dto
);
Result
removeItem
(
ItemRequestDto
dto
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ItemService.java
View file @
481b195b
...
...
@@ -14,5 +14,7 @@ public interface ItemService {
Result
collect
(
ItemRequestDto
dto
);
Result
cancel
(
ItemRequestDto
dto
);
Result
update
(
ItemRequestDto
dto
);
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
View file @
481b195b
This diff is collapsed.
Click to expand it.
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFootprintController.java
View file @
481b195b
...
...
@@ -11,8 +11,10 @@ import com.wwdz.ch.db.domain.Footprint;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.wx.annotation.LoginUser
;
import
com.wwdz.ch.wx.entity.request.FootPrintRequestDto
;
import
com.wwdz.ch.wx.entity.request.KlDataRequestDto
;
import
com.wwdz.ch.wx.service.FootPrintService
;
import
org.apache.commons.collections.CollectionUtils
;
import
com.xxdxxs.utils.JsonUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -20,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* 用户访问足迹服务
...
...
@@ -126,28 +129,52 @@ public class WxFootprintController {
}
@PostMapping
(
"/page"
)
public
Result
page
(
@RequestBody
FootPrintRequestDto
dto
)
{
logger
.
info
(
"【请求开始】用户足迹列表查询,请求参数,userId:{}"
,
dto
.
getUserId
());
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
public
Result
page
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】用户足迹列表查询,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
page
=
JsonUtils
.
getValueByPath
(
json
,
"page"
);
String
size
=
JsonUtils
.
getValueByPath
(
json
,
"size"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getPage
()
))
{
if
(
StringUtils
.
isBlank
(
page
))
{
return
Result
.
failed
(
"当前页不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getSize
()
))
{
if
(
StringUtils
.
isBlank
(
size
))
{
return
Result
.
failed
(
"页面大小不能为空"
);
}
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
page
))
{
return
Result
.
failed
(
"当前页不能为空"
);
}
if
(
StringUtils
.
isBlank
(
size
))
{
return
Result
.
failed
(
"页面大小不能为空"
);
}
FootPrintRequestDto
dto
=
new
FootPrintRequestDto
();
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setPage
(
Integer
.
parseInt
(
page
));
dto
.
setSize
(
Integer
.
parseInt
(
size
));
return
footPrintService
.
page
(
dto
);
}
@PostMapping
(
"/del"
)
public
Result
delete
(
@RequestBody
FootPrintRequestDto
dto
)
{
logger
.
info
(
"【请求开始】用户足迹删除,请求参数,ids:{}"
,
dto
.
getIds
());
if
(
CollectionUtils
.
isEmpty
(
dto
.
getIds
()))
{
return
Result
.
failed
(
"请选择足迹"
);
public
Result
delete
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册收藏,请求参数,kl_data:{}"
,
json
);
String
ids
=
JsonUtils
.
getValueByPath
(
json
,
"ids"
);
if
(
StringUtils
.
isBlank
(
ids
))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
List
<
Long
>
idss
=
Arrays
.
stream
(
ids
.
substring
(
1
,
ids
.
length
()
-
1
).
split
(
","
))
.
map
(
Long:
:
valueOf
).
collect
(
Collectors
.
toList
());
FootPrintRequestDto
dto
=
new
FootPrintRequestDto
();
dto
.
setIds
(
idss
);
return
footPrintService
.
delete
(
dto
);
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxItemController.java
View file @
481b195b
...
...
@@ -27,13 +27,10 @@ public class WxItemController {
@PostMapping
(
"/page"
)
public
Result
page
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】藏品列表
分页查询
,请求参数,kl_data:{}"
,
json
);
logger
.
info
(
"【请求开始】藏品列表
首页
,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
page
=
JsonUtils
.
getValueByPath
(
json
,
"page"
);
String
size
=
JsonUtils
.
getValueByPath
(
json
,
"size"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
page
))
{
return
Result
.
failed
(
"当前页不能为空"
);
}
...
...
@@ -42,7 +39,10 @@ public class WxItemController {
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setUserId
(
0L
);
if
(
StringUtils
.
isNotBlank
(
userId
))
{
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
}
dto
.
setPage
(
Integer
.
parseInt
(
page
));
dto
.
setSize
(
Integer
.
parseInt
(
size
));
return
itemService
.
page
(
dto
);
...
...
@@ -56,13 +56,90 @@ public class WxItemController {
@ApiOperation
(
value
=
"新增"
)
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
ItemRequestDto
dto
)
{
public
Result
add
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】藏品发布,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
cid
=
JsonUtils
.
getValueByPath
(
json
,
"cid"
);
String
name
=
JsonUtils
.
getValueByPath
(
json
,
"name"
);
String
detail
=
JsonUtils
.
getValueByPath
(
json
,
"detail"
);
String
images
=
JsonUtils
.
getValueByPath
(
json
,
"images"
);
String
favoritesId
=
JsonUtils
.
getValueByPath
(
json
,
"favoritesId"
);
String
price
=
JsonUtils
.
getValueByPath
(
json
,
"price"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
cid
))
{
return
Result
.
failed
(
"分类id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
name
))
{
return
Result
.
failed
(
"标题不能为空"
);
}
if
(
StringUtils
.
isBlank
(
price
))
{
return
Result
.
failed
(
"价格不能为空"
);
}
if
(
StringUtils
.
isBlank
(
images
))
{
return
Result
.
failed
(
"图片或视频不能为空"
);
}
if
(
StringUtils
.
isBlank
(
favoritesId
))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setName
(
name
);
dto
.
setCid
(
Integer
.
parseInt
(
cid
));
dto
.
setDetail
(
detail
);
dto
.
setFavoritesId
(
Long
.
parseLong
(
favoritesId
));
dto
.
setImages
(
images
);
dto
.
setPrice
(
price
);
return
itemService
.
add
(
dto
);
}
@ApiOperation
(
value
=
"修改"
)
@PostMapping
(
"/update"
)
public
Result
update
(
@RequestBody
ItemRequestDto
dto
)
{
public
Result
update
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】藏品发布,请求参数,kl_data:{}"
,
json
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
cid
=
JsonUtils
.
getValueByPath
(
json
,
"cid"
);
String
name
=
JsonUtils
.
getValueByPath
(
json
,
"name"
);
String
detail
=
JsonUtils
.
getValueByPath
(
json
,
"detail"
);
String
images
=
JsonUtils
.
getValueByPath
(
json
,
"images"
);
String
favoritesId
=
JsonUtils
.
getValueByPath
(
json
,
"favoritesId"
);
String
price
=
JsonUtils
.
getValueByPath
(
json
,
"price"
);
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
cid
))
{
return
Result
.
failed
(
"分类id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
name
))
{
return
Result
.
failed
(
"标题不能为空"
);
}
if
(
StringUtils
.
isBlank
(
price
))
{
return
Result
.
failed
(
"价格不能为空"
);
}
if
(
StringUtils
.
isBlank
(
images
))
{
return
Result
.
failed
(
"图片或视频不能为空"
);
}
if
(
StringUtils
.
isBlank
(
favoritesId
))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setId
(
Long
.
parseLong
(
id
));
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setName
(
name
);
dto
.
setCid
(
Integer
.
parseInt
(
cid
));
dto
.
setDetail
(
detail
);
dto
.
setFavoritesId
(
Long
.
parseLong
(
favoritesId
));
dto
.
setImages
(
images
);
dto
.
setPrice
(
price
);
return
itemService
.
update
(
dto
);
}
...
...
@@ -73,16 +150,56 @@ public class WxItemController {
logger
.
info
(
"【请求开始】藏品详情查询,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"
当前页
不能为空"
);
return
Result
.
failed
(
"
藏品id
不能为空"
);
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setUserId
(
0L
);
if
(
StringUtils
.
isNotBlank
(
userId
))
{
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
}
dto
.
setId
(
Long
.
parseLong
(
id
));
return
itemService
.
info
(
dto
);
}
@ApiOperation
(
value
=
"收藏"
)
@PostMapping
(
"/collect"
)
public
Result
collect
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】首页收藏,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"藏品id不能为空"
);
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
0L
);
if
(
StringUtils
.
isNotBlank
(
userId
))
{
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
}
dto
.
setId
(
Long
.
parseLong
(
id
));
return
itemService
.
collect
(
dto
);
}
@ApiOperation
(
value
=
"取消收藏"
)
@PostMapping
(
"/cancel"
)
public
Result
cancel
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】首页取消收藏,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"藏品id不能为空"
);
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
0L
);
if
(
StringUtils
.
isNotBlank
(
userId
))
{
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
}
dto
.
setId
(
Long
.
parseLong
(
id
));
return
itemService
.
cancel
(
dto
);
}
}
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