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
3234caae
Commit
3234caae
authored
Sep 06, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增 开关
parent
6fd7d644
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1287 additions
and
24 deletions
+1287
-24
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
+237
-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/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/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
+20
-10
ch-wx-api/src/main/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
...ain/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
+73
-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/SwitchService.java
...i/src/main/java/com/wwdz/ch/wx/service/SwitchService.java
+12
-0
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/SwitchDao.java
0 → 100644
View file @
3234caae
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 @
3234caae
package
com.wwdz.ch.db.domain
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
/**
* @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 @
3234caae
This diff is collapsed.
Click to expand it.
ch-dao/src/main/java/com/wwdz/ch/db/impl/SwitchDaoImpl.java
0 → 100644
View file @
3234caae
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 @
3234caae
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 @
3234caae
<?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 @
3234caae
...
...
@@ -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/SwitchServiceImpl.java
0 → 100644
View file @
3234caae
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 @
3234caae
...
...
@@ -12,8 +12,8 @@ import com.wwdz.ch.core.util.RegexUtil;
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.Switch
;
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 +23,8 @@ 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.InviteRecordService
;
import
com.wwdz.ch.wx.service.SwitchService
;
import
com.wwdz.ch.wx.service.UserService
;
import
com.wwdz.ch.wx.util.IpUtil
;
import
com.wwdz.ch.wx.util.RedisUtil
;
...
...
@@ -59,8 +60,6 @@ public class UserServiceImpl implements UserService {
@Autowired
private
ApplicationContext
applicationContext
;
@Autowired
private
FavoritesService
favoritesService
;
@Autowired
private
WxLoginManager
wxLoginManager
;
@Autowired
private
AlipayLoginManager
alipayLoginManager
;
...
...
@@ -74,6 +73,11 @@ public class UserServiceImpl implements UserService {
@Autowired
private
AliSmsSender
aliSmsSender
;
@Autowired
private
InviteRecordService
inviteRecordService
;
@Autowired
private
SwitchService
switchService
;
@Override
public
Result
regCaptcha
(
UserRequestDto
dto
)
{
...
...
@@ -128,7 +132,12 @@ public class UserServiceImpl implements UserService {
}
// 获取登录结果
Map
<
String
,
Object
>
result
=
getLoginResult
(
dto
.
getMobile
(),
request
);
Switch
switchh
=
switchService
.
findOnly
();
boolean
isOpen
=
Objects
.
nonNull
(
switchh
)
&&
switchh
.
getState
()
==
1
;
result
.
put
(
"isInvited"
,
inviteRecordService
.
isExisted
(
dto
.
getMobile
()).
getData
());
if
(!
isOpen
)
{
result
.
put
(
"isInvited"
,
true
);
}
logger
.
info
(
"【请求结束】手机号登录,响应结果:{}"
,
JSONObject
.
toJSONString
(
result
));
// 清除验证码缓存
redisUtil
.
del
(
key
);
...
...
@@ -183,7 +192,12 @@ public class UserServiceImpl implements UserService {
}
// 获取登录结果
Map
<
String
,
Object
>
result
=
getLoginResult
(
mobile
,
request
);
Switch
switchh
=
switchService
.
findOnly
();
boolean
isOpen
=
Objects
.
nonNull
(
switchh
)
&&
switchh
.
getState
()
==
1
;
result
.
put
(
"isInvited"
,
inviteRecordService
.
isExisted
(
mobile
).
getData
());
if
(!
isOpen
)
{
result
.
put
(
"isInvited"
,
true
);
}
logger
.
info
(
"【请求结束】快捷登录成功,响应结果:{}"
,
JSONObject
.
toJSONString
(
result
));
return
Result
.
success
(
result
);
}
catch
(
Exception
e
)
{
...
...
@@ -437,10 +451,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 @
3234caae
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,19 +42,67 @@ public class LoginInterceptor implements HandlerInterceptor {
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
logger
.
info
(
"进入拦截器"
);
String
token
=
request
.
getHeader
(
"Authorization"
);
if
(
StringUtils
.
isNotBlank
(
token
))
{
if
(
userTokenManager
.
checkLogin
(
token
))
{
Switch
switchh
=
switchService
.
findOnly
();
boolean
isOpen
=
Objects
.
nonNull
(
switchh
)
&&
switchh
.
getState
()
==
1
;
String
url
=
request
.
getRequestURI
();
if
(!
isOpen
)
{
if
(
Arrays
.
asList
(
excludeUrl
).
contains
(
url
))
{
return
true
;
}
if
(
StringUtils
.
isNotBlank
(
token
))
{
if
(
userTokenManager
.
checkLogin
(
token
))
{
return
true
;
}
}
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"code"
,
401
);
map
.
put
(
"success"
,
false
);
map
.
put
(
"message"
,
"未登录!"
);
map
.
put
(
"result"
,
null
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
getWriter
().
write
(
JSON
.
toJSONString
(
map
));
}
else
{
int
loginType
=
1
;
if
(
StringUtils
.
isBlank
(
token
))
{
loginType
=
2
;
}
else
{
if
(
userTokenManager
.
checkLogin
(
token
))
{
if
(
StringUtils
.
equals
(
url
,
"/wx/user/fillCode"
))
{
return
true
;
}
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
));
}
}
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"code"
,
401
);
map
.
put
(
"success"
,
false
);
map
.
put
(
"message"
,
"未登录!"
);
map
.
put
(
"result"
,
null
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
getWriter
().
write
(
JSON
.
toJSONString
(
map
));
return
false
;
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/manager/AlipayLoginManager.java
View file @
3234caae
...
...
@@ -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/SwitchService.java
0 → 100644
View file @
3234caae
package
com.wwdz.ch.wx.service
;
import
com.wwdz.ch.db.domain.Switch
;
public
interface
SwitchService
{
/**
* 获取开关配置
*
* @return
*/
Switch
findOnly
();
}
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