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
Show 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 {
...
@@ -10,12 +10,9 @@ public interface FavoritesDao {
int
delete
(
Long
id
);
int
delete
(
Long
id
);
int
update
(
Favorites
record
);
int
update
(
Favorites
record
);
Favorites
info
(
Long
id
);
Favorites
info
(
Long
id
);
List
<
Favorites
>
listByUserId
(
Long
userId
);
List
<
Favorites
>
listByUserId
(
Long
userId
);
PageInfo
<
Favorites
>
pageByUserId
(
Long
userId
,
int
page
,
int
size
);
PageInfo
<
Favorites
>
pageByUserId
(
Long
userId
,
int
page
,
int
size
);
boolean
isExisted
(
Long
id
,
Long
userId
,
String
title
);
boolean
isExisted
(
Long
id
,
Long
userId
,
String
title
);
int
delete
(
Long
id
,
List
<
Long
>
ids
);
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 {
...
@@ -10,6 +10,7 @@ public interface FavoritesItemsRelationDao {
int
batchInsert
(
List
<
FavoritesItemsRelation
>
list
);
int
batchInsert
(
List
<
FavoritesItemsRelation
>
list
);
int
deleteByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
int
deleteByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
int
deleteByChosen
(
Long
favoritesId
,
List
<
Long
>
itemIds
);
int
deleteByChosen
(
Long
favoritesId
,
List
<
Long
>
itemIds
);
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
);
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
FavoritesItemsRelation
selectByUserIdItemId
(
Long
userId
,
Long
itemId
);
FavoritesItemsRelation
selectByUserIdItemId
(
Long
userId
,
Long
itemId
);
PageInfo
<
FavoritesItemsRelation
>
pageByFavoritesId
(
Long
favoritesId
,
int
page
,
int
size
);
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 {
...
@@ -59,6 +59,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
example
.
orderBy
(
"add_time desc"
);
PageHelper
.
startPage
(
page
,
size
);
PageHelper
.
startPage
(
page
,
size
);
List
<
Favorites
>
list
=
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
List
<
Favorites
>
list
=
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
return
new
PageInfo
<>(
list
);
return
new
PageInfo
<>(
list
);
...
@@ -88,4 +89,13 @@ public class FavoritesDaoImpl implements FavoritesDao {
...
@@ -88,4 +89,13 @@ public class FavoritesDaoImpl implements FavoritesDao {
favorites
.
setUpdateTime
(
new
Date
());
favorites
.
setUpdateTime
(
new
Date
());
return
favoritesMapper
.
updateByExampleSelective
(
favorites
,
example
);
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;
...
@@ -2,6 +2,7 @@ package com.wwdz.ch.db.impl;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.db.domain.Favorites
;
import
com.wwdz.ch.db.mapper.FavoritesItemsRelationMapper
;
import
com.wwdz.ch.db.mapper.FavoritesItemsRelationMapper
;
import
com.wwdz.ch.db.domain.FavoritesItemsRelation
;
import
com.wwdz.ch.db.domain.FavoritesItemsRelation
;
import
com.wwdz.ch.db.domain.FavoritesItemsRelationExample
;
import
com.wwdz.ch.db.domain.FavoritesItemsRelationExample
;
...
@@ -41,6 +42,16 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
...
@@ -41,6 +42,16 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
criteria
.
andItemIdIn
(
itemIds
);
criteria
.
andItemIdIn
(
itemIds
);
return
favoritesItemsRelationMapper
.
deleteByExample
(
example
);
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
@Override
public
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
)
{
public
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/FavoritesItemsRelationMapper.xml
View file @
481b195b
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<mapper
namespace=
"com.wwdz.ch.db.mapper.FavoritesItemsRelationMapper"
>
<mapper
namespace=
"com.wwdz.ch.db.mapper.FavoritesItemsRelationMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
<resultMap
id=
"BaseResultMap"
type=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
<result
column=
"favorites_id"
jdbcType=
"BIGINT"
property=
"favoritesId"
/>
<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=
"item_id"
jdbcType=
"BIGINT"
property=
"itemId"
/>
<result
column=
"add_time"
jdbcType=
"TIMESTAMP"
property=
"addTime"
/>
<result
column=
"add_time"
jdbcType=
"TIMESTAMP"
property=
"addTime"
/>
</resultMap>
</resultMap>
...
@@ -65,7 +66,7 @@
...
@@ -65,7 +66,7 @@
</where>
</where>
</sql>
</sql>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
favorites_id, item_id, add_time
favorites_id,
user_id,
item_id, add_time
</sql>
</sql>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelationExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelationExample"
resultMap=
"BaseResultMap"
>
select
select
...
@@ -94,13 +95,13 @@
...
@@ -94,13 +95,13 @@
distinct
distinct
</if>
</if>
<choose>
<choose>
<when
test=
"selective != null and selective.length
>
0"
>
<when
test=
"selective != null and selective.length
>
0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
${column.escapedColumnName}
</foreach>
</foreach>
</when>
</when>
<otherwise>
<otherwise>
favorites_id, item_id, add_time
favorites_id,
user_id,
item_id, add_time
</otherwise>
</otherwise>
</choose>
</choose>
from favorites_items_relation
from favorites_items_relation
...
@@ -118,16 +119,16 @@
...
@@ -118,16 +119,16 @@
</if>
</if>
</delete>
</delete>
<insert
id=
"insert"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
<insert
id=
"insert"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
insert into favorites_items_relation (favorites_id,
item_id, add_time
insert into favorites_items_relation (favorites_id,
user_id, item_id,
)
add_time
)
values (#{favoritesId,jdbcType=BIGINT}, #{
itemId,jdbcType=BIGINT}, #{addTime,jdbcType=TIMESTAMP}
values (#{favoritesId,jdbcType=BIGINT}, #{
userId,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT},
)
#{addTime,jdbcType=TIMESTAMP}
)
</insert>
</insert>
<insert
id=
"batchInsert"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
<insert
id=
"batchInsert"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
insert into favorites_
coins_relation (favorites_id, item_id, add_time)
insert into favorites_
items_relation (favorites_id, user_id, item_id,
values
add_time)
<foreach
collection=
"list"
item=
"item"
separator=
","
>
<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>
</foreach>
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.FavoritesItemsRelation"
>
...
@@ -136,6 +137,9 @@
...
@@ -136,6 +137,9 @@
<if
test=
"favoritesId != null"
>
<if
test=
"favoritesId != null"
>
favorites_id,
favorites_id,
</if>
</if>
<if
test=
"userId != null"
>
user_id,
</if>
<if
test=
"itemId != null"
>
<if
test=
"itemId != null"
>
item_id,
item_id,
</if>
</if>
...
@@ -147,6 +151,9 @@
...
@@ -147,6 +151,9 @@
<if
test=
"favoritesId != null"
>
<if
test=
"favoritesId != null"
>
#{favoritesId,jdbcType=BIGINT},
#{favoritesId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"userId != null"
>
#{userId,jdbcType=BIGINT},
</if>
<if
test=
"itemId != null"
>
<if
test=
"itemId != null"
>
#{itemId,jdbcType=BIGINT},
#{itemId,jdbcType=BIGINT},
</if>
</if>
...
@@ -167,6 +174,9 @@
...
@@ -167,6 +174,9 @@
<if
test=
"record.favoritesId != null"
>
<if
test=
"record.favoritesId != null"
>
favorites_id = #{record.favoritesId,jdbcType=BIGINT},
favorites_id = #{record.favoritesId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"record.userId != null"
>
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if
test=
"record.itemId != null"
>
<if
test=
"record.itemId != null"
>
item_id = #{record.itemId,jdbcType=BIGINT},
item_id = #{record.itemId,jdbcType=BIGINT},
</if>
</if>
...
@@ -181,6 +191,7 @@
...
@@ -181,6 +191,7 @@
<update
id=
"updateByExample"
parameterType=
"map"
>
<update
id=
"updateByExample"
parameterType=
"map"
>
update favorites_items_relation
update favorites_items_relation
set favorites_id = #{record.favoritesId,jdbcType=BIGINT},
set favorites_id = #{record.favoritesId,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
item_id = #{record.itemId,jdbcType=BIGINT},
item_id = #{record.itemId,jdbcType=BIGINT},
add_time = #{record.addTime,jdbcType=TIMESTAMP}
add_time = #{record.addTime,jdbcType=TIMESTAMP}
<if
test=
"_parameter != null"
>
<if
test=
"_parameter != null"
>
...
@@ -214,13 +225,13 @@
...
@@ -214,13 +225,13 @@
select
select
'true' as QUERYID,
'true' as QUERYID,
<choose>
<choose>
<when
test=
"selective != null and selective.length
>
0"
>
<when
test=
"selective != null and selective.length
>
0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
${column.escapedColumnName}
</foreach>
</foreach>
</when>
</when>
<otherwise>
<otherwise>
favorites_id, item_id, add_time
favorites_id,
user_id,
item_id, add_time
</otherwise>
</otherwise>
</choose>
</choose>
from favorites_items_relation
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
;
package
com.wwdz.ch.wx.config
;
import
java.util.List
;
import
com.wwdz.ch.wx.annotation.support.LoginUserHandlerMethodArgumentResolver
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
@Configuration
@Configuration
public
class
WxWebMvcConfiguration
implements
WebMvcConfigurer
{
public
class
WxWebMvcConfiguration
implements
WebMvcConfigurer
{
@Bean
LoginInterceptor
loginInterceptor
()
{
return
new
LoginInterceptor
();
}
@Autowired
@Autowired
private
LoginUserHandlerMethodArgumentResolver
loginUserHandlerMethodArgumentResolver
;
private
LoginUserHandlerMethodArgumentResolver
loginUserHandlerMethodArgumentResolver
;
...
@@ -17,4 +24,12 @@ public class WxWebMvcConfiguration implements WebMvcConfigurer {
...
@@ -17,4 +24,12 @@ public class WxWebMvcConfiguration implements WebMvcConfigurer {
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
argumentResolvers
.
add
(
loginUserHandlerMethodArgumentResolver
);
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
;
package
com.wwdz.ch.wx.entity.vo
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
public
class
ItemResponseVo
{
public
class
ItemResponseVo
implements
Entity
{
private
Long
id
;
private
Long
id
;
private
Long
itemId
;
private
Long
itemId
;
private
Integer
cid
;
private
Integer
cid
;
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
481b195b
package
com.wwdz.ch.wx.impl
;
package
com.wwdz.ch.wx.impl
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.CommonEnum
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
...
@@ -14,6 +15,7 @@ import com.wwdz.ch.db.dto.request.CoinRequestDto;
...
@@ -14,6 +15,7 @@ import com.wwdz.ch.db.dto.request.CoinRequestDto;
import
com.wwdz.ch.wx.entity.request.FavoritesRequestDto
;
import
com.wwdz.ch.wx.entity.request.FavoritesRequestDto
;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo
;
import
com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo
;
import
com.wwdz.ch.wx.entity.vo.FavoritesResponseVo
;
import
com.wwdz.ch.wx.entity.vo.ItemResponseVo
;
import
com.wwdz.ch.wx.entity.vo.ItemResponseVo
;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -72,6 +74,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -72,6 +74,7 @@ public class FavoritesServiceImpl implements FavoritesService {
page
.
setTotal
(
0
);
page
.
setTotal
(
0
);
page
.
setList
(
new
ArrayList
<>());
page
.
setList
(
new
ArrayList
<>());
PageInfo
<
Favorites
>
favoritesPage
=
favoritesDao
.
pageByUserId
(
dto
.
getUserId
(),
dto
.
getPage
(),
dto
.
getSize
());
PageInfo
<
Favorites
>
favoritesPage
=
favoritesDao
.
pageByUserId
(
dto
.
getUserId
(),
dto
.
getPage
(),
dto
.
getSize
());
page
.
setHasNextPage
(
favoritesPage
.
isHasNextPage
());
if
(
favoritesPage
.
getList
().
isEmpty
())
{
if
(
favoritesPage
.
getList
().
isEmpty
())
{
return
Result
.
success
(
page
);
return
Result
.
success
(
page
);
}
}
...
@@ -80,11 +83,22 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -80,11 +83,22 @@ public class FavoritesServiceImpl implements FavoritesService {
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setViewType
(
2
);
agentTranceResponseVo
.
setViewType
(
2
);
agentTranceResponseVo
.
setDetail
(
favorites
);
FavoritesResponseVo
vo
=
new
FavoritesResponseVo
();
vo
.
setId
(
favorites
.
getId
());
vo
.
setTitle
(
favorites
.
getTitle
());
vo
.
setDescription
(
favorites
.
getDescription
());
vo
.
setSort
(
favorites
.
getSort
());
vo
.
setDeleted
(
favorites
.
getDeleted
());
vo
.
setAddTime
(
favorites
.
getAddTime
());
vo
.
setImages
(
favorites
.
getImages
());
vo
.
setUpdateTime
(
favorites
.
getUpdateTime
());
vo
.
setCount
(
favoritesItemsRelationDao
.
countByFavoritesId
(
favorites
.
getId
()));
agentTranceResponseVo
.
setDetail
(
vo
);
list
.
add
(
agentTranceResponseVo
);
list
.
add
(
agentTranceResponseVo
);
}
}
page
.
setTotal
(
favoritesPage
.
getTotal
());
page
.
setTotal
(
favoritesPage
.
getTotal
());
page
.
setList
(
list
);
page
.
setList
(
list
);
logger
.
info
(
"【请求结束】分页查询收藏册列表成功"
);
return
Result
.
success
(
page
);
return
Result
.
success
(
page
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询收藏册列表失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"查询收藏册列表失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -95,7 +109,23 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -95,7 +109,23 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override
@Override
public
Result
list
(
FavoritesRequestDto
dto
)
{
public
Result
list
(
FavoritesRequestDto
dto
)
{
try
{
try
{
return
Result
.
success
(
favoritesDao
.
listByUserId
(
dto
.
getUserId
()));
List
<
Favorites
>
list
=
favoritesDao
.
listByUserId
(
dto
.
getUserId
());
List
<
FavoritesResponseVo
>
result
=
new
ArrayList
<>();
for
(
Favorites
favorites
:
list
)
{
FavoritesResponseVo
vo
=
new
FavoritesResponseVo
();
vo
.
setId
(
favorites
.
getId
());
vo
.
setTitle
(
favorites
.
getTitle
());
vo
.
setDescription
(
favorites
.
getDescription
());
vo
.
setSort
(
favorites
.
getSort
());
vo
.
setDeleted
(
favorites
.
getDeleted
());
vo
.
setAddTime
(
favorites
.
getAddTime
());
vo
.
setImages
(
favorites
.
getImages
());
vo
.
setUpdateTime
(
favorites
.
getUpdateTime
());
vo
.
setCount
(
favoritesItemsRelationDao
.
countByFavoritesId
(
favorites
.
getId
()));
result
.
add
(
vo
);
}
logger
.
info
(
"【请求结束】查询收藏册列表成功"
);
return
Result
.
success
(
result
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取收藏册列表失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"获取收藏册列表失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(-
1
,
"获取收藏册列表失败"
);
return
Result
.
failed
(-
1
,
"获取收藏册列表失败"
);
...
@@ -115,13 +145,13 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -115,13 +145,13 @@ public class FavoritesServiceImpl implements FavoritesService {
favorites
.
setUserId
(
dto
.
getUserId
());
favorites
.
setUserId
(
dto
.
getUserId
());
favorites
.
setTitle
(
dto
.
getTitle
());
favorites
.
setTitle
(
dto
.
getTitle
());
favorites
.
setDescription
(
dto
.
getDescription
());
favorites
.
setDescription
(
dto
.
getDescription
());
favorites
.
setImages
(
dto
.
getImages
());
Date
date
=
new
Date
();
Date
date
=
new
Date
();
favorites
.
setAddTime
(
date
);
favorites
.
setAddTime
(
date
);
favorites
.
setUpdateTime
(
date
);
favorites
.
setUpdateTime
(
date
);
favorites
.
setDeleted
(
false
);
favorites
.
setDeleted
(
false
);
favorites
.
setSort
(
0
);
favorites
.
setSort
(
0
);
favoritesDao
.
insert
(
favorites
);
favoritesDao
.
insert
(
favorites
);
logger
.
info
(
"【请求结束】新增收藏册成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"新增收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"新增收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -145,14 +175,14 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -145,14 +175,14 @@ public class FavoritesServiceImpl implements FavoritesService {
favorites
.
setTitle
(
dto
.
getTitle
());
favorites
.
setTitle
(
dto
.
getTitle
());
favorites
.
setDescription
(
dto
.
getDescription
());
favorites
.
setDescription
(
dto
.
getDescription
());
favorites
.
setImages
(
dto
.
getImages
());
favorites
.
setUpdateTime
(
new
Date
());
favorites
.
setUpdateTime
(
new
Date
());
favoritesDao
.
update
(
favorites
);
favoritesDao
.
update
(
favorites
);
logger
.
info
(
"【请求结束】修改收藏册成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"
新增
收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"
修改
收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"
新增
收藏册失败"
);
return
Result
.
failed
(
"
修改
收藏册失败"
);
}
}
}
}
...
@@ -163,6 +193,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -163,6 +193,7 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
Objects
.
isNull
(
favorites
))
{
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,记录不存在"
);
return
Result
.
failed
(
"数据异常,记录不存在"
);
}
}
logger
.
info
(
"【请求结束】查看收藏册详情成功"
);
return
Result
.
success
(
favorites
);
return
Result
.
success
(
favorites
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"查看收藏册详情失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"查看收藏册详情失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -179,6 +210,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -179,6 +210,7 @@ public class FavoritesServiceImpl implements FavoritesService {
page
.
setTotal
(
0L
);
page
.
setTotal
(
0L
);
page
.
setList
(
new
ArrayList
<>());
page
.
setList
(
new
ArrayList
<>());
PageInfo
<
FavoritesItemsRelation
>
relationPage
=
favoritesItemsRelationDao
.
pageByFavoritesId
(
dto
.
getId
(),
dto
.
getPage
(),
dto
.
getSize
());
PageInfo
<
FavoritesItemsRelation
>
relationPage
=
favoritesItemsRelationDao
.
pageByFavoritesId
(
dto
.
getId
(),
dto
.
getPage
(),
dto
.
getSize
());
page
.
setHasNextPage
(
relationPage
.
isHasNextPage
());
if
(
relationPage
.
getList
().
isEmpty
())
{
if
(
relationPage
.
getList
().
isEmpty
())
{
return
Result
.
success
(
page
);
return
Result
.
success
(
page
);
}
}
...
@@ -192,7 +224,11 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -192,7 +224,11 @@ public class FavoritesServiceImpl implements FavoritesService {
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
relation
.
getItemId
())
?
1
:
0
);
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
relation
.
getItemId
())
?
1
:
0
);
vo
.
setCollectCount
(
favoritesItemsRelationDao
.
countByItemId
(
relation
.
getItemId
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
if
(
item
.
getSourceType
().
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
vo
.
setCollectCount
(
count
);
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
...
@@ -202,6 +238,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -202,6 +238,7 @@ public class FavoritesServiceImpl implements FavoritesService {
}
}
page
.
setTotal
(
favoritesItemsRelationDao
.
countByFavoritesId
(
dto
.
getId
()));
page
.
setTotal
(
favoritesItemsRelationDao
.
countByFavoritesId
(
dto
.
getId
()));
page
.
setList
(
list
);
page
.
setList
(
list
);
logger
.
info
(
"【请求结束】查看收藏册的藏品列表成功"
);
return
Result
.
success
(
page
);
return
Result
.
success
(
page
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"查看收藏册的藏品列表失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"查看收藏册的藏品列表失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -220,6 +257,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -220,6 +257,7 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册
// 删除收藏册
favoritesDao
.
delete
(
dto
.
getId
(),
null
);
favoritesDao
.
delete
(
dto
.
getId
(),
null
);
logger
.
info
(
"【请求结束】删除收藏册成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"删除收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"删除收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -254,6 +292,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -254,6 +292,7 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册
// 删除收藏册
favoritesDao
.
delete
(
null
,
dto
.
getIds
());
favoritesDao
.
delete
(
null
,
dto
.
getIds
());
logger
.
info
(
"【请求结束】批量删除收藏册成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"批量删除收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"批量删除收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -262,6 +301,33 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -262,6 +301,33 @@ public class FavoritesServiceImpl implements FavoritesService {
}
}
}
}
@Transactional
@Override
public
Result
addItem
(
ItemRequestDto
dto
)
{
try
{
Favorites
favorites
=
favoritesDao
.
info
(
dto
.
getFavoritesId
());
if
(
Objects
.
isNull
(
favorites
))
{
Result
.
failed
(
"数据异常,收藏册不存在"
);
}
if
(
favoritesItemsRelationDao
.
isCollected
(
favorites
.
getUserId
(),
dto
.
getId
()))
{
Result
.
failed
(
"您已经收藏过该藏品"
);
}
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
favorites
.
getUserId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getFavoritesId
());
favoritesItemsRelation
.
setItemId
(
dto
.
getId
());
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
logger
.
info
(
"【请求结束】收藏藏品成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"收藏藏品失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"收藏藏品失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
Result
removeItem
(
ItemRequestDto
dto
)
{
public
Result
removeItem
(
ItemRequestDto
dto
)
{
...
@@ -280,6 +346,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -280,6 +346,7 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册和钱币的关联
// 删除收藏册和钱币的关联
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
logger
.
info
(
"【请求结束】取消收藏成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
info
(
"收藏册取消收藏失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
info
(
"收藏册取消收藏失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -292,6 +359,10 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -292,6 +359,10 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override
@Override
public
Result
moveItem
(
ItemRequestDto
dto
)
{
public
Result
moveItem
(
ItemRequestDto
dto
)
{
try
{
try
{
Favorites
favorites
=
favoritesDao
.
info
(
dto
.
getAfterFavoritesId
());
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,目标收藏册不存在"
);
}
// 删除原收藏册和藏品关联记录
// 删除原收藏册和藏品关联记录
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getBeforeFavoritesId
(),
dto
.
getItemIds
());
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getBeforeFavoritesId
(),
dto
.
getItemIds
());
...
@@ -301,6 +372,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -301,6 +372,7 @@ public class FavoritesServiceImpl implements FavoritesService {
for
(
Long
itemId
:
dto
.
getItemIds
())
{
for
(
Long
itemId
:
dto
.
getItemIds
())
{
FavoritesItemsRelation
record
=
new
FavoritesItemsRelation
();
FavoritesItemsRelation
record
=
new
FavoritesItemsRelation
();
record
.
setFavoritesId
(
dto
.
getAfterFavoritesId
());
record
.
setFavoritesId
(
dto
.
getAfterFavoritesId
());
record
.
setUserId
(
favorites
.
getUserId
());
record
.
setItemId
(
itemId
);
record
.
setItemId
(
itemId
);
record
.
setAddTime
(
now
);
record
.
setAddTime
(
now
);
list
.
add
(
record
);
list
.
add
(
record
);
...
@@ -308,6 +380,7 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -308,6 +380,7 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
favoritesItemsRelationDao
.
batchInsert
(
list
);
favoritesItemsRelationDao
.
batchInsert
(
list
);
}
}
logger
.
info
(
"【请求结束】移动藏品成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"移动藏品失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"移动藏品失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
481b195b
...
@@ -3,14 +3,8 @@ package com.wwdz.ch.wx.impl;
...
@@ -3,14 +3,8 @@ package com.wwdz.ch.wx.impl;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.CommonEnum
;
import
com.wwdz.ch.core.consts.CommonEnum
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dao.CategoryDao
;
import
com.wwdz.ch.db.dao.*
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.domain.*
;
import
com.wwdz.ch.db.dao.ItemDao
;
import
com.wwdz.ch.db.dao.UserItemsRelationDao
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.domain.FavoritesItemsRelation
;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.db.domain.UserItemsRelation
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo
;
import
com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo
;
...
@@ -37,6 +31,10 @@ public class ItemServiceImpl implements ItemService {
...
@@ -37,6 +31,10 @@ public class ItemServiceImpl implements ItemService {
private
FavoritesItemsRelationDao
favoritesItemsRelationDao
;
private
FavoritesItemsRelationDao
favoritesItemsRelationDao
;
@Autowired
@Autowired
private
CategoryDao
categoryDao
;
private
CategoryDao
categoryDao
;
@Autowired
private
FootPrintDao
footPrintDao
;
@Autowired
private
FavoritesDao
favoritesDao
;
@Override
@Override
...
@@ -51,6 +49,7 @@ public class ItemServiceImpl implements ItemService {
...
@@ -51,6 +49,7 @@ public class ItemServiceImpl implements ItemService {
result
.
setPageSize
(
page
.
getPageSize
());
result
.
setPageSize
(
page
.
getPageSize
());
result
.
setTotal
(
page
.
getTotal
());
result
.
setTotal
(
page
.
getTotal
());
result
.
setList
(
new
ArrayList
<>());
result
.
setList
(
new
ArrayList
<>());
result
.
setHasNextPage
(
page
.
isHasNextPage
());
if
(
CollectionUtils
.
isEmpty
(
page
.
getList
()))
{
if
(
CollectionUtils
.
isEmpty
(
page
.
getList
()))
{
return
Result
.
success
(
result
);
return
Result
.
success
(
result
);
}
}
...
@@ -62,8 +61,17 @@ public class ItemServiceImpl implements ItemService {
...
@@ -62,8 +61,17 @@ public class ItemServiceImpl implements ItemService {
vo
.
setImages
(
item
.
getImages
());
vo
.
setImages
(
item
.
getImages
());
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setIsCollected
(
0
);
if
(!
dto
.
getUserId
().
equals
(
0L
))
{
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
vo
.
setCollectCount
(
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
()));
vo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
}
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
if
(
item
.
getSourceType
().
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
vo
.
setCollectCount
(
count
);
vo
.
setSourceType
(
item
.
getSourceType
());
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
...
@@ -114,11 +122,15 @@ public class ItemServiceImpl implements ItemService {
...
@@ -114,11 +122,15 @@ public class ItemServiceImpl implements ItemService {
// 新增收藏册和藏品关联记录
// 新增收藏册和藏品关联记录
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getFavoritesId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getFavoritesId
());
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
return
Result
.
success
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
item
.
getId
());
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"发布藏品失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"发布藏品失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
...
@@ -145,6 +157,9 @@ public class ItemServiceImpl implements ItemService {
...
@@ -145,6 +157,9 @@ public class ItemServiceImpl implements ItemService {
}
}
itemResponseVo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
itemResponseVo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
itemResponseVo
.
setSourceType
(
item
.
getSourceType
());
itemResponseVo
.
setSourceType
(
item
.
getSourceType
());
itemResponseVo
.
setIsCollected
(
0
);
itemResponseVo
.
setIsMine
(
0
);
if
(!
dto
.
getUserId
().
equals
(
0L
))
{
FavoritesItemsRelation
favoritesItemsRelation
=
favoritesItemsRelationDao
.
selectByUserIdItemId
(
dto
.
getUserId
(),
item
.
getId
());
FavoritesItemsRelation
favoritesItemsRelation
=
favoritesItemsRelationDao
.
selectByUserIdItemId
(
dto
.
getUserId
(),
item
.
getId
());
if
(
Objects
.
nonNull
(
favoritesItemsRelation
))
{
if
(
Objects
.
nonNull
(
favoritesItemsRelation
))
{
itemResponseVo
.
setIsCollected
(
1
);
itemResponseVo
.
setIsCollected
(
1
);
...
@@ -153,6 +168,17 @@ public class ItemServiceImpl implements ItemService {
...
@@ -153,6 +168,17 @@ public class ItemServiceImpl implements ItemService {
itemResponseVo
.
setIsCollected
(
0
);
itemResponseVo
.
setIsCollected
(
0
);
}
}
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
// 添加用户足迹
Footprint
footprint
=
new
Footprint
();
footprint
.
setUserId
(
dto
.
getUserId
());
footprint
.
setItemId
(
item
.
getId
());
Date
now
=
new
Date
();
footprint
.
setAddTime
(
now
);
footprint
.
setUpdateTime
(
now
);
footprint
.
setDeleted
(
false
);
footPrintDao
.
insert
(
footprint
);
}
logger
.
info
(
"【请求结束】查看藏品详情成功"
);
logger
.
info
(
"【请求结束】查看藏品详情成功"
);
return
Result
.
success
(
itemResponseVo
);
return
Result
.
success
(
itemResponseVo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -165,36 +191,48 @@ public class ItemServiceImpl implements ItemService {
...
@@ -165,36 +191,48 @@ public class ItemServiceImpl implements ItemService {
@Override
@Override
public
Result
collect
(
ItemRequestDto
dto
)
{
public
Result
collect
(
ItemRequestDto
dto
)
{
try
{
try
{
Item
item
=
itemDao
.
findDetails
(
dto
.
getId
());
if
(
dto
.
getUserId
().
equals
(
0L
))
{
if
(
null
==
item
.
getId
())
{
return
Result
.
failed
(
"您尚未登录,请先登录"
);
return
Result
.
failed
(
"数据异常,该藏品不存在"
);
}
// 查找默认收藏册
Favorites
favorites
=
favoritesDao
.
defaultFavorites
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,查询不到用户的默认收藏册"
);
}
}
item
.
setName
(
dto
.
getName
());
item
.
setCid
(
dto
.
getCid
());
item
.
setImages
(
dto
.
getImages
());
item
.
setPrice
(
Long
.
parseLong
(
dto
.
getPrice
())
/
100
);
item
.
setDetail
(
dto
.
getDetail
());
Date
now
=
new
Date
();
item
.
setUpdateTime
(
now
);
item
.
setSourceType
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
());
item
.
setIsDeleted
(
false
);
itemDao
.
update
(
item
);
// 删除藏品和原收藏册关联
List
<
Long
>
itemIds
=
new
ArrayList
<>();
itemIds
.
add
(
item
.
getId
());
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getBeforeFavoritesId
(),
itemIds
);
// 新增藏品和新收藏册关联
// 新增藏品和新收藏册关联
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getAfterFavorites
Id
());
favoritesItemsRelation
.
setFavoritesId
(
favorites
.
get
Id
());
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesItemsRelation
.
setItemId
(
dto
.
getId
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"favoritesId"
,
favorites
.
getId
());
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"首页收藏失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(
"首页收藏失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
cancel
(
ItemRequestDto
dto
)
{
try
{
if
(
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"您尚未登录,请先登录"
);
}
if
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
dto
.
getId
()))
{
return
Result
.
failed
(
"操作失败,无法取消收藏"
);
}
// 删除藏品和收藏册关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"
修改藏品
失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"
首页取消收藏
失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(
"
修改藏品
失败"
);
return
Result
.
failed
(
"
首页取消收藏
失败"
);
}
}
}
}
...
@@ -206,6 +244,18 @@ public class ItemServiceImpl implements ItemService {
...
@@ -206,6 +244,18 @@ public class ItemServiceImpl implements ItemService {
return
Result
.
failed
(
"数据异常,该藏品不存在"
);
return
Result
.
failed
(
"数据异常,该藏品不存在"
);
}
}
item
.
setName
(
dto
.
getName
());
item
.
setCid
(
dto
.
getCid
());
item
.
setImages
(
dto
.
getImages
());
item
.
setPrice
(
Long
.
parseLong
(
dto
.
getPrice
())
/
100
);
item
.
setDetail
(
dto
.
getDetail
());
Date
now
=
new
Date
();
item
.
setUpdateTime
(
now
);
itemDao
.
update
(
item
);
// 删除原来藏品和收藏册关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
// 新增藏品和收藏册关联
// 新增藏品和收藏册关联
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
...
@@ -214,8 +264,8 @@ public class ItemServiceImpl implements ItemService {
...
@@ -214,8 +264,8 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"
收藏
藏品失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"
修改
藏品失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(
"
收藏
藏品失败"
);
return
Result
.
failed
(
"
修改
藏品失败"
);
}
}
}
}
}
}
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 {
...
@@ -21,6 +21,7 @@ public interface FavoritesService {
Result
delete
(
FavoritesRequestDto
dto
);
Result
delete
(
FavoritesRequestDto
dto
);
Result
batchDelete
(
FavoritesRequestDto
dto
);
Result
batchDelete
(
FavoritesRequestDto
dto
);
Result
addItem
(
ItemRequestDto
dto
);
Result
removeItem
(
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 {
...
@@ -14,5 +14,7 @@ public interface ItemService {
Result
collect
(
ItemRequestDto
dto
);
Result
collect
(
ItemRequestDto
dto
);
Result
cancel
(
ItemRequestDto
dto
);
Result
update
(
ItemRequestDto
dto
);
Result
update
(
ItemRequestDto
dto
);
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
View file @
481b195b
...
@@ -5,22 +5,20 @@ import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
...
@@ -5,22 +5,20 @@ import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.request.KlDataRequestDto
;
import
com.wwdz.ch.wx.entity.request.KlDataRequestDto
;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
com.xxdxxs.support.Delete
;
import
com.xxdxxs.support.Select
;
import
com.xxdxxs.utils.JsonUtils
;
import
com.xxdxxs.utils.JsonUtils
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Objects
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RestController
@RestController
@RequestMapping
(
"/wx/favorites"
)
@RequestMapping
(
"/wx/favorites"
)
...
@@ -72,46 +70,79 @@ public class WxFavoritesController {
...
@@ -72,46 +70,79 @@ public class WxFavoritesController {
@ApiOperation
(
value
=
"新增"
)
@ApiOperation
(
value
=
"新增"
)
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
FavoritesRequestDto
dto
)
{
public
Result
add
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册新增,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
title
=
JsonUtils
.
getValueByPath
(
json
,
"title"
);
String
description
=
JsonUtils
.
getValueByPath
(
json
,
"description"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
return
Result
.
failed
(
"用户id不能为空"
);
}
}
if
(
StringUtils
.
isBlank
(
dto
.
getTitle
()
))
{
if
(
StringUtils
.
isBlank
(
title
))
{
return
Result
.
failed
(
"标题不能为空"
);
return
Result
.
failed
(
"标题不能为空"
);
}
}
if
(
dto
.
getTitle
()
.
length
()
>
20
)
{
if
(
title
.
length
()
>
20
)
{
return
Result
.
failed
(
"标题的字数不能大于20字"
);
return
Result
.
failed
(
"标题的字数不能大于20字"
);
}
}
if
(
StringUtils
.
isNotBlank
(
d
to
.
getDescription
())
&&
dto
.
getDescription
()
.
length
()
>
200
)
{
if
(
StringUtils
.
isNotBlank
(
d
escription
)
&&
description
.
length
()
>
200
)
{
return
Result
.
failed
(
"描述的字数不能大于200字"
);
return
Result
.
failed
(
"描述的字数不能大于200字"
);
}
}
FavoritesRequestDto
dto
=
new
FavoritesRequestDto
();
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setTitle
(
title
);
dto
.
setDescription
(
description
);
return
favoritesService
.
add
(
dto
);
return
favoritesService
.
add
(
dto
);
}
}
@ApiOperation
(
value
=
"修改"
)
@ApiOperation
(
value
=
"修改"
)
@PostMapping
(
"/update"
)
@PostMapping
(
"/update"
)
public
Result
update
(
@RequestBody
FavoritesRequestDto
dto
)
{
public
Result
update
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
if
(
Objects
.
isNull
(
dto
.
getId
()))
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册修改,请求参数,kl_data:{}"
,
json
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
title
=
JsonUtils
.
getValueByPath
(
json
,
"title"
);
String
description
=
JsonUtils
.
getValueByPath
(
json
,
"description"
);
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"id不能为空"
);
return
Result
.
failed
(
"id不能为空"
);
}
}
if
(
Objects
.
isNull
(
dto
.
getUserId
()
))
{
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
return
Result
.
failed
(
"用户id不能为空"
);
}
}
if
(
StringUtils
.
isBlank
(
dto
.
getTitle
()
))
{
if
(
StringUtils
.
isBlank
(
title
))
{
return
Result
.
failed
(
"标题不能为空"
);
return
Result
.
failed
(
"标题不能为空"
);
}
}
if
(
dto
.
getTitle
()
.
length
()
>
20
)
{
if
(
title
.
length
()
>
20
)
{
return
Result
.
failed
(
"标题的字数不能大于20字"
);
return
Result
.
failed
(
"标题的字数不能大于20字"
);
}
}
if
(
StringUtils
.
isNotBlank
(
d
to
.
getDescription
())
&&
dto
.
getDescription
()
.
length
()
>
200
)
{
if
(
StringUtils
.
isNotBlank
(
d
escription
)
&&
description
.
length
()
>
200
)
{
return
Result
.
failed
(
"描述的字数不能大于200字"
);
return
Result
.
failed
(
"描述的字数不能大于200字"
);
}
}
FavoritesRequestDto
dto
=
new
FavoritesRequestDto
();
dto
.
setId
(
Long
.
parseLong
(
id
));
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setTitle
(
title
);
dto
.
setDescription
(
description
);
return
favoritesService
.
update
(
dto
);
return
favoritesService
.
update
(
dto
);
}
}
@ApiOperation
(
value
=
"详情"
)
@ApiOperation
(
value
=
"详情"
)
@PostMapping
(
"/info"
)
@PostMapping
(
"/info"
)
public
Result
info
(
@RequestBody
@Validated
(
Select
.
class
)
FavoritesRequestDto
dto
)
{
public
Result
info
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册详情查询,请求参数,kl_data:{}"
,
json
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
FavoritesRequestDto
dto
=
new
FavoritesRequestDto
();
dto
.
setId
(
Long
.
parseLong
(
id
));
return
favoritesService
.
info
(
dto
);
return
favoritesService
.
info
(
dto
);
}
}
...
@@ -121,6 +152,7 @@ public class WxFavoritesController {
...
@@ -121,6 +152,7 @@ public class WxFavoritesController {
String
json
=
klDataRequestDto
.
getKl_data
();
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册下藏品列表分页查询,请求参数,kl_data:{}"
,
json
);
logger
.
info
(
"【请求开始】收藏册下藏品列表分页查询,请求参数,kl_data:{}"
,
json
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
page
=
JsonUtils
.
getValueByPath
(
json
,
"page"
);
String
page
=
JsonUtils
.
getValueByPath
(
json
,
"page"
);
String
size
=
JsonUtils
.
getValueByPath
(
json
,
"size"
);
String
size
=
JsonUtils
.
getValueByPath
(
json
,
"size"
);
if
(
StringUtils
.
isBlank
(
id
))
{
if
(
StringUtils
.
isBlank
(
id
))
{
...
@@ -134,7 +166,8 @@ public class WxFavoritesController {
...
@@ -134,7 +166,8 @@ public class WxFavoritesController {
}
}
FavoritesRequestDto
dto
=
new
FavoritesRequestDto
();
FavoritesRequestDto
dto
=
new
FavoritesRequestDto
();
dto
.
setUserId
(
Long
.
parseLong
(
id
));
dto
.
setId
(
Long
.
parseLong
(
id
));
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setPage
(
Integer
.
parseInt
(
page
));
dto
.
setPage
(
Integer
.
parseInt
(
page
));
dto
.
setSize
(
Integer
.
parseInt
(
size
));
dto
.
setSize
(
Integer
.
parseInt
(
size
));
return
favoritesService
.
itemList
(
dto
);
return
favoritesService
.
itemList
(
dto
);
...
@@ -142,49 +175,107 @@ public class WxFavoritesController {
...
@@ -142,49 +175,107 @@ public class WxFavoritesController {
@ApiOperation
(
value
=
"单个删除"
)
@ApiOperation
(
value
=
"单个删除"
)
@PostMapping
(
"/delete"
)
@PostMapping
(
"/delete"
)
public
Result
delete
(
@RequestBody
@Validated
(
Delete
.
class
)
FavoritesRequestDto
dto
)
{
public
Result
delete
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
if
(
Objects
.
isNull
(
dto
.
getId
()))
{
String
json
=
klDataRequestDto
.
getKl_data
();
return
Result
.
failed
(
"id不能为空"
);
logger
.
info
(
"【请求开始】收藏册单个删除,请求参数,kl_data:{}"
,
json
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
}
FavoritesRequestDto
dto
=
new
FavoritesRequestDto
();
dto
.
setId
(
Long
.
parseLong
(
id
));
return
favoritesService
.
delete
(
dto
);
return
favoritesService
.
delete
(
dto
);
}
}
@ApiOperation
(
value
=
"批量删除"
)
@ApiOperation
(
value
=
"批量删除"
)
@PostMapping
(
"/batchDelete"
)
@PostMapping
(
"/batchDelete"
)
public
Result
batchDelete
(
@RequestBody
@Validated
(
Delete
.
class
)
FavoritesRequestDto
dto
)
{
public
Result
batchDelete
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
if
(
CollectionUtils
.
isEmpty
(
dto
.
getIds
()))
{
String
json
=
klDataRequestDto
.
getKl_data
();
return
Result
.
failed
(
"请选择收藏册"
);
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
());
FavoritesRequestDto
dto
=
new
FavoritesRequestDto
();
dto
.
setIds
(
idss
);
return
favoritesService
.
batchDelete
(
dto
);
return
favoritesService
.
batchDelete
(
dto
);
}
}
@ApiOperation
(
value
=
"收藏"
)
@PostMapping
(
"/addItem"
)
public
Result
addItem
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册收藏,请求参数,kl_data:{}"
,
json
);
String
favoritesId
=
JsonUtils
.
getValueByPath
(
json
,
"favoritesId"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
favoritesId
))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"请选择藏品"
);
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setFavoritesId
(
Long
.
parseLong
(
favoritesId
));
dto
.
setId
(
Long
.
parseLong
(
id
));
return
favoritesService
.
addItem
(
dto
);
}
@ApiOperation
(
value
=
"取消收藏"
)
@ApiOperation
(
value
=
"取消收藏"
)
@PostMapping
(
"/removeItem"
)
@PostMapping
(
"/removeItem"
)
public
Result
removeItem
(
@RequestBody
ItemRequestDto
dto
)
{
public
Result
removeItem
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册取消收藏,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
favoritesId
=
JsonUtils
.
getValueByPath
(
json
,
"favoritesId"
);
String
itemIds
=
JsonUtils
.
getValueByPath
(
json
,
"itemIds"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
return
Result
.
failed
(
"用户id不能为空"
);
}
}
if
(
Objects
.
isNull
(
dto
.
getFavoritesId
()
))
{
if
(
StringUtils
.
isBlank
(
favoritesId
))
{
return
Result
.
failed
(
"收藏册不能为空"
);
return
Result
.
failed
(
"收藏册
id
不能为空"
);
}
}
if
(
CollectionUtils
.
isEmpty
(
dto
.
getItemIds
()
))
{
if
(
StringUtils
.
isBlank
(
itemIds
))
{
return
Result
.
failed
(
"请选择藏品"
);
return
Result
.
failed
(
"请选择藏品"
);
}
}
List
<
Long
>
itemIdss
=
Arrays
.
stream
(
itemIds
.
substring
(
1
,
itemIds
.
length
()
-
1
).
split
(
","
))
.
map
(
Long:
:
valueOf
).
collect
(
Collectors
.
toList
());
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setFavoritesId
(
Long
.
parseLong
(
favoritesId
));
dto
.
setItemIds
(
itemIdss
);
return
favoritesService
.
removeItem
(
dto
);
return
favoritesService
.
removeItem
(
dto
);
}
}
@ApiOperation
(
value
=
"移动藏品"
)
@ApiOperation
(
value
=
"移动藏品"
)
@PostMapping
(
"/moveItem"
)
@PostMapping
(
"/moveItem"
)
public
Result
moveItem
(
@RequestBody
ItemRequestDto
dto
)
{
public
Result
moveItem
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
if
(
Objects
.
isNull
(
dto
.
getBeforeFavoritesId
()))
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册移动藏品,请求参数,kl_data:{}"
,
json
);
String
beforeFavoritesId
=
JsonUtils
.
getValueByPath
(
json
,
"beforeFavoritesId"
);
String
afterFavoritesId
=
JsonUtils
.
getValueByPath
(
json
,
"afterFavoritesId"
);
String
itemIds
=
JsonUtils
.
getValueByPath
(
json
,
"itemIds"
);
if
(
StringUtils
.
isBlank
(
beforeFavoritesId
))
{
return
Result
.
failed
(
"原收藏册不能为空"
);
return
Result
.
failed
(
"原收藏册不能为空"
);
}
}
if
(
Objects
.
isNull
(
dto
.
getAfterFavoritesId
()
))
{
if
(
StringUtils
.
isBlank
(
afterFavoritesId
))
{
return
Result
.
failed
(
"现收藏册不能为空"
);
return
Result
.
failed
(
"现收藏册不能为空"
);
}
}
if
(
CollectionUtils
.
isEmpty
(
dto
.
getItemIds
()
))
{
if
(
StringUtils
.
isBlank
(
itemIds
))
{
return
Result
.
failed
(
"请选择藏品"
);
return
Result
.
failed
(
"请选择藏品"
);
}
}
List
<
Long
>
itemIdss
=
Arrays
.
stream
(
itemIds
.
substring
(
1
,
itemIds
.
length
()
-
1
).
split
(
","
))
.
map
(
Long:
:
valueOf
).
collect
(
Collectors
.
toList
());
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setBeforeFavoritesId
(
Long
.
parseLong
(
beforeFavoritesId
));
dto
.
setAfterFavoritesId
(
Long
.
parseLong
(
afterFavoritesId
));
dto
.
setItemIds
(
itemIdss
);
return
favoritesService
.
moveItem
(
dto
);
return
favoritesService
.
moveItem
(
dto
);
}
}
}
}
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;
...
@@ -11,8 +11,10 @@ import com.wwdz.ch.db.domain.Footprint;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.wx.annotation.LoginUser
;
import
com.wwdz.ch.wx.annotation.LoginUser
;
import
com.wwdz.ch.wx.entity.request.FootPrintRequestDto
;
import
com.wwdz.ch.wx.entity.request.FootPrintRequestDto
;
import
com.wwdz.ch.wx.entity.request.KlDataRequestDto
;
import
com.wwdz.ch.wx.service.FootPrintService
;
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.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -20,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
...
@@ -20,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* 用户访问足迹服务
* 用户访问足迹服务
...
@@ -126,28 +129,52 @@ public class WxFootprintController {
...
@@ -126,28 +129,52 @@ public class WxFootprintController {
}
}
@PostMapping
(
"/page"
)
@PostMapping
(
"/page"
)
public
Result
page
(
@RequestBody
FootPrintRequestDto
dto
)
{
public
Result
page
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
logger
.
info
(
"【请求开始】用户足迹列表查询,请求参数,userId:{}"
,
dto
.
getUserId
());
String
json
=
klDataRequestDto
.
getKl_data
();
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
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不能为空"
);
return
Result
.
failed
(
"用户id不能为空"
);
}
}
if
(
Objects
.
isNull
(
dto
.
getPage
()
))
{
if
(
StringUtils
.
isBlank
(
page
))
{
return
Result
.
failed
(
"当前页不能为空"
);
return
Result
.
failed
(
"当前页不能为空"
);
}
}
if
(
Objects
.
isNull
(
dto
.
getSize
()
))
{
if
(
StringUtils
.
isBlank
(
size
))
{
return
Result
.
failed
(
"页面大小不能为空"
);
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
);
return
footPrintService
.
page
(
dto
);
}
}
@PostMapping
(
"/del"
)
@PostMapping
(
"/del"
)
public
Result
delete
(
@RequestBody
FootPrintRequestDto
dto
)
{
public
Result
delete
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
logger
.
info
(
"【请求开始】用户足迹删除,请求参数,ids:{}"
,
dto
.
getIds
());
String
json
=
klDataRequestDto
.
getKl_data
();
if
(
CollectionUtils
.
isEmpty
(
dto
.
getIds
()))
{
logger
.
info
(
"【请求开始】收藏册收藏,请求参数,kl_data:{}"
,
json
);
return
Result
.
failed
(
"请选择足迹"
);
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
);
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 {
...
@@ -27,13 +27,10 @@ public class WxItemController {
@PostMapping
(
"/page"
)
@PostMapping
(
"/page"
)
public
Result
page
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
public
Result
page
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】藏品列表
分页查询
,请求参数,kl_data:{}"
,
json
);
logger
.
info
(
"【请求开始】藏品列表
首页
,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
page
=
JsonUtils
.
getValueByPath
(
json
,
"page"
);
String
page
=
JsonUtils
.
getValueByPath
(
json
,
"page"
);
String
size
=
JsonUtils
.
getValueByPath
(
json
,
"size"
);
String
size
=
JsonUtils
.
getValueByPath
(
json
,
"size"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
page
))
{
if
(
StringUtils
.
isBlank
(
page
))
{
return
Result
.
failed
(
"当前页不能为空"
);
return
Result
.
failed
(
"当前页不能为空"
);
}
}
...
@@ -42,7 +39,10 @@ public class WxItemController {
...
@@ -42,7 +39,10 @@ public class WxItemController {
}
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
0L
);
if
(
StringUtils
.
isNotBlank
(
userId
))
{
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
}
dto
.
setPage
(
Integer
.
parseInt
(
page
));
dto
.
setPage
(
Integer
.
parseInt
(
page
));
dto
.
setSize
(
Integer
.
parseInt
(
size
));
dto
.
setSize
(
Integer
.
parseInt
(
size
));
return
itemService
.
page
(
dto
);
return
itemService
.
page
(
dto
);
...
@@ -56,13 +56,90 @@ public class WxItemController {
...
@@ -56,13 +56,90 @@ public class WxItemController {
@ApiOperation
(
value
=
"新增"
)
@ApiOperation
(
value
=
"新增"
)
@PostMapping
(
"/add"
)
@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
);
return
itemService
.
add
(
dto
);
}
}
@ApiOperation
(
value
=
"修改"
)
@ApiOperation
(
value
=
"修改"
)
@PostMapping
(
"/update"
)
@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
);
return
itemService
.
update
(
dto
);
}
}
...
@@ -73,16 +150,56 @@ public class WxItemController {
...
@@ -73,16 +150,56 @@ public class WxItemController {
logger
.
info
(
"【请求开始】藏品详情查询,请求参数,kl_data:{}"
,
json
);
logger
.
info
(
"【请求开始】藏品详情查询,请求参数,kl_data:{}"
,
json
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
userId
=
JsonUtils
.
getValueByPath
(
json
,
"userId"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
userId
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
id
))
{
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"
当前页
不能为空"
);
return
Result
.
failed
(
"
藏品id
不能为空"
);
}
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setUserId
(
0L
);
if
(
StringUtils
.
isNotBlank
(
userId
))
{
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
dto
.
setUserId
(
Long
.
parseLong
(
userId
));
}
dto
.
setId
(
Long
.
parseLong
(
id
));
dto
.
setId
(
Long
.
parseLong
(
id
));
return
itemService
.
info
(
dto
);
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