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
3cd30d72
Commit
3cd30d72
authored
Sep 05, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增 邀请码和我的
parent
fcfdec3b
Changes
24
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
1698 additions
and
190 deletions
+1698
-190
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
...in/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
+32
-1
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemDao.java
+8
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/SwitchDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/SwitchDao.java
+7
-0
ch-dao/src/main/java/com/wwdz/ch/db/domain/Switch.java
ch-dao/src/main/java/com/wwdz/ch/db/domain/Switch.java
+236
-0
ch-dao/src/main/java/com/wwdz/ch/db/domain/SwitchExample.java
...ao/src/main/java/com/wwdz/ch/db/domain/SwitchExample.java
+566
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
...va/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
+43
-3
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
+13
-1
ch-dao/src/main/java/com/wwdz/ch/db/impl/SwitchDaoImpl.java
ch-dao/src/main/java/com/wwdz/ch/db/impl/SwitchDaoImpl.java
+21
-0
ch-dao/src/main/java/com/wwdz/ch/db/mapper/SwitchMapper.java
ch-dao/src/main/java/com/wwdz/ch/db/mapper/SwitchMapper.java
+69
-0
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/SwitchMapper.xml
...src/main/resources/com/wwdz/ch/db/mapper/SwitchMapper.xml
+259
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
.../main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
+4
-4
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+10
-69
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
+15
-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
+217
-66
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/SwitchServiceImpl.java
.../src/main/java/com/wwdz/ch/wx/impl/SwitchServiceImpl.java
+18
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
+0
-8
ch-wx-api/src/main/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
...ain/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
+74
-10
ch-wx-api/src/main/java/com/wwdz/ch/wx/manager/AlipayLoginManager.java
.../main/java/com/wwdz/ch/wx/manager/AlipayLoginManager.java
+1
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
...rc/main/java/com/wwdz/ch/wx/service/FavoritesService.java
+0
-8
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ItemService.java
...api/src/main/java/com/wwdz/ch/wx/service/ItemService.java
+19
-3
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/SwitchService.java
...i/src/main/java/com/wwdz/ch/wx/service/SwitchService.java
+12
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
...c/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
+1
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxItemController.java
...pi/src/main/java/com/wwdz/ch/wx/web/WxItemController.java
+52
-13
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxUserController.java
...pi/src/main/java/com/wwdz/ch/wx/web/WxUserController.java
+21
-1
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
View file @
3cd30d72
...
...
@@ -79,6 +79,17 @@ public interface FavoritesItemsRelationDao {
*/
PageInfo
<
FavoritesItemsRelation
>
pageByFavoritesId
(
Long
favoritesId
,
int
page
,
int
size
);
/**
* 通过用户id分页查询
*
* @param userId
* @param page
* @param size
* @param type
* @return
*/
PageInfo
<
FavoritesItemsRelation
>
pageByUserId
(
Long
userId
,
Integer
type
,
int
page
,
int
size
);
/**
* 通过藏品id统计记录数
*
...
...
@@ -94,7 +105,7 @@ public interface FavoritesItemsRelationDao {
* @param itemId
* @return
*/
boolean
isCollected
(
Long
userId
,
Long
itemId
);
boolean
isCollected
(
Long
userId
,
Long
itemId
,
List
<
Long
>
itemIds
);
/**
* 通过收藏册id统计记录数
...
...
@@ -118,4 +129,24 @@ public interface FavoritesItemsRelationDao {
* @return
*/
List
<
FavoritesItemsDto
>
queryItemImages
(
Long
favoritesId
);
/**
* 更新收藏册id
*
* @param userId
* @param favoritesId
* @param itemIds
* @return
*/
int
updateFavoritesId
(
Long
userId
,
Long
favoritesId
,
List
<
Long
>
itemIds
);
/**
* 更新收藏册id
*
* @param userId
* @param favoritesId
* @param itemIds
* @return
*/
int
deleteFavoritesId
(
Long
userId
,
Long
favoritesId
,
List
<
Long
>
itemIds
);
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/ItemDao.java
View file @
3cd30d72
...
...
@@ -21,6 +21,14 @@ public interface ItemDao {
*/
List
<
Item
>
findListNotDeleted
(
CoinRequestDto
coinRequestDto
);
/**
* 获取未删除的分页
*
* @param coinRequestDto
* @return
*/
PageInfo
<
Item
>
findPageNotDeleted
(
CoinRequestDto
coinRequestDto
);
List
<
Item
>
findListByPage
(
CoinRequestDto
coinRequestDto
);
PageInfo
<
Item
>
findByPage
(
CoinRequestDto
coinRequestDto
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dao/SwitchDao.java
0 → 100644
View file @
3cd30d72
package
com.wwdz.ch.db.dao
;
import
com.wwdz.ch.db.domain.Switch
;
public
interface
SwitchDao
{
Switch
find
();
}
ch-dao/src/main/java/com/wwdz/ch/db/domain/Switch.java
0 → 100644
View file @
3cd30d72
package
com.wwdz.ch.db.domain
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
lombok.Data
;
/**
* @author shiyu
* @date 2023/09/04
*/
@Data
public
class
Switch
implements
Serializable
{
private
Long
id
;
/**
* 状态(0:关闭,2:打开)
*/
private
Integer
state
;
private
static
final
long
serialVersionUID
=
1L
;
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", state="
).
append
(
state
);
sb
.
append
(
", serialVersionUID="
).
append
(
serialVersionUID
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
@Override
public
boolean
equals
(
Object
that
)
{
if
(
this
==
that
)
{
return
true
;
}
if
(
that
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
that
.
getClass
())
{
return
false
;
}
Switch
other
=
(
Switch
)
that
;
return
(
this
.
getId
()
==
null
?
other
.
getId
()
==
null
:
this
.
getId
().
equals
(
other
.
getId
()))
&&
(
this
.
getState
()
==
null
?
other
.
getState
()
==
null
:
this
.
getState
().
equals
(
other
.
getState
()));
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
getId
()
==
null
)
?
0
:
getId
().
hashCode
());
result
=
prime
*
result
+
((
getState
()
==
null
)
?
0
:
getState
().
hashCode
());
return
result
;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
enum
Column
{
id
(
"id"
,
"id"
,
"BIGINT"
,
false
),
state
(
"state"
,
"state"
,
"INTEGER"
,
true
);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
static
final
String
BEGINNING_DELIMITER
=
"`"
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
static
final
String
ENDING_DELIMITER
=
"`"
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
final
String
column
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
final
boolean
isColumnNameDelimited
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
final
String
javaProperty
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
final
String
jdbcType
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
value
()
{
return
this
.
column
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
getValue
()
{
return
this
.
column
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
getJavaProperty
()
{
return
this
.
javaProperty
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
getJdbcType
()
{
return
this
.
jdbcType
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column
(
String
column
,
String
javaProperty
,
String
jdbcType
,
boolean
isColumnNameDelimited
)
{
this
.
column
=
column
;
this
.
javaProperty
=
javaProperty
;
this
.
jdbcType
=
jdbcType
;
this
.
isColumnNameDelimited
=
isColumnNameDelimited
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
desc
()
{
return
this
.
getEscapedColumnName
()
+
" DESC"
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
asc
()
{
return
this
.
getEscapedColumnName
()
+
" ASC"
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
static
Column
[]
excludes
(
Column
...
excludes
)
{
ArrayList
<
Column
>
columns
=
new
ArrayList
<>(
Arrays
.
asList
(
Column
.
values
()));
if
(
excludes
!=
null
&&
excludes
.
length
>
0
)
{
columns
.
removeAll
(
new
ArrayList
<>(
Arrays
.
asList
(
excludes
)));
}
return
columns
.
toArray
(
new
Column
[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
getEscapedColumnName
()
{
if
(
this
.
isColumnNameDelimited
)
{
return
new
StringBuilder
().
append
(
BEGINNING_DELIMITER
).
append
(
this
.
column
).
append
(
ENDING_DELIMITER
).
toString
();
}
else
{
return
this
.
column
;
}
}
}
}
\ No newline at end of file
ch-dao/src/main/java/com/wwdz/ch/db/domain/SwitchExample.java
0 → 100644
View file @
3cd30d72
This diff is collapsed.
Click to expand it.
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
View file @
3cd30d72
...
...
@@ -12,6 +12,7 @@ import com.xxdxxs.db.component.JdbcHelper;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -84,6 +85,20 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
return
new
PageInfo
<>(
list
);
}
@Override
public
PageInfo
<
FavoritesItemsRelation
>
pageByUserId
(
Long
userId
,
Integer
type
,
int
page
,
int
size
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
if
(
type
==
1
)
{
criteria
.
andFavoritesIdEqualTo
(
0L
);
}
example
.
orderBy
(
"add_time desc"
);
PageHelper
.
startPage
(
page
,
size
);
List
<
FavoritesItemsRelation
>
list
=
favoritesItemsRelationMapper
.
selectByExample
(
example
);
return
new
PageInfo
<>(
list
);
}
@Override
public
long
countByItemId
(
Long
itemId
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
...
...
@@ -93,11 +108,11 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
}
@Override
public
boolean
isCollected
(
Long
userId
,
Long
itemId
)
{
public
boolean
isCollected
(
Long
userId
,
Long
itemId
,
List
<
Long
>
itemIds
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andItemIdEqualTo
(
itemId
);
JdbcHelper
.
ifPresent
(
itemId
,
criteria:
:
andItemIdEqualTo
);
JdbcHelper
.
ifPresent
(
itemIds
,
criteria:
:
andItemIdIn
);
return
favoritesItemsRelationMapper
.
countByExample
(
example
)
>
0
;
}
...
...
@@ -120,4 +135,29 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
favoritesRequestDto
.
setId
(
favoritesId
);
return
favoritesItemsRelationMapper
.
selectItemImages
(
favoritesRequestDto
);
}
@Override
public
int
updateFavoritesId
(
Long
userId
,
Long
favoritesId
,
List
<
Long
>
itemIds
)
{
FavoritesItemsRelationExample
favoritesItemsRelationExample
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
favoritesItemsRelationExample
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andItemIdIn
(
itemIds
);
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setFavoritesId
(
favoritesId
);
favoritesItemsRelation
.
setUpdateTime
(
new
Date
());
return
favoritesItemsRelationMapper
.
updateByExampleSelective
(
favoritesItemsRelation
,
favoritesItemsRelationExample
);
}
@Override
public
int
deleteFavoritesId
(
Long
userId
,
Long
favoritesId
,
List
<
Long
>
itemIds
)
{
FavoritesItemsRelationExample
favoritesItemsRelationExample
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
favoritesItemsRelationExample
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andItemIdIn
(
itemIds
);
criteria
.
andFavoritesIdEqualTo
(
favoritesId
);
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setFavoritesId
(
0L
);
favoritesItemsRelation
.
setUpdateTime
(
new
Date
());
return
favoritesItemsRelationMapper
.
updateByExampleSelective
(
favoritesItemsRelation
,
favoritesItemsRelationExample
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/ItemDaoImpl.java
View file @
3cd30d72
...
...
@@ -49,7 +49,7 @@ public class ItemDaoImpl implements ItemDao {
JdbcHelper
.
ifPresent
(
coinRequestDto
.
getName
(),
criteria
::
andNameLike
);
JdbcHelper
.
ifPresent
(
coinRequestDto
.
getCid
(),
criteria
::
andCidEqualTo
);
JdbcHelper
.
ifPresent
(
coinRequestDto
.
getIds
(),
criteria:
:
andIdIn
);
return
itemMapper
.
selectByExample
(
example
);
return
itemMapper
.
selectByExample
WithBLOBs
(
example
);
}
@Override
...
...
@@ -61,6 +61,18 @@ public class ItemDaoImpl implements ItemDao {
return
itemMapper
.
selectByExampleWithBLOBs
(
example
);
}
@Override
public
PageInfo
<
Item
>
findPageNotDeleted
(
CoinRequestDto
coinRequestDto
)
{
ItemExample
example
=
new
ItemExample
();
ItemExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
coinRequestDto
.
getIds
(),
criteria:
:
andIdIn
);
criteria
.
andIsDeletedEqualTo
(
false
);
example
.
orderBy
(
"update_time desc"
);
PageHelper
.
startPage
(
coinRequestDto
.
getPage
(),
coinRequestDto
.
getLimit
());
List
<
Item
>
list
=
itemMapper
.
selectByExampleWithBLOBs
(
example
);
return
new
PageInfo
<>(
list
);
}
@Override
public
List
<
Item
>
findListByPage
(
CoinRequestDto
coinRequestDto
)
{
ItemExample
example
=
new
ItemExample
();
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/SwitchDaoImpl.java
0 → 100644
View file @
3cd30d72
package
com.wwdz.ch.db.impl
;
import
com.wwdz.ch.db.dao.SwitchDao
;
import
com.wwdz.ch.db.domain.Switch
;
import
com.wwdz.ch.db.domain.SwitchExample
;
import
com.wwdz.ch.db.mapper.SwitchMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
@Repository
public
class
SwitchDaoImpl
implements
SwitchDao
{
@Autowired
private
SwitchMapper
switchMapper
;
@Override
public
Switch
find
()
{
SwitchExample
switchExample
=
new
SwitchExample
();
switchExample
.
orderBy
(
"id asc"
);
return
switchMapper
.
selectOneByExample
(
switchExample
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/mapper/SwitchMapper.java
0 → 100644
View file @
3cd30d72
package
com.wwdz.ch.db.mapper
;
import
com.wwdz.ch.db.domain.Switch
;
import
com.wwdz.ch.db.domain.SwitchExample
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
SwitchMapper
{
long
countByExample
(
SwitchExample
example
);
int
deleteByExample
(
SwitchExample
example
);
int
deleteByPrimaryKey
(
Long
id
);
int
insert
(
Switch
record
);
int
insertSelective
(
Switch
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Switch
selectOneByExample
(
SwitchExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Switch
selectOneByExampleSelective
(
@Param
(
"example"
)
SwitchExample
example
,
@Param
(
"selective"
)
Switch
.
Column
...
selective
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List
<
Switch
>
selectByExampleSelective
(
@Param
(
"example"
)
SwitchExample
example
,
@Param
(
"selective"
)
Switch
.
Column
...
selective
);
List
<
Switch
>
selectByExample
(
SwitchExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table switch
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Switch
selectByPrimaryKeySelective
(
@Param
(
"id"
)
Long
id
,
@Param
(
"selective"
)
Switch
.
Column
...
selective
);
Switch
selectByPrimaryKey
(
Long
id
);
int
updateByExampleSelective
(
@Param
(
"record"
)
Switch
record
,
@Param
(
"example"
)
SwitchExample
example
);
int
updateByExample
(
@Param
(
"record"
)
Switch
record
,
@Param
(
"example"
)
SwitchExample
example
);
int
updateByPrimaryKeySelective
(
Switch
record
);
int
updateByPrimaryKey
(
Switch
record
);
}
\ No newline at end of file
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/SwitchMapper.xml
0 → 100644
View file @
3cd30d72
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.wwdz.ch.db.mapper.SwitchMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.wwdz.ch.db.domain.Switch"
>
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"state"
jdbcType=
"INTEGER"
property=
"state"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
<foreach
collection=
"oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Update_By_Example_Where_Clause"
>
<where>
<foreach
collection=
"example.oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Base_Column_List"
>
id, `state`
</sql>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.SwitchExample"
resultMap=
"BaseResultMap"
>
select
<if
test=
"distinct"
>
distinct
</if>
'true' as QUERYID,
<include
refid=
"Base_Column_List"
/>
from switch
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
</if>
</select>
<select
id=
"selectByExampleSelective"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<if
test=
"example.distinct"
>
distinct
</if>
<choose>
<when
test=
"selective != null and selective.length > 0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, `state`
</otherwise>
</choose>
from switch
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
<if
test=
"example.orderByClause != null"
>
order by ${example.orderByClause}
</if>
</select>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from switch
where id = #{id,jdbcType=BIGINT}
</select>
<select
id=
"selectByPrimaryKeySelective"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when
test=
"selective != null and selective.length > 0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, `state`
</otherwise>
</choose>
from switch
where id = #{id,jdbcType=BIGINT}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Long"
>
delete from switch
where id = #{id,jdbcType=BIGINT}
</delete>
<delete
id=
"deleteByExample"
parameterType=
"com.wwdz.ch.db.domain.SwitchExample"
>
delete from switch
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<insert
id=
"insert"
parameterType=
"com.wwdz.ch.db.domain.Switch"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into switch (`state`)
values (#{state,jdbcType=INTEGER})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.Switch"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into switch
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"state != null"
>
`state`,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"state != null"
>
#{state,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"com.wwdz.ch.db.domain.SwitchExample"
resultType=
"java.lang.Long"
>
select count(*) from switch
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<update
id=
"updateByExampleSelective"
parameterType=
"map"
>
update switch
<set>
<if
test=
"record.id != null"
>
id = #{record.id,jdbcType=BIGINT},
</if>
<if
test=
"record.state != null"
>
`state` = #{record.state,jdbcType=INTEGER},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByExample"
parameterType=
"map"
>
update switch
set id = #{record.id,jdbcType=BIGINT},
`state` = #{record.state,jdbcType=INTEGER}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.wwdz.ch.db.domain.Switch"
>
update switch
<set>
<if
test=
"state != null"
>
`state` = #{state,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.wwdz.ch.db.domain.Switch"
>
update switch
set `state` = #{state,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
<select
id=
"selectOneByExample"
parameterType=
"com.wwdz.ch.db.domain.SwitchExample"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<include
refid=
"Base_Column_List"
/>
from switch
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
</if>
limit 1
</select>
<select
id=
"selectOneByExampleSelective"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<choose>
<when
test=
"selective != null and selective.length > 0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, `state`
</otherwise>
</choose>
from switch
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
<if
test=
"example.orderByClause != null"
>
order by ${example.orderByClause}
</if>
limit 1
</select>
</mapper>
\ No newline at end of file
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WebMvcConfiguration.java
View file @
3cd30d72
...
...
@@ -30,9 +30,9 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
registry
.
addInterceptor
(
loginInterceptor
())
.
addPathPatterns
(
"/**"
)
.
excludePathPatterns
(
"/*.html"
,
"/**/*.html"
,
"/**/*.css"
,
"/**/*.js"
,
"/wx/user/loginByWx"
,
"/wx/user/loginByMobile"
,
"/wx/user/loginRegCaptcha"
,
"/wx/user/updateRegCaptcha"
,
"/wx/user/login"
,
"/wx/item/page"
,
"/wx/item/info"
,
"/wx/item/findNames"
,
"/wx/favorites/info"
,
"/wx/favorites/itemList"
,
"/wx/keyword/recommend"
,
"/wx/queryPrice/**"
);
,
"/wx/user/loginByWx"
,
"/wx/user/loginByMobile"
,
"/wx/user/loginRegCaptcha"
,
"/wx/user/updateRegCaptcha"
,
"/wx/user/login"
);
//
, "/wx/item/page", "/wx/item/info", "/wx/item/findNames"
//
, "/wx/favorites/info", "/wx/favorites/itemList"
//
, "/wx/keyword/recommend", "/wx/queryPrice/**");
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
3cd30d72
...
...
@@ -45,29 +45,6 @@ public class FavoritesServiceImpl implements FavoritesService {
@Autowired
private
ItemDao
itemDao
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
addDefault
(
FavoritesRequestDto
dto
)
{
try
{
Favorites
favorites
=
new
Favorites
();
favorites
.
setUserId
(
dto
.
getUserId
());
favorites
.
setTitle
(
"默认收藏册"
);
favorites
.
setDescription
(
""
);
favorites
.
setImages
(
""
);
Date
date
=
new
Date
();
favorites
.
setAddTime
(
date
);
favorites
.
setUpdateTime
(
date
);
favorites
.
setDeleted
(
false
);
favorites
.
setSort
(
1
);
favoritesDao
.
insert
(
favorites
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"新建默认收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(-
1
,
"新建默认收藏册失败"
);
}
}
@Override
public
Result
page
(
FavoritesRequestDto
dto
)
{
try
{
...
...
@@ -254,7 +231,7 @@ public class FavoritesServiceImpl implements FavoritesService {
vo
.
setIsCollected
(
0
);
vo
.
setIsMine
(
0
);
if
(
Objects
.
nonNull
(
dto
.
getUserId
())
&&
dto
.
getUserId
()
!=
0L
)
{
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
relation
.
getItemId
())
?
1
:
0
);
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
relation
.
getItemId
()
,
null
)
?
1
:
0
);
vo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
}
// 设置收藏数
...
...
@@ -287,9 +264,6 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,收藏册不存在"
);
}
if
(
1
==
favorites
.
getSort
())
{
return
Result
.
failed
(
"无法删除默认收藏册"
);
}
// 删除收藏册
favoritesDao
.
delete
(
dto
.
getId
(),
null
);
...
...
@@ -345,16 +319,12 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,收藏册不存在"
);
}
if
(
favoritesItemsRelationDao
.
isCollected
(
favorites
.
getUserId
(),
dto
.
getId
()))
{
return
Result
.
failed
(
"
您已经收藏过该藏品
"
);
if
(
favoritesItemsRelationDao
.
isCollected
(
favorites
.
getUserId
(),
null
,
dto
.
getItemIds
()))
{
return
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
);
// 更新收藏册id
favoritesItemsRelationDao
.
updateFavoritesId
(
favorites
.
getUserId
(),
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
...
...
@@ -371,31 +341,17 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override
public
Result
removeItem
(
ItemRequestDto
dto
)
{
try
{
// 批量删除收藏册下用户创建的钱币
List
<
UserItemsRelation
>
usersItemsList
=
userItemsRelationDao
.
listByUserIds
(
dto
.
getUserId
(),
null
);
if
(
CollectionUtils
.
isNotEmpty
(
usersItemsList
))
{
List
<
Long
>
usersItemsIds
=
usersItemsList
.
stream
()
.
map
(
UserItemsRelation:
:
getItemId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
itemIds
=
dto
.
getItemIds
().
stream
()
.
filter
(
usersItemsIds:
:
contains
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
itemIds
))
{
CoinRequestDto
coinRequestDto
=
new
CoinRequestDto
();
coinRequestDto
.
setIds
(
itemIds
);
itemDao
.
deleteUserItems
(
coinRequestDto
);
}
}
// 删除收藏册和钱币的关联
favoritesItemsRelationDao
.
delete
ByChosen
(
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
favoritesItemsRelationDao
.
delete
FavoritesId
(
dto
.
getUserId
(),
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
logger
.
info
(
"【请求结束】取消收藏成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
info
(
"收藏册
取消收藏
失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
info
(
"收藏册
移除
失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"收藏册
取消收藏
失败"
);
return
Result
.
failed
(
"收藏册
移除
失败"
);
}
}
...
...
@@ -407,23 +363,8 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,目标收藏册不存在"
);
}
// 删除原收藏册和藏品关联记录
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getBeforeFavoritesId
(),
dto
.
getItemIds
());
// 新增新收藏册和藏品关联记录
Date
now
=
new
Date
();
List
<
FavoritesItemsRelation
>
list
=
new
ArrayList
<>();
for
(
Long
itemId
:
dto
.
getItemIds
())
{
FavoritesItemsRelation
record
=
new
FavoritesItemsRelation
();
record
.
setFavoritesId
(
dto
.
getAfterFavoritesId
());
record
.
setUserId
(
favorites
.
getUserId
());
record
.
setItemId
(
itemId
);
record
.
setAddTime
(
now
);
list
.
add
(
record
);
}
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
favoritesItemsRelationDao
.
batchInsert
(
list
);
}
// 更新收藏册id
favoritesItemsRelationDao
.
updateFavoritesId
(
favorites
.
getUserId
(),
dto
.
getAfterFavoritesId
(),
dto
.
getItemIds
());
// 更新收藏册操作时间
List
<
Long
>
favoritesIds
=
new
ArrayList
<>();
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
View file @
3cd30d72
...
...
@@ -9,6 +9,7 @@ import com.wwdz.ch.db.dao.ItemDao;
import
com.wwdz.ch.db.dao.UserItemsRelationDao
;
import
com.wwdz.ch.db.domain.Footprint
;
import
com.wwdz.ch.db.domain.Item
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
com.wwdz.ch.wx.entity.request.FootPrintRequestDto
;
import
com.wwdz.ch.wx.entity.vo.AgentTranceResponseVo
;
import
com.wwdz.ch.wx.entity.vo.ItemResponseVo
;
...
...
@@ -25,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
FootPrintServiceImpl
implements
FootPrintService
{
...
...
@@ -48,6 +50,7 @@ public class FootPrintServiceImpl implements FootPrintService {
result
.
setList
(
new
ArrayList
<>());
result
.
setHasNextPage
(
false
);
// 分页查询足迹
PageInfo
<
Footprint
>
page
=
footPrintDao
.
pageByUserId
(
dto
.
getUserId
(),
dto
.
getPage
(),
dto
.
getSize
());
if
(
CollectionUtils
.
isEmpty
(
page
.
getList
()))
{
return
Result
.
success
(
result
);
...
...
@@ -75,9 +78,19 @@ public class FootPrintServiceImpl implements FootPrintService {
calendar
.
setTime
(
now
);
calendar
.
add
(
Calendar
.
MONTH
,
-
1
);
Date
month
=
calendar
.
getTime
();
// 获取足迹对应的藏品列表
List
<
Long
>
itemIds
=
page
.
getList
().
stream
()
.
map
(
Footprint:
:
getItemId
).
collect
(
Collectors
.
toList
());
CoinRequestDto
coinRequestDto
=
new
CoinRequestDto
();
coinRequestDto
.
setIds
(
itemIds
);
List
<
Item
>
itemList
=
itemDao
.
findList
(
coinRequestDto
);
Map
<
Long
,
Item
>
itemMap
=
itemList
.
stream
()
.
collect
(
Collectors
.
toMap
(
Item:
:
getId
,
s
->
s
,
(
k1
,
k2
)
->
k2
));
// 包装结果
for
(
Footprint
footprint
:
page
.
getList
())
{
ItemResponseVo
itemResponseVo
=
new
ItemResponseVo
();
Item
item
=
item
Dao
.
findDetails
(
footprint
.
getItemId
());
Item
item
=
item
Map
.
get
(
footprint
.
getItemId
());
// 设置基本信息
itemResponseVo
.
setId
(
footprint
.
getId
());
itemResponseVo
.
setItemId
(
item
.
getId
());
...
...
@@ -88,7 +101,7 @@ public class FootPrintServiceImpl implements FootPrintService {
// 设置价格
itemResponseVo
.
setPrice
(
getPrice
(
item
.
getPrice
()));
// 设置是否收藏或是否是自己发布的
itemResponseVo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
footprint
.
getItemId
())
?
1
:
0
);
itemResponseVo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
footprint
.
getItemId
()
,
null
)
?
1
:
0
);
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
// 设置收藏数
itemResponseVo
.
setCollectCount
(
getCollectCount
(
item
.
getId
(),
item
.
getSourceType
()));
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
3cd30d72
This diff is collapsed.
Click to expand it.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/SwitchServiceImpl.java
0 → 100644
View file @
3cd30d72
package
com.wwdz.ch.wx.impl
;
import
com.wwdz.ch.db.dao.SwitchDao
;
import
com.wwdz.ch.db.domain.Switch
;
import
com.wwdz.ch.wx.service.SwitchService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
SwitchServiceImpl
implements
SwitchService
{
@Autowired
private
SwitchDao
switchDao
;
@Override
public
Switch
findOnly
()
{
return
switchDao
.
find
();
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserServiceImpl.java
View file @
3cd30d72
...
...
@@ -13,7 +13,6 @@ import com.wwdz.ch.core.util.UUID;
import
com.wwdz.ch.core.util.bcrypt.BCryptPasswordEncoder
;
import
com.wwdz.ch.db.dao.UserDao
;
import
com.wwdz.ch.db.domain.User
;
import
com.wwdz.ch.db.dto.request.FavoritesRequestDto
;
import
com.wwdz.ch.wx.constant.CacheCodeConstants
;
import
com.wwdz.ch.wx.constant.LoginTypeEnum
;
import
com.wwdz.ch.wx.dao.UserInfo
;
...
...
@@ -23,7 +22,6 @@ import com.wwdz.ch.wx.manager.AlipayLoginManager;
import
com.wwdz.ch.wx.manager.TikTokLoginManager
;
import
com.wwdz.ch.wx.manager.UserTokenManager
;
import
com.wwdz.ch.wx.manager.WxLoginManager
;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
com.wwdz.ch.wx.service.UserService
;
import
com.wwdz.ch.wx.util.IpUtil
;
import
com.wwdz.ch.wx.util.RedisUtil
;
...
...
@@ -59,8 +57,6 @@ public class UserServiceImpl implements UserService {
@Autowired
private
ApplicationContext
applicationContext
;
@Autowired
private
FavoritesService
favoritesService
;
@Autowired
private
WxLoginManager
wxLoginManager
;
@Autowired
private
AlipayLoginManager
alipayLoginManager
;
...
...
@@ -437,10 +433,6 @@ public class UserServiceImpl implements UserService {
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
user
.
setShareUserId
(
0L
);
userDao
.
insert
(
user
);
FavoritesRequestDto
favoritesRequestDto
=
new
FavoritesRequestDto
();
favoritesRequestDto
.
setUserId
(
user
.
getId
());
favoritesService
.
addDefault
(
favoritesRequestDto
);
}
else
{
user
.
setLastLoginTime
(
new
Date
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
View file @
3cd30d72
package
com.wwdz.ch.wx.interceptor
;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.db.dao.UserDao
;
import
com.wwdz.ch.db.domain.Switch
;
import
com.wwdz.ch.db.domain.User
;
import
com.wwdz.ch.wx.manager.UserTokenManager
;
import
com.wwdz.ch.wx.service.InviteRecordService
;
import
com.wwdz.ch.wx.service.SwitchService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -11,14 +16,24 @@ import org.springframework.web.servlet.ModelAndView;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
public
class
LoginInterceptor
implements
HandlerInterceptor
{
Logger
logger
=
LoggerFactory
.
getLogger
(
LoginInterceptor
.
class
);
@Autowired
private
UserTokenManager
userTokenManager
;
@Autowired
private
SwitchService
switchService
;
@Autowired
private
UserDao
userDao
;
@Autowired
private
InviteRecordService
inviteRecordService
;
String
[]
excludeUrl
=
{
"/wx/item/page"
,
"/wx/item/info"
,
"/wx/item/findNames"
,
"/wx/keyword/recommend"
};
/***
* 在请求处理之前进行调用(Controller方法调用之前)
...
...
@@ -27,6 +42,16 @@ public class LoginInterceptor implements HandlerInterceptor {
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
logger
.
info
(
"进入拦截器"
);
String
token
=
request
.
getHeader
(
"Authorization"
);
Switch
switchh
=
switchService
.
findOnly
();
boolean
isOpen
=
false
;
if
(
Objects
.
nonNull
(
switchh
)
&&
switchh
.
getState
()
==
1
)
{
isOpen
=
true
;
}
String
url
=
request
.
getRequestURI
();
if
(!
isOpen
)
{
if
(
Arrays
.
asList
(
excludeUrl
).
contains
(
url
))
{
return
true
;
}
if
(
StringUtils
.
isNotBlank
(
token
))
{
if
(
userTokenManager
.
checkLogin
(
token
))
{
return
true
;
...
...
@@ -40,6 +65,45 @@ public class LoginInterceptor implements HandlerInterceptor {
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
getWriter
().
write
(
JSON
.
toJSONString
(
map
));
}
else
{
Integer
loginType
=
1
;
if
(
StringUtils
.
isBlank
(
token
))
{
loginType
=
2
;
}
if
(
StringUtils
.
isNotBlank
(
token
))
{
if
(
userTokenManager
.
checkLogin
(
token
))
{
User
user
=
userDao
.
queryById
(
userTokenManager
.
getUserId
(
token
));
if
(!(
Boolean
)
inviteRecordService
.
isExisted
(
user
.
getMobile
()).
getData
())
{
loginType
=
3
;
}
}
else
{
loginType
=
2
;
}
}
if
(
loginType
==
1
)
{
return
true
;
}
if
(
loginType
==
2
)
{
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
));
}
if
(
loginType
==
3
)
{
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"code"
,
403
);
map
.
put
(
"success"
,
false
);
map
.
put
(
"message"
,
"未授权!"
);
map
.
put
(
"result"
,
null
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_FORBIDDEN
);
response
.
getWriter
().
write
(
JSON
.
toJSONString
(
map
));
}
}
return
false
;
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/manager/AlipayLoginManager.java
View file @
3cd30d72
...
...
@@ -82,6 +82,7 @@ public class AlipayLoginManager {
logger
.
error
(
"支付宝解密失败,解密异常"
,
e
);
return
"false"
;
}
logger
.
info
(
"支付宝解密结果:"
+
plainData
);
if
(
StringUtils
.
isBlank
(
plainData
)
||
!
plainData
.
contains
(
"mobile"
))
{
logger
.
info
(
"支付宝解密失败,解密不通过"
);
return
"false"
;
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
View file @
3cd30d72
...
...
@@ -5,14 +5,6 @@ import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import
com.wwdz.ch.db.dto.request.FavoritesRequestDto
;
public
interface
FavoritesService
{
/**
* 新增默认收藏册
*
* @param dto
* @return
*/
Result
addDefault
(
FavoritesRequestDto
dto
);
/**
* 收藏册分页
*
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/ItemService.java
View file @
3cd30d72
...
...
@@ -16,7 +16,7 @@ public interface ItemService {
Result
nameList
(
ItemRequestDto
dto
);
/**
*
藏品分
页
*
首
页
*
* @param dto
* @return
...
...
@@ -24,12 +24,20 @@ public interface ItemService {
Result
page
(
ItemRequestDto
dto
);
/**
*
藏品列表
*
我发布的
*
* @param dto
* @return
*/
Result
list
(
ItemRequestDto
dto
);
Result
myPage
(
ItemRequestDto
dto
);
/**
* 全部藏品
*
* @param dto
* @return
*/
Result
collectPage
(
ItemRequestDto
dto
);
/**
* 新增藏品
...
...
@@ -47,6 +55,14 @@ public interface ItemService {
*/
Result
info
(
ItemRequestDto
dto
);
/**
* 藏品删除
*
* @param dto
* @return
*/
Result
del
(
ItemRequestDto
dto
);
/**
* 收藏(仅首页使用)
*
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/SwitchService.java
0 → 100644
View file @
3cd30d72
package
com.wwdz.ch.wx.service
;
import
com.wwdz.ch.db.domain.Switch
;
public
interface
SwitchService
{
/**
* 获取开关配置
*
* @return
*/
Switch
findOnly
();
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
View file @
3cd30d72
...
...
@@ -146,7 +146,7 @@ public class WxFavoritesController {
if
(
Objects
.
isNull
(
dto
.
getFavoritesId
()))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getId
()))
{
if
(
CollectionUtils
.
isEmpty
(
dto
.
getItemIds
()))
{
return
Result
.
failed
(
"请选择藏品"
);
}
return
favoritesService
.
addItem
(
dto
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxItemController.java
View file @
3cd30d72
...
...
@@ -34,7 +34,7 @@ public class WxItemController {
return
itemService
.
nameList
(
dto
);
}
@ApiOperation
(
value
=
"
分页查询
"
)
@ApiOperation
(
value
=
"
首页
"
)
@PostMapping
(
"/page"
)
public
Result
page
(
@RequestBody
ItemRequestDto
dto
)
{
logger
.
info
(
"【请求开始】藏品列表首页,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
...
...
@@ -47,10 +47,39 @@ public class WxItemController {
return
itemService
.
page
(
dto
);
}
@ApiOperation
(
value
=
"列表查询"
)
@PostMapping
(
"/list"
)
public
Result
list
(
@RequestBody
ItemRequestDto
dto
)
{
return
itemService
.
list
(
dto
);
@ApiOperation
(
value
=
"我发布的"
)
@PostMapping
(
"/myPage"
)
public
Result
myPage
(
@RequestBody
ItemRequestDto
dto
)
{
logger
.
info
(
"【请求开始】我发布的,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getPage
()))
{
return
Result
.
failed
(
"当前页不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getSize
()))
{
return
Result
.
failed
(
"页面大小不能为空"
);
}
return
itemService
.
myPage
(
dto
);
}
@ApiOperation
(
value
=
"全部收藏"
)
@PostMapping
(
"/collectPage"
)
public
Result
collectPage
(
@RequestBody
ItemRequestDto
dto
)
{
logger
.
info
(
"【请求开始】全部收藏,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"用户id不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getPage
()))
{
return
Result
.
failed
(
"当前页不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getSize
()))
{
return
Result
.
failed
(
"页面大小不能为空"
);
}
if
(
Objects
.
isNull
(
dto
.
getType
()))
{
return
Result
.
failed
(
"类型不能为空"
);
}
return
itemService
.
collectPage
(
dto
);
}
@ApiOperation
(
value
=
"新增"
)
...
...
@@ -69,9 +98,6 @@ public class WxItemController {
if
(
StringUtils
.
isBlank
(
dto
.
getImages
()))
{
return
Result
.
failed
(
"请至少上传一张图片"
);
}
if
(
Objects
.
isNull
(
dto
.
getFavoritesId
()))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
dto
.
setPrice
(
StringUtils
.
isBlank
(
dto
.
getPrice
())
?
"0"
:
dto
.
getPrice
());
return
itemService
.
add
(
dto
);
}
...
...
@@ -95,9 +121,6 @@ public class WxItemController {
if
(
StringUtils
.
isBlank
(
dto
.
getImages
()))
{
return
Result
.
failed
(
"请至少上传一张图片"
);
}
if
(
Objects
.
isNull
(
dto
.
getFavoritesId
()))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
dto
.
setDetail
(
StringUtils
.
isBlank
(
dto
.
getDetail
())
?
""
:
dto
.
getDetail
());
dto
.
setVideos
(
StringUtils
.
isBlank
(
dto
.
getVideos
())
?
""
:
dto
.
getVideos
());
dto
.
setPrice
(
StringUtils
.
isBlank
(
dto
.
getPrice
())
?
"0"
:
dto
.
getPrice
());
...
...
@@ -114,10 +137,23 @@ public class WxItemController {
return
itemService
.
info
(
dto
);
}
@ApiOperation
(
value
=
"删除"
)
@PostMapping
(
"/del"
)
public
Result
del
(
@RequestBody
ItemRequestDto
dto
)
{
logger
.
info
(
"【请求开始】藏品详情查询,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getId
()))
{
return
Result
.
failed
(
"藏品id不能为空"
);
}
return
itemService
.
del
(
dto
);
}
@ApiOperation
(
value
=
"收藏"
)
@PostMapping
(
"/collect"
)
public
Result
collect
(
@RequestBody
ItemRequestDto
dto
)
{
logger
.
info
(
"【请求开始】首页收藏,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
logger
.
info
(
"【请求开始】直接收藏,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"您尚未登录,请先登录"
);
}
if
(
Objects
.
isNull
(
dto
.
getId
()))
{
return
Result
.
failed
(
"藏品id不能为空"
);
}
...
...
@@ -127,7 +163,10 @@ public class WxItemController {
@ApiOperation
(
value
=
"取消收藏"
)
@PostMapping
(
"/cancel"
)
public
Result
cancel
(
@RequestBody
ItemRequestDto
dto
)
{
logger
.
info
(
"【请求开始】首页取消收藏,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
logger
.
info
(
"【请求开始】直接取消收藏,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getUserId
())
||
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"您尚未登录,请先登录"
);
}
if
(
Objects
.
isNull
(
dto
.
getId
()))
{
return
Result
.
failed
(
"藏品id不能为空"
);
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxUserController.java
View file @
3cd30d72
...
...
@@ -3,9 +3,11 @@ package com.wwdz.ch.wx.web;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dto.request.InviteRecordRequestDto
;
import
com.wwdz.ch.wx.constant.CacheCodeConstants
;
import
com.wwdz.ch.wx.constant.LoginTypeEnum
;
import
com.wwdz.ch.wx.entity.request.UserRequestDto
;
import
com.wwdz.ch.wx.service.InviteRecordService
;
import
com.wwdz.ch.wx.service.UserService
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -31,6 +33,8 @@ public class WxUserController {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WxUserController
.
class
);
@Autowired
private
UserService
userService
;
@Autowired
private
InviteRecordService
inviteRecordService
;
@ApiOperation
(
value
=
"快捷登录"
)
...
...
@@ -98,7 +102,7 @@ public class WxUserController {
@ApiOperation
(
value
=
"手机验证码登录"
)
@PostMapping
(
"/loginByMobile"
)
public
Result
loginByMobile
(
@RequestBody
UserRequestDto
dto
,
HttpServletRequest
request
)
{
logger
.
info
(
"【请求开始】手机号登录,请求参数
,kl_data
:{}"
,
JSON
.
toJSONString
(
dto
));
logger
.
info
(
"【请求开始】手机号登录,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
StringUtils
.
isBlank
(
dto
.
getMobile
()))
{
return
Result
.
failed
(
"手机号不能为空"
);
}
...
...
@@ -108,6 +112,22 @@ public class WxUserController {
return
userService
.
loginByMobile
(
dto
,
request
);
}
@ApiOperation
(
value
=
"填写邀请码"
)
@PostMapping
(
"/fillCode"
)
public
Result
fillCode
(
@RequestBody
InviteRecordRequestDto
dto
)
{
logger
.
info
(
"【请求开始】填写邀请码,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
Objects
.
isNull
(
dto
.
getInvitee
())
||
dto
.
getInvitee
().
equals
(
0L
))
{
return
Result
.
failed
(
"受邀人id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getInviteePhone
()))
{
return
Result
.
failed
(
"受邀人手机号不能为空"
);
}
if
(
StringUtils
.
isBlank
(
dto
.
getInvitationCode
()))
{
return
Result
.
failed
(
"请填写邀请码"
);
}
return
inviteRecordService
.
create
(
dto
);
}
@ApiOperation
(
value
=
"修改个性签名"
)
@PostMapping
(
"/updateProfile"
)
public
Result
updateProfile
(
@RequestBody
UserRequestDto
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