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
cad17097
Commit
cad17097
authored
Aug 08, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
eb839b71
8f0701c2
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
690 additions
and
69 deletions
+690
-69
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
...in/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
+2
-1
ch-dao/src/main/java/com/wwdz/ch/db/dao/UserDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/UserDao.java
+4
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/impl/FavoritesItemsRelationDaoImpl.java
...om/wwdz/ch/db/dao/impl/FavoritesItemsRelationDaoImpl.java
+11
-1
ch-dao/src/main/java/com/wwdz/ch/db/dao/impl/UserDaoImpl.java
...ao/src/main/java/com/wwdz/ch/db/dao/impl/UserDaoImpl.java
+14
-0
ch-dao/src/main/java/com/wwdz/ch/db/domain/User.java
ch-dao/src/main/java/com/wwdz/ch/db/domain/User.java
+19
-1
ch-dao/src/main/java/com/wwdz/ch/db/domain/UserExample.java
ch-dao/src/main/java/com/wwdz/ch/db/domain/UserExample.java
+284
-0
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/UserMapper.xml
...o/src/main/resources/com/wwdz/ch/db/mapper/UserMapper.xml
+46
-14
ch-wx-api/src/main/java/com/wwdz/ch/wx/constant/CacheCodeEnum.java
.../src/main/java/com/wwdz/ch/wx/constant/CacheCodeEnum.java
+50
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/request/UserRequestDto.java
...in/java/com/wwdz/ch/wx/entity/request/UserRequestDto.java
+3
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+41
-4
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
+2
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+1
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
+96
-43
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
...rc/main/java/com/wwdz/ch/wx/service/FavoritesService.java
+2
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/UserService.java
...api/src/main/java/com/wwdz/ch/wx/service/UserService.java
+4
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
...c/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
+6
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxUserController.java
...pi/src/main/java/com/wwdz/ch/wx/web/WxUserController.java
+105
-2
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
View file @
cad17097
...
...
@@ -13,6 +13,7 @@ public interface FavoritesItemsRelationDao {
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
FavoritesItemsRelation
selectByUserIdItemId
(
Long
userId
,
Long
itemId
);
PageInfo
<
FavoritesItemsRelation
>
pageByFavoritesId
(
Long
favoritesId
,
int
page
,
int
size
);
long
count
(
Long
itemId
);
long
count
ByItemId
(
Long
itemId
);
boolean
isCollected
(
Long
userId
,
Long
itemId
);
long
countByFavoritesId
(
Long
favoritesId
);
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/UserDao.java
View file @
cad17097
...
...
@@ -9,6 +9,10 @@ public interface UserDao {
User
queryById
(
Long
id
);
boolean
isExistedByNickname
(
Long
userId
,
String
nickname
);
boolean
isExistedByWechatId
(
Long
userId
,
String
wechatId
);
int
insert
(
User
user
);
int
updateById
(
User
user
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dao/impl/FavoritesItemsRelationDaoImpl.java
View file @
cad17097
...
...
@@ -47,6 +47,7 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
favoritesId
,
criteria:
:
andFavoritesIdEqualTo
);
JdbcHelper
.
ifPresent
(
favoritesIds
,
criteria:
:
andFavoritesIdIn
);
example
.
orderBy
(
"add_time desc"
);
return
favoritesItemsRelationMapper
.
selectByExample
(
example
);
}
...
...
@@ -64,13 +65,14 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andFavoritesIdEqualTo
(
favoritesId
);
example
.
orderBy
(
"add_time desc"
);
PageHelper
.
startPage
(
page
,
size
);
List
<
FavoritesItemsRelation
>
list
=
favoritesItemsRelationMapper
.
selectByExample
(
example
);
return
new
PageInfo
<>(
list
);
}
@Override
public
long
count
(
Long
itemId
)
{
public
long
count
ByItemId
(
Long
itemId
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andItemIdEqualTo
(
itemId
);
...
...
@@ -85,4 +87,12 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
criteria
.
andItemIdEqualTo
(
itemId
);
return
favoritesItemsRelationMapper
.
countByExample
(
example
)
>
0
;
}
@Override
public
long
countByFavoritesId
(
Long
favoritesId
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
favoritesId
,
criteria:
:
andFavoritesIdEqualTo
);
return
favoritesItemsRelationMapper
.
countByExample
(
example
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/impl/UserDaoImpl.java
View file @
cad17097
...
...
@@ -36,6 +36,20 @@ public class UserDaoImpl implements UserDao {
return
userMapper
.
selectOneByExample
(
example
);
}
@Override
public
boolean
isExistedByNickname
(
Long
userId
,
String
nickname
)
{
UserExample
example
=
new
UserExample
();
example
.
or
().
andIdNotEqualTo
(
userId
).
andNicknameEqualTo
(
nickname
).
andDeletedEqualTo
(
false
);
return
userMapper
.
countByExample
(
example
)
>
0
;
}
@Override
public
boolean
isExistedByWechatId
(
Long
userId
,
String
wechatId
)
{
UserExample
example
=
new
UserExample
();
example
.
or
().
andIdNotEqualTo
(
userId
).
andWechatIdEqualTo
(
wechatId
).
andDeletedEqualTo
(
false
);
return
userMapper
.
countByExample
(
example
)
>
0
;
}
@Override
public
int
insert
(
User
user
)
{
return
userMapper
.
insert
(
user
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/User.java
View file @
cad17097
...
...
@@ -9,7 +9,7 @@ import java.util.Date;
/**
* @author shiyu
* @date 2023/0
7/26
* @date 2023/0
8/07
*/
@Data
public
class
User
implements
Serializable
{
...
...
@@ -83,6 +83,16 @@ public class User implements Serializable {
*/
private
String
avatar
;
/**
* 用户简介
*/
private
String
profile
;
/**
* 用户背景图片
*/
private
String
background
;
/**
* 微信登录openid
*/
...
...
@@ -134,6 +144,8 @@ public class User implements Serializable {
sb
.
append
(
", nickname="
).
append
(
nickname
);
sb
.
append
(
", mobile="
).
append
(
mobile
);
sb
.
append
(
", avatar="
).
append
(
avatar
);
sb
.
append
(
", profile="
).
append
(
profile
);
sb
.
append
(
", background="
).
append
(
background
);
sb
.
append
(
", weixinOpenid="
).
append
(
weixinOpenid
);
sb
.
append
(
", wechatId="
).
append
(
wechatId
);
sb
.
append
(
", status="
).
append
(
status
);
...
...
@@ -169,6 +181,8 @@ public class User implements Serializable {
&&
(
this
.
getNickname
()
==
null
?
other
.
getNickname
()
==
null
:
this
.
getNickname
().
equals
(
other
.
getNickname
()))
&&
(
this
.
getMobile
()
==
null
?
other
.
getMobile
()
==
null
:
this
.
getMobile
().
equals
(
other
.
getMobile
()))
&&
(
this
.
getAvatar
()
==
null
?
other
.
getAvatar
()
==
null
:
this
.
getAvatar
().
equals
(
other
.
getAvatar
()))
&&
(
this
.
getProfile
()
==
null
?
other
.
getProfile
()
==
null
:
this
.
getProfile
().
equals
(
other
.
getProfile
()))
&&
(
this
.
getBackground
()
==
null
?
other
.
getBackground
()
==
null
:
this
.
getBackground
().
equals
(
other
.
getBackground
()))
&&
(
this
.
getWeixinOpenid
()
==
null
?
other
.
getWeixinOpenid
()
==
null
:
this
.
getWeixinOpenid
().
equals
(
other
.
getWeixinOpenid
()))
&&
(
this
.
getWechatId
()
==
null
?
other
.
getWechatId
()
==
null
:
this
.
getWechatId
().
equals
(
other
.
getWechatId
()))
&&
(
this
.
getStatus
()
==
null
?
other
.
getStatus
()
==
null
:
this
.
getStatus
().
equals
(
other
.
getStatus
()))
...
...
@@ -193,6 +207,8 @@ public class User implements Serializable {
result
=
prime
*
result
+
((
getNickname
()
==
null
)
?
0
:
getNickname
().
hashCode
());
result
=
prime
*
result
+
((
getMobile
()
==
null
)
?
0
:
getMobile
().
hashCode
());
result
=
prime
*
result
+
((
getAvatar
()
==
null
)
?
0
:
getAvatar
().
hashCode
());
result
=
prime
*
result
+
((
getProfile
()
==
null
)
?
0
:
getProfile
().
hashCode
());
result
=
prime
*
result
+
((
getBackground
()
==
null
)
?
0
:
getBackground
().
hashCode
());
result
=
prime
*
result
+
((
getWeixinOpenid
()
==
null
)
?
0
:
getWeixinOpenid
().
hashCode
());
result
=
prime
*
result
+
((
getWechatId
()
==
null
)
?
0
:
getWechatId
().
hashCode
());
result
=
prime
*
result
+
((
getStatus
()
==
null
)
?
0
:
getStatus
().
hashCode
());
...
...
@@ -233,6 +249,8 @@ public class User implements Serializable {
nickname
(
"nickname"
,
"nickname"
,
"VARCHAR"
,
false
),
mobile
(
"mobile"
,
"mobile"
,
"VARCHAR"
,
false
),
avatar
(
"avatar"
,
"avatar"
,
"VARCHAR"
,
false
),
profile
(
"profile"
,
"profile"
,
"VARCHAR"
,
false
),
background
(
"background"
,
"background"
,
"VARCHAR"
,
false
),
weixinOpenid
(
"weixin_openid"
,
"weixinOpenid"
,
"VARCHAR"
,
false
),
wechatId
(
"wechat_id"
,
"wechatId"
,
"VARCHAR"
,
false
),
status
(
"status"
,
"status"
,
"TINYINT"
,
true
),
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/UserExample.java
View file @
cad17097
...
...
@@ -1687,6 +1687,290 @@ public class UserExample {
return
(
Criteria
)
this
;
}
public
Criteria
andProfileIsNull
()
{
addCriterion
(
"profile is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProfileIsNotNull
()
{
addCriterion
(
"profile is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProfileEqualTo
(
String
value
)
{
addCriterion
(
"profile ="
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andProfileEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"profile = "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andProfileNotEqualTo
(
String
value
)
{
addCriterion
(
"profile <>"
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andProfileNotEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"profile <> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andProfileGreaterThan
(
String
value
)
{
addCriterion
(
"profile >"
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andProfileGreaterThanColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"profile > "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andProfileGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"profile >="
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andProfileGreaterThanOrEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"profile >= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andProfileLessThan
(
String
value
)
{
addCriterion
(
"profile <"
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andProfileLessThanColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"profile < "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andProfileLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"profile <="
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andProfileLessThanOrEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"profile <= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andProfileLike
(
String
value
)
{
addCriterion
(
"profile like"
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProfileNotLike
(
String
value
)
{
addCriterion
(
"profile not like"
,
value
,
"profile"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProfileIn
(
List
<
String
>
values
)
{
addCriterion
(
"profile in"
,
values
,
"profile"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProfileNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"profile not in"
,
values
,
"profile"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProfileBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"profile between"
,
value1
,
value2
,
"profile"
);
return
(
Criteria
)
this
;
}
public
Criteria
andProfileNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"profile not between"
,
value1
,
value2
,
"profile"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundIsNull
()
{
addCriterion
(
"background is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundIsNotNull
()
{
addCriterion
(
"background is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundEqualTo
(
String
value
)
{
addCriterion
(
"background ="
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBackgroundEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"background = "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundNotEqualTo
(
String
value
)
{
addCriterion
(
"background <>"
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBackgroundNotEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"background <> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundGreaterThan
(
String
value
)
{
addCriterion
(
"background >"
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBackgroundGreaterThanColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"background > "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"background >="
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBackgroundGreaterThanOrEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"background >= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundLessThan
(
String
value
)
{
addCriterion
(
"background <"
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBackgroundLessThanColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"background < "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"background <="
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBackgroundLessThanOrEqualToColumn
(
User
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"background <= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundLike
(
String
value
)
{
addCriterion
(
"background like"
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundNotLike
(
String
value
)
{
addCriterion
(
"background not like"
,
value
,
"background"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundIn
(
List
<
String
>
values
)
{
addCriterion
(
"background in"
,
values
,
"background"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"background not in"
,
values
,
"background"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"background between"
,
value1
,
value2
,
"background"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBackgroundNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"background not between"
,
value1
,
value2
,
"background"
);
return
(
Criteria
)
this
;
}
public
Criteria
andWeixinOpenidIsNull
()
{
addCriterion
(
"weixin_openid is null"
);
return
(
Criteria
)
this
;
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/UserMapper.xml
View file @
cad17097
...
...
@@ -13,6 +13,8 @@
<result
column=
"nickname"
jdbcType=
"VARCHAR"
property=
"nickname"
/>
<result
column=
"mobile"
jdbcType=
"VARCHAR"
property=
"mobile"
/>
<result
column=
"avatar"
jdbcType=
"VARCHAR"
property=
"avatar"
/>
<result
column=
"profile"
jdbcType=
"VARCHAR"
property=
"profile"
/>
<result
column=
"background"
jdbcType=
"VARCHAR"
property=
"background"
/>
<result
column=
"weixin_openid"
jdbcType=
"VARCHAR"
property=
"weixinOpenid"
/>
<result
column=
"wechat_id"
jdbcType=
"VARCHAR"
property=
"wechatId"
/>
<result
column=
"status"
jdbcType=
"TINYINT"
property=
"status"
/>
...
...
@@ -81,8 +83,8 @@
</sql>
<sql
id=
"Base_Column_List"
>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar,
weixin_openid, wechat_id, `status`, add_time, update_time
,
deleted, share_user_id
nickname, mobile, avatar,
profile, background, weixin_openid, wechat_id, `status`
,
add_time, update_time,
deleted, share_user_id
</sql>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.UserExample"
resultMap=
"BaseResultMap"
>
select
...
...
@@ -118,8 +120,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar,
weixin_openid, wechat_id, `status`, add_time, update_time
,
deleted, share_user_id
nickname, mobile, avatar,
profile, background, weixin_openid, wechat_id, `status`
,
add_time, update_time,
deleted, share_user_id
</otherwise>
</choose>
from user
...
...
@@ -171,8 +173,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar,
weixin_openid, wechat_id, `status`, add_time, update_time
,
deleted, share_user_id
nickname, mobile, avatar,
profile, background, weixin_openid, wechat_id, `status`
,
add_time, update_time,
deleted, share_user_id
</otherwise>
</choose>
from user
...
...
@@ -195,15 +197,17 @@
insert into user (username, `password`, gender,
birthday, last_login_time, last_login_ip,
user_level, nickname, mobile,
avatar, weixin_openid, wechat_id,
`status`, add_time, update_time,
deleted, share_user_id)
avatar, profile, background,
weixin_openid, wechat_id, `status`,
add_time, update_time, deleted,
share_user_id)
values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
#{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR},
#{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{avatar,jdbcType=VARCHAR}, #{weixinOpenid,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT})
#{avatar,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR}, #{background,jdbcType=VARCHAR},
#{weixinOpenid,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{shareUserId,jdbcType=BIGINT})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.User"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
...
...
@@ -241,6 +245,12 @@
<if
test=
"avatar != null"
>
avatar,
</if>
<if
test=
"profile != null"
>
profile,
</if>
<if
test=
"background != null"
>
background,
</if>
<if
test=
"weixinOpenid != null"
>
weixin_openid,
</if>
...
...
@@ -294,6 +304,12 @@
<if
test=
"avatar != null"
>
#{avatar,jdbcType=VARCHAR},
</if>
<if
test=
"profile != null"
>
#{profile,jdbcType=VARCHAR},
</if>
<if
test=
"background != null"
>
#{background,jdbcType=VARCHAR},
</if>
<if
test=
"weixinOpenid != null"
>
#{weixinOpenid,jdbcType=VARCHAR},
</if>
...
...
@@ -359,6 +375,12 @@
<if
test=
"record.avatar != null"
>
avatar = #{record.avatar,jdbcType=VARCHAR},
</if>
<if
test=
"record.profile != null"
>
profile = #{record.profile,jdbcType=VARCHAR},
</if>
<if
test=
"record.background != null"
>
background = #{record.background,jdbcType=VARCHAR},
</if>
<if
test=
"record.weixinOpenid != null"
>
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
</if>
...
...
@@ -398,6 +420,8 @@
nickname = #{record.nickname,jdbcType=VARCHAR},
mobile = #{record.mobile,jdbcType=VARCHAR},
avatar = #{record.avatar,jdbcType=VARCHAR},
profile = #{record.profile,jdbcType=VARCHAR},
background = #{record.background,jdbcType=VARCHAR},
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
wechat_id = #{record.wechatId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=TINYINT},
...
...
@@ -442,6 +466,12 @@
<if
test=
"avatar != null"
>
avatar = #{avatar,jdbcType=VARCHAR},
</if>
<if
test=
"profile != null"
>
profile = #{profile,jdbcType=VARCHAR},
</if>
<if
test=
"background != null"
>
background = #{background,jdbcType=VARCHAR},
</if>
<if
test=
"weixinOpenid != null"
>
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
</if>
...
...
@@ -478,6 +508,8 @@
nickname = #{nickname,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
avatar = #{avatar,jdbcType=VARCHAR},
profile = #{profile,jdbcType=VARCHAR},
background = #{background,jdbcType=VARCHAR},
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
wechat_id = #{wechatId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=TINYINT},
...
...
@@ -521,8 +553,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar,
weixin_openid, wechat_id, `status`, add_time, update_time
,
deleted, share_user_id
nickname, mobile, avatar,
profile, background, weixin_openid, wechat_id, `status`
,
add_time, update_time,
deleted, share_user_id
</otherwise>
</choose>
from user
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/constant/CacheCodeEnum.java
0 → 100644
View file @
cad17097
package
com.wwdz.ch.wx.constant
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
CacheCodeEnum
{
public
enum
SmsTypeEnum
{
LOGIN
(
"LOGIN:"
,
"登录"
),
UPDATE
(
"UPDATE:"
,
"修改手机号"
),
;
private
String
code
;
private
String
name
;
SmsTypeEnum
(
String
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
public
static
String
getDesByCode
(
String
code
)
{
for
(
SmsTypeEnum
afterSaleStateEnum
:
SmsTypeEnum
.
values
())
{
if
(
code
.
equals
(
afterSaleStateEnum
.
getCode
()))
{
return
afterSaleStateEnum
.
getName
();
}
}
return
null
;
}
/**
* 返回map
* @return
*/
public
static
Map
<
String
,
String
>
getSmsTypeEnumMap
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
for
(
SmsTypeEnum
afterSaleStateEnum
:
SmsTypeEnum
.
values
())
{
map
.
put
(
afterSaleStateEnum
.
getCode
(),
afterSaleStateEnum
.
getName
());
}
return
map
;
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/request/UserRequestDto.java
View file @
cad17097
...
...
@@ -15,4 +15,7 @@ public class UserRequestDto implements Entity {
private
String
wechatId
;
private
String
beforeMobile
;
private
String
afterMobile
;
private
String
profile
;
private
String
background
;
private
String
smsType
;
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
cad17097
package
com.wwdz.ch.wx.impl
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.ItemManager
;
import
com.wwdz.ch.db.dao.UserItemsRelationDao
;
import
com.wwdz.ch.db.domain.Favorites
;
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.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.ItemManager
;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.request.FavoritesRequestDto
;
import
com.wwdz.ch.wx.entity.request.ItemRequestDto
;
import
com.wwdz.ch.wx.entity.vo.ItemResponseVo
;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
...
...
@@ -150,6 +153,40 @@ public class FavoritesServiceImpl implements FavoritesService {
}
}
@Override
public
Result
itemList
(
FavoritesRequestDto
dto
)
{
try
{
PageInfo
<
ItemResponseVo
>
page
=
new
PageInfo
<>();
page
.
setPageNum
(
dto
.
getPage
());
page
.
setPageSize
(
dto
.
getSize
());
page
.
setTotal
(
0L
);
page
.
setList
(
new
ArrayList
<>());
PageInfo
<
FavoritesItemsRelation
>
relationPage
=
favoritesItemsRelationDao
.
pageByFavoritesId
(
dto
.
getId
(),
dto
.
getPage
(),
dto
.
getSize
());
if
(
relationPage
.
getList
().
isEmpty
())
{
return
Result
.
success
(
page
);
}
List
<
ItemResponseVo
>
list
=
new
ArrayList
<>();
for
(
FavoritesItemsRelation
relation
:
relationPage
.
getList
())
{
ItemResponseVo
vo
=
new
ItemResponseVo
();
Item
item
=
itemManager
.
findDetails
(
relation
.
getItemId
());
vo
.
setId
(
relation
.
getItemId
());
vo
.
setName
(
item
.
getName
());
vo
.
setImages
(
item
.
getImages
());
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
relation
.
getItemId
())
?
1
:
0
);
vo
.
setCollectCount
(
favoritesItemsRelationDao
.
countByItemId
(
relation
.
getItemId
()));
list
.
add
(
vo
);
}
page
.
setTotal
(
favoritesItemsRelationDao
.
countByFavoritesId
(
dto
.
getId
()));
page
.
setList
(
list
);
return
Result
.
success
(
page
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查看收藏册的藏品列表失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(
"查看收藏册的藏品列表失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
delete
(
FavoritesRequestDto
dto
)
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
View file @
cad17097
...
...
@@ -73,7 +73,7 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo
.
setDetail
(
item
.
getDetail
());
itemResponseVo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
/
100
));
itemResponseVo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
footprint
.
getItemId
())
?
1
:
0
);
itemResponseVo
.
setCollectCount
(
favoritesItemsRelationDao
.
count
(
footprint
.
getItemId
()));
itemResponseVo
.
setCollectCount
(
favoritesItemsRelationDao
.
count
ByItemId
(
footprint
.
getItemId
()));
if
(
footprint
.
getAddTime
().
compareTo
(
today
)
>=
0
)
{
todayList
.
add
(
itemResponseVo
);
}
...
...
@@ -160,7 +160,7 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo
.
setDetail
(
item
.
getDetail
());
itemResponseVo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
/
100
));
itemResponseVo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
footprint
.
getItemId
())
?
1
:
0
);
itemResponseVo
.
setCollectCount
(
favoritesItemsRelationDao
.
count
(
footprint
.
getItemId
()));
itemResponseVo
.
setCollectCount
(
favoritesItemsRelationDao
.
count
ByItemId
(
footprint
.
getItemId
()));
if
(
footprint
.
getAddTime
().
compareTo
(
today
)
>=
0
)
{
todayList
.
add
(
itemResponseVo
);
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
cad17097
...
...
@@ -65,7 +65,7 @@ public class ItemServiceImpl implements ItemService {
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
vo
.
setCollectCount
(
favoritesItemsRelationDao
.
count
(
item
.
getId
()));
vo
.
setCollectCount
(
favoritesItemsRelationDao
.
count
ByItemId
(
item
.
getId
()));
resultList
.
add
(
vo
);
}
result
.
setList
(
resultList
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
View file @
cad17097
...
...
@@ -12,6 +12,7 @@ import com.wwdz.ch.core.util.CharUtil;
import
com.wwdz.ch.core.util.RegexUtil
;
import
com.wwdz.ch.db.dao.UserDao
;
import
com.wwdz.ch.db.domain.User
;
import
com.wwdz.ch.wx.constant.CacheCodeEnum
;
import
com.wwdz.ch.wx.dao.UserInfo
;
import
com.wwdz.ch.wx.dao.UserToken
;
import
com.wwdz.ch.wx.dao.WxLoginInfo
;
...
...
@@ -84,7 +85,6 @@ public class UserServiceImpl implements UserService {
}
User
user
=
userDao
.
queryByOid
(
openId
);
if
(
user
==
null
)
{
user
=
new
User
();
user
.
setUsername
(
openId
);
...
...
@@ -129,16 +129,14 @@ public class UserServiceImpl implements UserService {
if
(!
StringUtils
.
isEmpty
(
user
.
getMobile
()))
{
// 手机号存在则设置
userInfo
.
setPhone
(
user
.
getMobile
());
}
try
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
registerDate
=
simpleDateFormat
.
format
(
user
.
getAddTime
()
!=
null
?
user
.
getAddTime
()
:
new
Date
());
userInfo
.
setRegisterDate
(
registerDate
);
userInfo
.
setStatus
(
user
.
getStatus
());
userInfo
.
setUserLevel
(
user
.
getUserLevel
());
// 用户层级
userInfo
.
setUserLevelDesc
(
UserTypeEnum
.
getInstance
(
user
.
getUserLevel
()).
getDesc
());
// 用户层级描述
}
catch
(
Exception
e
)
{
logger
.
error
(
"微信登录:设置用户指定信息出错:"
+
e
.
getMessage
(),
e
);
}
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
registerDate
=
simpleDateFormat
.
format
(
Objects
.
isNull
(
user
.
getAddTime
())
?
new
Date
()
:
user
.
getAddTime
());
userInfo
.
setRegisterDate
(
registerDate
);
userInfo
.
setStatus
(
user
.
getStatus
());
// 用户层级
userInfo
.
setUserLevel
(
user
.
getUserLevel
());
// 用户层级描述
userInfo
.
setUserLevelDesc
(
UserTypeEnum
.
getInstance
(
user
.
getUserLevel
()).
getDesc
());
result
.
put
(
"userInfo"
,
userInfo
);
logger
.
info
(
"【请求结束】微信登录,响应结果:{}"
,
JSONObject
.
toJSONString
(
result
));
...
...
@@ -171,7 +169,7 @@ public class UserServiceImpl implements UserService {
}
}
boolean
successful
=
CaptchaCodeManager
.
addToCache
(
dto
.
getMobile
(),
code
,
1
);
boolean
successful
=
CaptchaCodeManager
.
addToCache
(
dto
.
get
SmsType
()
+
dto
.
get
Mobile
(),
code
,
1
);
if
(!
successful
)
{
logger
.
error
(
"请求验证码出错:{}"
,
WxResponseCode
.
AUTH_CAPTCHA_FREQUENCY
.
desc
());
return
Result
.
failed
(
WxResponseCode
.
AUTH_CAPTCHA_FREQUENCY
.
desc
());
...
...
@@ -189,10 +187,12 @@ public class UserServiceImpl implements UserService {
@Override
public
Result
loginByMobile
(
UserRequestDto
dto
,
HttpServletRequest
request
)
{
try
{
String
mobileCode
=
CaptchaCodeManager
.
getCachedCaptcha
(
dto
.
getMobile
());
String
mobileCode
=
CaptchaCodeManager
.
getCachedCaptcha
(
CacheCodeEnum
.
SmsTypeEnum
.
LOGIN
.
getCode
()
+
dto
.
getMobile
());
if
(!
StringUtils
.
equals
(
dto
.
getSmsCode
(),
mobileCode
))
{
return
Result
.
failed
(
"验证码不正确"
);
}
// 获取微信授权信息
String
openId
=
""
;
String
sessionKey
=
""
;
try
{
...
...
@@ -207,26 +207,39 @@ public class UserServiceImpl implements UserService {
if
(
StringUtils
.
isBlank
(
openId
))
{
return
Result
.
failed
(
"手机号登录失败,获取openid失败"
);
}
// 判断手机号用户是否存在
User
user
=
userDao
.
queryByMobile
(
dto
.
getMobile
());
if
(
Objects
.
isNull
(
user
))
{
user
=
new
User
();
user
.
setUsername
(
openId
);
user
.
setPassword
(
openId
);
user
.
setWeixinOpenid
(
openId
);
user
.
setMobile
(
dto
.
getMobile
());
user
.
setAvatar
(
dto
.
getAvatarUrl
());
user
.
setNickname
(
"微信用户"
+
StringUtil
.
generateRandomString
(
10
));
user
.
setGender
((
byte
)
0
);
user
.
setUserLevel
((
byte
)
0
);
user
.
setStatus
((
byte
)
0
);
user
.
setLastLoginTime
(
new
Date
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
user
.
setShareUserId
(
dto
.
getShareUserId
());
userDao
.
insert
(
user
);
User
openUser
=
userDao
.
queryByOid
(
openId
);
if
(
Objects
.
isNull
(
openUser
))
{
user
=
new
User
();
user
.
setUsername
(
openId
);
user
.
setPassword
(
openId
);
user
.
setWeixinOpenid
(
openId
);
user
.
setMobile
(
dto
.
getMobile
());
user
.
setAvatar
(
dto
.
getAvatarUrl
());
user
.
setNickname
(
"微信用户"
+
StringUtil
.
generateRandomString
(
10
));
user
.
setGender
((
byte
)
0
);
user
.
setUserLevel
((
byte
)
0
);
user
.
setStatus
((
byte
)
0
);
user
.
setLastLoginTime
(
new
Date
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
user
.
setShareUserId
(
dto
.
getShareUserId
());
userDao
.
insert
(
user
);
FavoritesRequestDto
favoritesRequestDto
=
new
FavoritesRequestDto
();
favoritesRequestDto
.
setUserId
(
user
.
getId
());
favoritesService
.
addDefault
(
favoritesRequestDto
);
FavoritesRequestDto
favoritesRequestDto
=
new
FavoritesRequestDto
();
favoritesRequestDto
.
setUserId
(
user
.
getId
());
favoritesService
.
addDefault
(
favoritesRequestDto
);
}
else
{
user
=
openUser
;
user
.
setMobile
(
dto
.
getMobile
());
user
.
setLastLoginTime
(
new
Date
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
if
(
userDao
.
updateById
(
user
)
==
0
)
{
return
Result
.
failed
(
505
,
"更新用户数据失败"
);
}
}
}
else
{
user
.
setLastLoginTime
(
new
Date
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
...
...
@@ -255,20 +268,18 @@ public class UserServiceImpl implements UserService {
userInfo
.
setGender
(
user
.
getGender
());
userInfo
.
setNickName
(
user
.
getNickname
());
userInfo
.
setWechatId
(
user
.
getWechatId
());
try
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
registerDate
=
simpleDateFormat
.
format
(
user
.
getAddTime
()
!=
null
?
user
.
getAddTime
()
:
new
Date
());
userInfo
.
setRegisterDate
(
registerDate
);
userInfo
.
setStatus
(
user
.
getStatus
());
userInfo
.
setUserLevel
(
user
.
getUserLevel
());
// 用户层级
userInfo
.
setUserLevelDesc
(
UserTypeEnum
.
getInstance
(
user
.
getUserLevel
()).
getDesc
());
// 用户层级描述
}
catch
(
Exception
e
)
{
logger
.
error
(
"手机号登录:设置用户指定信息出错:"
+
e
.
getMessage
(),
e
);
}
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
registerDate
=
simpleDateFormat
.
format
(
Objects
.
isNull
(
user
.
getAddTime
())
?
new
Date
()
:
user
.
getAddTime
());
userInfo
.
setRegisterDate
(
registerDate
);
userInfo
.
setStatus
(
user
.
getStatus
());
// 用户层级
userInfo
.
setUserLevel
(
user
.
getUserLevel
());
// 用户层级描述
userInfo
.
setUserLevelDesc
(
UserTypeEnum
.
getInstance
(
user
.
getUserLevel
()).
getDesc
());
result
.
put
(
"userInfo"
,
userInfo
);
logger
.
info
(
"【请求结束】手机号登录,响应结果:{}"
,
JSONObject
.
toJSONString
(
result
));
return
Result
.
success
();
return
Result
.
success
(
result
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"手机号登录失败"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
...
...
@@ -276,6 +287,42 @@ public class UserServiceImpl implements UserService {
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
updateProfile
(
UserRequestDto
dto
)
{
try
{
User
user
=
userDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
user
.
setProfile
(
dto
.
getProfile
());
userDao
.
updateById
(
user
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改个性签名失败"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"修改个性签名失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
updateBackground
(
UserRequestDto
dto
)
{
try
{
User
user
=
userDao
.
queryById
(
dto
.
getUserId
());
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
user
.
setBackground
(
dto
.
getBackground
());
userDao
.
updateById
(
user
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"用户修改背景失败"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"修改背景失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
updateNickname
(
UserRequestDto
dto
)
{
...
...
@@ -284,6 +331,9 @@ public class UserServiceImpl implements UserService {
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
if
(
userDao
.
isExistedByNickname
(
dto
.
getUserId
(),
dto
.
getNickname
()))
{
return
Result
.
failed
(
"昵称已存在"
);
}
user
.
setNickname
(
dto
.
getNickname
());
userDao
.
updateById
(
user
);
return
Result
.
success
();
...
...
@@ -320,6 +370,9 @@ public class UserServiceImpl implements UserService {
if
(
Objects
.
isNull
(
user
))
{
return
Result
.
failed
(
"数据异常,用户不存在"
);
}
if
(
userDao
.
isExistedByWechatId
(
dto
.
getUserId
(),
dto
.
getWechatId
()))
{
return
Result
.
failed
(
"无法绑定,该微信号已被绑定"
);
}
user
.
setWechatId
(
dto
.
getWechatId
());
userDao
.
updateById
(
user
);
return
Result
.
success
();
...
...
@@ -341,8 +394,8 @@ public class UserServiceImpl implements UserService {
if
(!
StringUtils
.
equals
(
user
.
getMobile
(),
dto
.
getBeforeMobile
()))
{
return
Result
.
failed
(
"原手机号码不正确"
);
}
String
mobileCode
=
CaptchaCodeManager
.
getCachedCaptcha
(
dto
.
getAfterMobile
());
if
(!
StringUtils
.
equals
(
dto
.
getCode
(),
mobileCode
))
{
String
mobileCode
=
CaptchaCodeManager
.
getCachedCaptcha
(
CacheCodeEnum
.
SmsTypeEnum
.
UPDATE
.
getCode
()
+
dto
.
getAfterMobile
());
if
(!
StringUtils
.
equals
(
dto
.
get
Sms
Code
(),
mobileCode
))
{
return
Result
.
failed
(
"验证码不正确"
);
}
if
(
userDao
.
isExistedByMobile
(
dto
.
getBeforeMobile
(),
dto
.
getAfterMobile
()))
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
View file @
cad17097
...
...
@@ -16,6 +16,8 @@ public interface FavoritesService {
Result
info
(
FavoritesRequestDto
dto
);
Result
itemList
(
FavoritesRequestDto
dto
);
Result
delete
(
FavoritesRequestDto
dto
);
Result
batchDelete
(
FavoritesRequestDto
dto
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/UserService.java
View file @
cad17097
...
...
@@ -13,6 +13,10 @@ public interface UserService {
Result
loginByMobile
(
UserRequestDto
dto
,
HttpServletRequest
request
);
Result
updateProfile
(
UserRequestDto
dto
);
Result
updateBackground
(
UserRequestDto
dto
);
Result
updateNickname
(
UserRequestDto
dto
);
Result
updateAvatar
(
UserRequestDto
dto
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
View file @
cad17097
...
...
@@ -54,6 +54,12 @@ public class WxFavoritesController {
return
favoritesService
.
info
(
dto
);
}
@ApiOperation
(
value
=
"详情"
)
@PostMapping
(
"/itemList"
)
public
Result
itemList
(
@RequestBody
@Validated
(
Select
.
class
)
FavoritesRequestDto
dto
)
{
return
favoritesService
.
itemList
(
dto
);
}
@ApiOperation
(
value
=
"单个删除"
)
@PostMapping
(
"/delete"
)
public
Result
delete
(
@RequestBody
@Validated
(
Delete
.
class
)
FavoritesRequestDto
dto
)
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxUserController.java
View file @
cad17097
...
...
@@ -7,9 +7,11 @@ import com.wwdz.ch.core.util.ResponseUtil;
import
com.wwdz.ch.db.domain.UserAccountObsolete
;
import
com.wwdz.ch.db.service.DtsAccountService
;
import
com.wwdz.ch.wx.annotation.LoginUser
;
import
com.wwdz.ch.wx.constant.CacheCodeEnum
;
import
com.wwdz.ch.wx.dao.WxLoginInfo
;
import
com.wwdz.ch.wx.entity.request.UserRequestDto
;
import
com.wwdz.ch.wx.service.UserService
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* 用户服务
...
...
@@ -86,25 +89,125 @@ public class WxUserController {
return
ResponseUtil
.
ok
(
data
);
}
@ApiOperation
(
value
=
"微信登录"
)
@PostMapping
(
"/loginByWx"
)
public
Result
loginByWx
(
@RequestBody
WxLoginInfo
wxLoginInfo
,
HttpServletRequest
request
)
{
logger
.
info
(
"【请求开始】微信登录,请求参数,wxLoginInfo:{}"
,
JSONObject
.
toJSONString
(
wxLoginInfo
));
return
userService
.
loginByWx
(
wxLoginInfo
,
request
);
}
@PostMapping
(
"/regCaptcha"
)
@ApiOperation
(
value
=
"登录手机验证码"
)
@PostMapping
(
"/loginRegCaptcha"
)
public
Object
registerCaptcha
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】请求验证码,请求参数,mobile:{}"
,
dto
.
getMobile
());
if
(
StringUtils
.
isBlank
(
dto
.
getMobile
()))
{
return
Result
.
failed
(
"手机号不能为空"
);
}
dto
.
setSmsType
(
CacheCodeEnum
.
SmsTypeEnum
.
LOGIN
.
getCode
());
return
userService
.
regCaptcha
(
dto
);
}
@ApiOperation
(
value
=
"手机验证码登录"
)
@PostMapping
(
"/loginByMobile"
)
public
Result
loginByMobile
(
@RequestBody
UserRequestDto
dto
,
HttpServletRequest
request
)
{
logger
.
info
(
"【请求开始】手机号登录,请求参数,
wxLoginInf
o:{}"
,
JSONObject
.
toJSONString
(
dto
));
logger
.
info
(
"【请求开始】手机号登录,请求参数,
userRequestDt
o:{}"
,
JSONObject
.
toJSONString
(
dto
));
return
userService
.
loginByMobile
(
dto
,
request
);
}
@ApiOperation
(
value
=
"修改个性签名"
)
@PostMapping
(
"/updateProfile"
)
public
Result
updateProfile
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改个性签名,请求参数,userRequestDto:{}"
,
JSONObject
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getProfile
()))
{
return
Result
.
failed
(
"个性签名不能为空"
);
}
return
userService
.
updateProfile
(
dto
);
}
@ApiOperation
(
value
=
"修改背景"
)
@PostMapping
(
"/updateBackground"
)
public
Result
updateBackground
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改背景,请求参数,userRequestDto:{}"
,
JSONObject
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getBackground
()))
{
return
Result
.
failed
(
"背景图片路径不能为空"
);
}
return
userService
.
updateBackground
(
dto
);
}
@ApiOperation
(
value
=
"修改昵称"
)
@PostMapping
(
"/updateNickname"
)
public
Result
updateNickname
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改昵称,请求参数,userRequestDto:{}"
,
JSONObject
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getNickname
()))
{
return
Result
.
failed
(
"昵称不能为空"
);
}
return
userService
.
updateNickname
(
dto
);
}
@ApiOperation
(
value
=
"修改头像"
)
@PostMapping
(
"/updateAvatar"
)
public
Result
updateAvatar
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改头像,请求参数,userRequestDto:{}"
,
JSONObject
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getAvatarUrl
()))
{
return
Result
.
failed
(
"头像图片路径不能为空"
);
}
return
userService
.
updateAvatar
(
dto
);
}
@ApiOperation
(
value
=
"绑定微信号"
)
@PostMapping
(
"/bindWechatId"
)
public
Result
bindWechatId
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】绑定微信号,请求参数,userRequestDto:{}"
,
JSONObject
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getWechatId
()))
{
return
Result
.
failed
(
"微信号不能为空"
);
}
return
userService
.
bindWechatId
(
dto
);
}
@ApiOperation
(
value
=
"修改手机验证码"
)
@PostMapping
(
"/updateRegCaptcha"
)
public
Object
updateRegCaptcha
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】请求修改手机验证码,请求参数,mobile:{}"
,
dto
.
getMobile
());
if
(
StringUtils
.
isBlank
(
dto
.
getMobile
()))
{
return
Result
.
failed
(
"手机号不能为空"
);
}
dto
.
setSmsType
(
CacheCodeEnum
.
SmsTypeEnum
.
UPDATE
.
getCode
());
return
userService
.
regCaptcha
(
dto
);
}
@ApiOperation
(
value
=
"修改手机号"
)
@PostMapping
(
"/updateMobile"
)
public
Result
updateMobile
(
@RequestBody
UserRequestDto
dto
)
{
logger
.
info
(
"【请求开始】修改手机号,请求参数,userRequestDto:{}"
,
JSONObject
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
()))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getBeforeMobile
()))
{
return
Result
.
failed
(
"原手机号不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getAfterMobile
()))
{
return
Result
.
failed
(
"新手机号不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getSmsCode
()))
{
return
Result
.
failed
(
"验证码不能为空"
);
}
return
userService
.
updateMobile
(
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