Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
OSmall
/
linjiashop
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b13259ed
authored
Dec 28, 2020
by
wnb0128
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
2 parents
15bdcfb6
d4ce2826
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
27 deletions
doc/database-open-platform.sql
doc/database.sql
shop-core/src/main/java/com/glsx/shop/bean/entity/shop/Goods.java
shop-core/src/main/java/com/glsx/shop/security/UserService.java
shop-core/src/main/java/com/glsx/shop/service/system/FileService.java
doc/database-open-platform.sql
View file @
b13259e
...
@@ -22,7 +22,7 @@ CREATE TABLE `t_platform_customer`
...
@@ -22,7 +22,7 @@ CREATE TABLE `t_platform_customer`
PRIMARY
KEY
(
`id`
),
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`contact_channel_number`
(
`contact_number`
,
`channel_number`
),
UNIQUE
KEY
`contact_channel_number`
(
`contact_number`
,
`channel_number`
),
UNIQUE
KEY
`customer_name`
(
`customer_name`
)
UNIQUE
KEY
`customer_name`
(
`customer_name`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'客户管理表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
00000
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'客户管理表'
;
DROP
TABLE
IF
EXISTS
`t_platform_secretkey`
;
DROP
TABLE
IF
EXISTS
`t_platform_secretkey`
;
CREATE
TABLE
`t_platform_secretkey`
CREATE
TABLE
`t_platform_secretkey`
...
@@ -69,7 +69,6 @@ CREATE TABLE `t_platform_user`
...
@@ -69,7 +69,6 @@ CREATE TABLE `t_platform_user`
`last_login_time`
DATETIME
DEFAULT
NULL
COMMENT
'最后登录时间'
,
`last_login_time`
DATETIME
DEFAULT
NULL
COMMENT
'最后登录时间'
,
`status`
TINYINT
(
2
)
DEFAULT
1
COMMENT
'用户状态 0 注销 1 正常'
,
`status`
TINYINT
(
2
)
DEFAULT
1
COMMENT
'用户状态 0 注销 1 正常'
,
`app_account_id`
INT
(
11
)
DEFAULT
NULL
COMMENT
'APP 账户ID'
,
`app_account_id`
INT
(
11
)
DEFAULT
NULL
COMMENT
'APP 账户ID'
,
`tu_ya_id`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'涂鸦平台ID'
,
`create_time`
DATETIME
DEFAULT
NULL
COMMENT
'创建时间 注册时间'
,
`create_time`
DATETIME
DEFAULT
NULL
COMMENT
'创建时间 注册时间'
,
`update_time`
DATETIME
DEFAULT
NULL
COMMENT
'更新时间'
,
`update_time`
DATETIME
DEFAULT
NULL
COMMENT
'更新时间'
,
`create_by`
INT
(
11
)
DEFAULT
NULL
COMMENT
'创建人'
,
`create_by`
INT
(
11
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
@@ -77,7 +76,22 @@ CREATE TABLE `t_platform_user`
...
@@ -77,7 +76,22 @@ CREATE TABLE `t_platform_user`
`remark`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'备注'
,
`remark`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'备注'
,
PRIMARY
KEY
(
`id`
),
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`contact_number`
(
`contact_number`
)
UNIQUE
KEY
`contact_number`
(
`contact_number`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'用户管理表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
10000000
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'用户管理表'
;
DROP
TABLE
IF
EXISTS
`t_tuya_user`
;
CREATE
TABLE
`t_tuya_user`
(
`id`
INT
(
11
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'主键'
,
`nickname`
VARCHAR
(
32
)
DEFAULT
NULL
COMMENT
'昵称,账号'
,
`contact_number`
VARCHAR
(
11
)
DEFAULT
NULL
COMMENT
'联系电话'
,
`password`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'密码'
,
`channel`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'渠道'
,
`status`
TINYINT
(
2
)
DEFAULT
'1'
COMMENT
'用户状态 0 注销 1 正常'
,
`tuya_id`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'涂鸦平台ID'
,
`create_time`
DATETIME
DEFAULT
NULL
COMMENT
'创建时间 注册时间'
,
`remark`
VARCHAR
(
50
)
DEFAULT
NULL
COMMENT
'备注'
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`contact_number`
(
`contact_number`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'涂鸦用户表'
;
DROP
TABLE
IF
EXISTS
`t_platform_api`
;
DROP
TABLE
IF
EXISTS
`t_platform_api`
;
CREATE
TABLE
`t_platform_api`
CREATE
TABLE
`t_platform_api`
...
...
doc/database.sql
View file @
b13259e
...
@@ -423,6 +423,7 @@ CREATE TABLE `t_shop_goods` (
...
@@ -423,6 +423,7 @@ CREATE TABLE `t_shop_goods` (
`like_num`
int
(
11
)
DEFAULT
NULL
COMMENT
'收藏数'
,
`like_num`
int
(
11
)
DEFAULT
NULL
COMMENT
'收藏数'
,
`name`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'名称'
,
`name`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'名称'
,
`pic`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'小图'
,
`pic`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'小图'
,
`marketing_price`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'市场价,原价'
,
`price`
varchar
(
16
)
DEFAULT
NULL
COMMENT
'价格'
,
`price`
varchar
(
16
)
DEFAULT
NULL
COMMENT
'价格'
,
`stock`
int
(
11
)
DEFAULT
NULL
COMMENT
'库存数量'
,
`stock`
int
(
11
)
DEFAULT
NULL
COMMENT
'库存数量'
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
...
...
shop-core/src/main/java/com/glsx/shop/bean/entity/shop/Goods.java
View file @
b13259e
...
@@ -51,6 +51,8 @@ public class Goods extends BaseEntity {
...
@@ -51,6 +51,8 @@ public class Goods extends BaseEntity {
*/
*/
@Column
(
columnDefinition
=
"VARCHAR(16) COMMENT '价格'"
)
@Column
(
columnDefinition
=
"VARCHAR(16) COMMENT '价格'"
)
private
BigDecimal
price
;
private
BigDecimal
price
;
@Column
(
name
=
"marketing_price"
,
columnDefinition
=
"VARCHAR(32) COMMENT '市场价,原价'"
)
private
BigDecimal
marketingPrice
;
@Column
(
columnDefinition
=
"tinyint COMMENT '是否删除'"
)
@Column
(
columnDefinition
=
"tinyint COMMENT '是否删除'"
)
private
Boolean
isDelete
=
false
;
private
Boolean
isDelete
=
false
;
@Column
(
columnDefinition
=
"tinyint COMMENT '是否上架'"
)
@Column
(
columnDefinition
=
"tinyint COMMENT '是否上架'"
)
...
...
shop-core/src/main/java/com/glsx/shop/security/UserService.java
View file @
b13259e
...
@@ -6,13 +6,14 @@ import java.util.HashSet;
...
@@ -6,13 +6,14 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
com.glsx.shop.bean.core.AuthorizationUser
;
import
com.glsx.shop.bean.core.AuthorizationUser
;
import
com.glsx.shop.bean.entity.shop.
Shop
User
;
import
com.glsx.shop.bean.entity.shop.
Platform
User
;
import
com.glsx.shop.bean.entity.system.Role
;
import
com.glsx.shop.bean.entity.system.Role
;
import
com.glsx.shop.bean.entity.system.User
;
import
com.glsx.shop.bean.entity.system.User
;
import
com.glsx.shop.bean.vo.JwtUser
;
import
com.glsx.shop.bean.vo.JwtUser
;
import
com.glsx.shop.bean.vo.SpringContextHolder
;
import
com.glsx.shop.bean.vo.SpringContextHolder
;
import
com.glsx.shop.cache.CacheDao
;
import
com.glsx.shop.cache.CacheDao
;
import
com.glsx.shop.cache.TokenCache
;
import
com.glsx.shop.cache.TokenCache
;
import
com.glsx.shop.dao.shop.PlatformUserRepository
;
import
com.glsx.shop.dao.shop.ShopUserRepository
;
import
com.glsx.shop.dao.shop.ShopUserRepository
;
import
com.glsx.shop.dao.system.MenuRepository
;
import
com.glsx.shop.dao.system.MenuRepository
;
import
com.glsx.shop.dao.system.RoleRepository
;
import
com.glsx.shop.dao.system.RoleRepository
;
...
@@ -20,6 +21,7 @@ import com.glsx.shop.dao.system.UserRepository;
...
@@ -20,6 +21,7 @@ import com.glsx.shop.dao.system.UserRepository;
import
com.glsx.shop.service.system.impl.ConstantFactory
;
import
com.glsx.shop.service.system.impl.ConstantFactory
;
import
com.glsx.shop.utils.Convert
;
import
com.glsx.shop.utils.Convert
;
import
com.glsx.shop.utils.HttpUtil
;
import
com.glsx.shop.utils.HttpUtil
;
import
com.glsx.shop.utils.JsonUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -51,6 +53,8 @@ public class UserService {
...
@@ -51,6 +53,8 @@ public class UserService {
private
CacheDao
cacheDao
;
private
CacheDao
cacheDao
;
@Autowired
@Autowired
private
ShopUserRepository
shopUserRepository
;
private
ShopUserRepository
shopUserRepository
;
@Autowired
private
PlatformUserRepository
platformUserRepository
;
public
static
UserService
me
()
{
public
static
UserService
me
()
{
return
SpringContextHolder
.
getBean
(
UserService
.
class
);
return
SpringContextHolder
.
getBean
(
UserService
.
class
);
...
@@ -61,6 +65,9 @@ public class UserService {
...
@@ -61,6 +65,9 @@ public class UserService {
String
token
=
HttpUtil
.
getToken
();
String
token
=
HttpUtil
.
getToken
();
AuthorizationUser
userBean
=
tokenCache
.
getUser
(
token
);
AuthorizationUser
userBean
=
tokenCache
.
getUser
(
token
);
this
.
logger
.
info
(
"$$$$ getAuthorizationInfo account: {}, userBean = {}"
,
account
,
JsonUtil
.
toJson
(
userBean
));
if
(
userBean
!=
null
)
{
if
(
userBean
!=
null
)
{
return
userBean
;
return
userBean
;
}
}
...
@@ -68,6 +75,7 @@ public class UserService {
...
@@ -68,6 +75,7 @@ public class UserService {
//构建后台用户认证信息
//构建后台用户认证信息
if
(
userType
==
JwtUser
.
MANAGER
)
{
if
(
userType
==
JwtUser
.
MANAGER
)
{
User
user
=
userRepository
.
findByAccount
(
account
);
User
user
=
userRepository
.
findByAccount
(
account
);
this
.
logger
.
info
(
"$$$$ getAuthorizationInfo manager = {}"
,
JsonUtil
.
toJson
(
user
));
userBean
.
setId
(
user
.
getId
());
userBean
.
setId
(
user
.
getId
());
userBean
.
setAccount
(
user
.
getAccount
());
userBean
.
setAccount
(
user
.
getAccount
());
userBean
.
setDeptId
(
user
.
getDeptid
());
userBean
.
setDeptId
(
user
.
getDeptid
());
...
@@ -97,10 +105,17 @@ public class UserService {
...
@@ -97,10 +105,17 @@ public class UserService {
}
}
//构建前台用户认证信息
//构建前台用户认证信息
if
(
userType
==
JwtUser
.
FRONT_USER
)
{
if
(
userType
==
JwtUser
.
FRONT_USER
)
{
ShopUser
user
=
shopUserRepository
.
findByMobile
(
account
);
// 修改:使用 platform_user 表里面的用户信息进行校验
userBean
.
setId
(
user
.
getId
());
PlatformUser
platformUser
=
this
.
platformUserRepository
.
findByContactNumber
(
account
);
userBean
.
setAccount
(
user
.
getMobile
());
this
.
logger
.
info
(
"$$$$ getAuthorizationInfo frontUser = {}"
,
userBean
.
setPassword
(
user
.
getPassword
());
JsonUtil
.
toJson
(
platformUser
));
userBean
.
setId
(
platformUser
.
getId
());
userBean
.
setAccount
(
platformUser
.
getContactNumber
());
userBean
.
setPassword
(
platformUser
.
getRemark
());
//ShopUser user = shopUserRepository.findByMobile(account);
//userBean.setId(user.getId());
//userBean.setAccount(user.getMobile());
//userBean.setPassword(user.getPassword());
}
}
tokenCache
.
setUser
(
token
,
userBean
);
tokenCache
.
setUser
(
token
,
userBean
);
return
userBean
;
return
userBean
;
...
...
shop-core/src/main/java/com/glsx/shop/service/system/FileService.java
View file @
b13259e
package
com
.
glsx
.
shop
.
service
.
system
;
package
com
.
glsx
.
shop
.
service
.
system
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -21,6 +22,7 @@ import com.glsx.shop.cache.TokenCache;
...
@@ -21,6 +22,7 @@ import com.glsx.shop.cache.TokenCache;
import
com.glsx.shop.dao.system.FileInfoRepository
;
import
com.glsx.shop.dao.system.FileInfoRepository
;
import
com.glsx.shop.security.JwtUtil
;
import
com.glsx.shop.security.JwtUtil
;
import
com.glsx.shop.service.BaseService
;
import
com.glsx.shop.service.BaseService
;
import
com.glsx.shop.utils.HttpUtil
;
import
com.glsx.shop.utils.XlsUtils
;
import
com.glsx.shop.utils.XlsUtils
;
import
org.jxls.common.Context
;
import
org.jxls.common.Context
;
import
org.jxls.expression.JexlExpressionEvaluator
;
import
org.jxls.expression.JexlExpressionEvaluator
;
...
@@ -29,6 +31,7 @@ import org.jxls.util.JxlsHelper;
...
@@ -29,6 +31,7 @@ import org.jxls.util.JxlsHelper;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -133,40 +136,35 @@ public class FileService extends BaseService<FileInfo, Long, FileInfoRepository>
...
@@ -133,40 +136,35 @@ public class FileService extends BaseService<FileInfo, Long, FileInfoRepository>
* @return
* @return
*/
*/
public
FileInfo
createExcel
(
String
template
,
String
fileName
,
Map
<
String
,
Object
>
data
)
{
public
FileInfo
createExcel
(
String
template
,
String
fileName
,
Map
<
String
,
Object
>
data
)
{
FileOutputStream
outputStream
=
null
;
File
file
=
new
File
(
cfgService
.
getCfgValue
(
CfgKey
.
SYSTEM_FILE_UPLOAD_PATH
)
+
File
.
separator
+
UUID
.
randomUUID
().
toString
()
+
".xlsx"
);
try
{
try
{
HttpServletResponse
response
=
HttpUtil
.
getResponse
();
// 定义输出类型
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
outputStream
=
new
FileOutputStream
(
file
);
response
.
setHeader
(
HttpHeaders
.
SET_COOKIE
,
"fileDownload=true; path=/"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment;filename=\""
+
fileName
+
"\""
);
response
.
setContentType
(
"application/csv"
);
JxlsHelper
jxlsHelper
=
JxlsHelper
.
getInstance
();
JxlsHelper
jxlsHelper
=
JxlsHelper
.
getInstance
();
String
templateFile
=
getClass
().
getClassLoader
().
getResource
(
template
).
getPath
();
String
templateFile
=
getClass
().
getClassLoader
().
getResource
(
template
).
getPath
();
InputStream
is
=
new
BufferedInputStream
(
new
FileInputStream
(
templateFile
));
InputStream
templateStream
=
new
BufferedInputStream
(
new
FileInputStream
(
templateFile
));
Transformer
transformer
=
jxlsHelper
.
createTransformer
(
templateStream
,
outputStream
);
Transformer
transformer
=
jxlsHelper
.
createTransformer
(
is
,
outputStream
);
Context
context
=
new
Context
();
Context
context
=
new
Context
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
data
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
data
.
entrySet
())
{
context
.
putVar
(
entry
.
getKey
(),
entry
.
getValue
());
context
.
putVar
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
JexlExpressionEvaluator
evaluator
=
(
JexlExpressionEvaluator
)
transformer
.
getTransformationConfig
().
getExpressionEvaluator
();
JexlExpressionEvaluator
evaluator
=
(
JexlExpressionEvaluator
)
transformer
.
getTransformationConfig
().
getExpressionEvaluator
();
Map
<
String
,
Object
>
funcs
=
new
HashMap
<>(
4
);
Map
<
String
,
Object
>
funcs
=
new
HashMap
<>(
4
);
funcs
.
put
(
"utils"
,
new
XlsUtils
());
funcs
.
put
(
"utils"
,
new
XlsUtils
());
evaluator
.
getJexlEngine
().
setFunctions
(
funcs
);
evaluator
.
getJexlEngine
().
setFunctions
(
funcs
);
jxlsHelper
.
processTemplate
(
context
,
transformer
);
jxlsHelper
.
processTemplate
(
context
,
transformer
);
outputStream
.
flush
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
try
{
outputStream
.
flush
();
outputStream
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
return
save
(
fileName
,
file
);
return
new
FileInfo
();
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment