Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
a5c2aff4
Commit
a5c2aff4
authored
Nov 16, 2018
by
Junling Bu
Browse files
chore[后端服务]: 后端服务代码基于IDEA的reformat code工具格式化代码,但是mybatis generator生成的代码除外。
parent
556f269d
Changes
132
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/pom.xml
View file @
a5c2aff4
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
litemall-admin-api
</artifactId>
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/Application.java
View file @
a5c2aff4
...
...
@@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
@SpringBootApplication
(
scanBasePackages
=
{
"org.linlinjava.litemall.core"
,
"org.linlinjava.litemall.admin"
,
"org.linlinjava.litemall.db"
})
@SpringBootApplication
(
scanBasePackages
=
{
"org.linlinjava.litemall.core"
,
"org.linlinjava.litemall.admin"
,
"org.linlinjava.litemall.db"
})
@MapperScan
(
"org.linlinjava.litemall.db.dao"
)
@EnableTransactionManagement
@EnableScheduling
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/annotation/support/LoginAdminHandlerMethodArgumentResolver.java
View file @
a5c2aff4
...
...
@@ -11,9 +11,10 @@ import org.springframework.web.method.support.ModelAndViewContainer;
public
class
LoginAdminHandlerMethodArgumentResolver
implements
HandlerMethodArgumentResolver
{
public
static
final
String
LOGIN_TOKEN_KEY
=
"Admin-Token"
;
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
return
parameter
.
getParameterType
().
isAssignableFrom
(
Integer
.
class
)&&
parameter
.
hasParameterAnnotation
(
LoginAdmin
.
class
);
return
parameter
.
getParameterType
().
isAssignableFrom
(
Integer
.
class
)
&&
parameter
.
hasParameterAnnotation
(
LoginAdmin
.
class
);
}
@Override
...
...
@@ -22,7 +23,7 @@ public class LoginAdminHandlerMethodArgumentResolver implements HandlerMethodArg
// return new Integer(1);
String
token
=
request
.
getHeader
(
LOGIN_TOKEN_KEY
);
if
(
token
==
null
||
token
.
isEmpty
()){
if
(
token
==
null
||
token
.
isEmpty
())
{
return
null
;
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/config/AdminConfig.java
View file @
a5c2aff4
...
...
@@ -4,6 +4,7 @@ import org.linlinjava.litemall.admin.annotation.support.LoginAdminHandlerMethodA
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
@Configuration
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/dao/AdminToken.java
View file @
a5c2aff4
...
...
@@ -8,35 +8,35 @@ public class AdminToken {
private
LocalDateTime
expireTime
;
private
LocalDateTime
updateTime
;
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
void
setExpireTime
(
LocalDateTime
expireTime
)
{
this
.
expireTime
=
expireTime
;
}
public
void
setUpdateTime
(
LocalDateTime
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
LocalDateTime
getExpireTime
()
{
return
expireTime
;
}
public
void
setExpireTime
(
LocalDateTime
expireTime
)
{
this
.
expireTime
=
expireTime
;
}
public
LocalDateTime
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
LocalDateTime
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/dao/GoodsAllinone.java
View file @
a5c2aff4
...
...
@@ -2,8 +2,8 @@ package org.linlinjava.litemall.admin.dao;
import
org.linlinjava.litemall.db.domain.LitemallGoods
;
import
org.linlinjava.litemall.db.domain.LitemallGoodsAttribute
;
import
org.linlinjava.litemall.db.domain.LitemallGoodsSpecification
;
import
org.linlinjava.litemall.db.domain.LitemallGoodsProduct
;
import
org.linlinjava.litemall.db.domain.LitemallGoodsSpecification
;
public
class
GoodsAllinone
{
LitemallGoods
goods
;
...
...
@@ -16,6 +16,10 @@ public class GoodsAllinone {
return
goods
;
}
public
void
setGoods
(
LitemallGoods
goods
)
{
this
.
goods
=
goods
;
}
public
LitemallGoodsProduct
[]
getProducts
()
{
return
products
;
}
...
...
@@ -24,10 +28,6 @@ public class GoodsAllinone {
this
.
products
=
products
;
}
public
void
setGoods
(
LitemallGoods
goods
)
{
this
.
goods
=
goods
;
}
public
LitemallGoodsSpecification
[]
getSpecifications
()
{
return
specifications
;
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/service/AdminTokenManager.java
View file @
a5c2aff4
...
...
@@ -14,11 +14,11 @@ public class AdminTokenManager {
public
static
Integer
getUserId
(
String
token
)
{
AdminToken
userToken
=
tokenMap
.
get
(
token
);
if
(
userToken
==
null
){
if
(
userToken
==
null
)
{
return
null
;
}
if
(
userToken
.
getExpireTime
().
isBefore
(
LocalDateTime
.
now
())){
if
(
userToken
.
getExpireTime
().
isBefore
(
LocalDateTime
.
now
()))
{
tokenMap
.
remove
(
token
);
idMap
.
remove
(
userToken
.
getUserId
());
return
null
;
...
...
@@ -28,7 +28,7 @@ public class AdminTokenManager {
}
public
static
AdminToken
generateToken
(
Integer
id
){
public
static
AdminToken
generateToken
(
Integer
id
)
{
AdminToken
userToken
=
null
;
// userToken = idMap.get(id);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/util/StatVo.java
View file @
a5c2aff4
...
...
@@ -25,7 +25,7 @@ public class StatVo {
this
.
rows
=
rows
;
}
public
void
add
(
Map
...
r
)
{
public
void
add
(
Map
...
r
)
{
rows
.
addAll
(
Arrays
.
asList
(
r
));
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdController.java
View file @
a5c2aff4
...
...
@@ -3,18 +3,17 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallAd
;
import
org.linlinjava.litemall.db.service.LitemallAdService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -34,8 +33,8 @@ public class AdminAdController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -50,23 +49,23 @@ public class AdminAdController {
private
Object
validate
(
LitemallAd
ad
)
{
String
name
=
ad
.
getName
();
if
(
StringUtils
.
isEmpty
(
name
)){
if
(
StringUtils
.
isEmpty
(
name
))
{
return
ResponseUtil
.
badArgument
();
}
String
content
=
ad
.
getName
();
if
(
StringUtils
.
isEmpty
(
content
)){
if
(
StringUtils
.
isEmpty
(
content
))
{
return
ResponseUtil
.
badArgument
();
}
return
null
;
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
){
if
(
adminId
==
null
){
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
ad
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
adService
.
add
(
ad
);
...
...
@@ -74,8 +73,8 @@ public class AdminAdController {
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
){
if
(
adminId
==
null
){
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -84,15 +83,15 @@ public class AdminAdController {
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
){
if
(
adminId
==
null
){
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
ad
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
if
(
adService
.
updateById
(
ad
)
==
0
){
if
(
adService
.
updateById
(
ad
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
...
...
@@ -100,12 +99,12 @@ public class AdminAdController {
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
){
if
(
adminId
==
null
){
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Integer
id
=
ad
.
getId
();
if
(
id
==
null
){
if
(
id
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
adService
.
deleteById
(
id
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAddressController.java
View file @
a5c2aff4
...
...
@@ -3,19 +3,19 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.Re
gex
Util
;
import
org.linlinjava.litemall.core.util.Re
sponse
Util
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallAddress
;
import
org.linlinjava.litemall.db.service.LitemallAddressService
;
import
org.linlinjava.litemall.db.service.LitemallRegionService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -32,7 +32,7 @@ public class AdminAddressController {
@Autowired
private
LitemallRegionService
regionService
;
private
Map
<
String
,
Object
>
toVo
(
LitemallAddress
address
){
private
Map
<
String
,
Object
>
toVo
(
LitemallAddress
address
)
{
Map
<
String
,
Object
>
addressVo
=
new
HashMap
<>();
addressVo
.
put
(
"id"
,
address
.
getId
());
addressVo
.
put
(
"userId"
,
address
.
getUserId
());
...
...
@@ -58,8 +58,8 @@ public class AdminAddressController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -67,7 +67,7 @@ public class AdminAddressController {
int
total
=
addressService
.
countSelective
(
userId
,
name
,
page
,
limit
,
sort
,
order
);
List
<
Map
<
String
,
Object
>>
addressVoList
=
new
ArrayList
<>(
addressList
.
size
());
for
(
LitemallAddress
address
:
addressList
){
for
(
LitemallAddress
address
:
addressList
)
{
Map
<
String
,
Object
>
addressVo
=
toVo
(
address
);
addressVoList
.
add
(
addressVo
);
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
View file @
a5c2aff4
...
...
@@ -12,13 +12,11 @@ import org.linlinjava.litemall.core.validator.Sort;
import
org.linlinjava.litemall.db.domain.LitemallAdmin
;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -34,13 +32,13 @@ public class AdminAdminController {
private
LitemallAdminService
adminService
;
@GetMapping
(
"/info"
)
public
Object
info
(
String
token
){
public
Object
info
(
String
token
)
{
Integer
adminId
=
AdminTokenManager
.
getUserId
(
token
);
if
(
adminId
==
null
){
if
(
adminId
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
LitemallAdmin
admin
=
adminService
.
findById
(
adminId
);
if
(
admin
==
null
){
if
(
admin
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
...
...
@@ -62,8 +60,8 @@ public class AdminAdminController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -78,32 +76,32 @@ public class AdminAdminController {
private
Object
validate
(
LitemallAdmin
admin
)
{
String
name
=
admin
.
getUsername
();
if
(
StringUtils
.
isEmpty
(
name
)){
if
(
StringUtils
.
isEmpty
(
name
))
{
return
ResponseUtil
.
badArgument
();
}
if
(!
RegexUtil
.
isUsername
(
name
)){
if
(!
RegexUtil
.
isUsername
(
name
))
{
return
ResponseUtil
.
fail
(
402
,
"管理员名称不符合规定"
);
}
String
password
=
admin
.
getPassword
();
if
(
StringUtils
.
isEmpty
(
password
)
||
password
.
length
()
<
6
){
if
(
StringUtils
.
isEmpty
(
password
)
||
password
.
length
()
<
6
)
{
return
ResponseUtil
.
fail
(
402
,
"管理员密码长度不能小于6"
);
}
return
null
;
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
){
if
(
adminId
==
null
){
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
admin
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
String
username
=
admin
.
getUsername
();
List
<
LitemallAdmin
>
adminList
=
adminService
.
findAdmin
(
username
);
if
(
adminList
.
size
()
>
0
){
if
(
adminList
.
size
()
>
0
)
{
return
ResponseUtil
.
fail
(
402
,
"管理员已经存在"
);
}
...
...
@@ -116,8 +114,8 @@ public class AdminAdminController {
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
){
if
(
adminId
==
null
){
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -126,22 +124,22 @@ public class AdminAdminController {
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
){
if
(
adminId
==
null
){
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
admin
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
Integer
anotherAdminId
=
admin
.
getId
();
if
(
anotherAdminId
==
null
){
if
(
anotherAdminId
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
// TODO 这里开发者需要删除以下检验代码
// 目前这里不允许修改超级管理员是防止演示平台上他人修改管理员密码而导致登录失败
if
(
anotherAdminId
==
1
){
if
(
anotherAdminId
==
1
)
{
return
ResponseUtil
.
fail
(
403
,
"超级管理员不能修改"
);
}
...
...
@@ -150,7 +148,7 @@ public class AdminAdminController {
String
encodedPassword
=
encoder
.
encode
(
rawPassword
);
admin
.
setPassword
(
encodedPassword
);
if
(
adminService
.
updateById
(
admin
)
==
0
){
if
(
adminService
.
updateById
(
admin
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
...
...
@@ -158,18 +156,18 @@ public class AdminAdminController {
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
){
if
(
adminId
==
null
){
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Integer
anotherAdminId
=
admin
.
getId
();
if
(
anotherAdminId
==
null
){
if
(
anotherAdminId
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
// TODO 这里开发者需要删除以下检验代码
// 目前这里不允许删除超级管理员是防止演示平台上他人删除管理员账号而导致登录失败
if
(
anotherAdminId
==
1
){
if
(
anotherAdminId
==
1
)
{
return
ResponseUtil
.
fail
(
403
,
"超级管理员不能删除"
);
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAuthController.java
View file @
a5c2aff4
...
...
@@ -2,14 +2,14 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.dao.AdminToken
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.admin.dao.AdminToken
;
import
org.linlinjava.litemall.admin.service.AdminTokenManager
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.util.bcrypt.BCryptPasswordEncoder
;
import
org.linlinjava.litemall.db.domain.LitemallAdmin
;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
...
...
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
...
...
@@ -33,23 +34,23 @@ public class AdminAuthController {
* { username : value, password : value }
*/
@PostMapping
(
"/login"
)
public
Object
login
(
@RequestBody
String
body
){
public
Object
login
(
@RequestBody
String
body
)
{
String
username
=
JacksonUtil
.
parseString
(
body
,
"username"
);
String
password
=
JacksonUtil
.
parseString
(
body
,
"password"
);
if
(
StringUtils
.
isEmpty
(
username
)
||
StringUtils
.
isEmpty
(
password
)){
if
(
StringUtils
.
isEmpty
(
username
)
||
StringUtils
.
isEmpty
(
password
))
{
return
ResponseUtil
.
badArgument
();
}
List
<
LitemallAdmin
>
adminList
=
adminService
.
findAdmin
(
username
);
Assert
.
state
(
adminList
.
size
()
<
2
,
"同一个用户名存在两个账户"
);
if
(
adminList
.
size
()
==
0
){
if
(
adminList
.
size
()
==
0
)
{
return
ResponseUtil
.
badArgumentValue
();
}
LitemallAdmin
admin
=
adminList
.
get
(
0
);
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
if
(!
encoder
.
matches
(
password
,
admin
.
getPassword
())){
if
(!
encoder
.
matches
(
password
,
admin
.
getPassword
()))
{
return
ResponseUtil
.
fail
(
403
,
"账号密码不对"
);
}
...
...
@@ -64,8 +65,8 @@ public class AdminAuthController {
*
*/
@PostMapping
(
"/logout"
)
public
Object
login
(
@LoginAdmin
Integer
adminId
){
if
(
adminId
==
null
){
public
Object
login
(
@LoginAdmin
Integer
adminId
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminBrandController.java
View file @
a5c2aff4
...
...
@@ -3,11 +3,11 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallBrand
;
import
org.linlinjava.litemall.db.service.LitemallBrandService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -35,8 +34,8 @@ public class AdminBrandController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -51,29 +50,29 @@ public class AdminBrandController {
private
Object
validate
(
LitemallBrand
brand
)
{
String
name
=
brand
.
getName
();
if
(
StringUtils
.
isEmpty
(
name
)){
if
(
StringUtils
.
isEmpty
(
name
))
{
return
ResponseUtil
.
badArgument
();
}
String
desc
=
brand
.
getDesc
();
if
(
StringUtils
.
isEmpty
(
desc
)){
if
(
StringUtils
.
isEmpty
(
desc
))
{
return
ResponseUtil
.
badArgument
();
}
BigDecimal
price
=
brand
.
getFloorPrice
();
if
(
price
==
null
){
if
(
price
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
return
null
;
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
){
if
(
adminId
==
null
){
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
brand
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
brandService
.
add
(
brand
);
...
...
@@ -81,8 +80,8 @@ public class AdminBrandController {
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
){
if
(
adminId
==
null
){
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -91,27 +90,27 @@ public class AdminBrandController {
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
){
if
(
adminId
==
null
){
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
brand
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
if
(
brandService
.
updateById
(
brand
)
==
0
){
if
(
brandService
.
updateById
(
brand
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
return
ResponseUtil
.
ok
(
brand
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
){
if
(
adminId
==
null
){
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Integer
id
=
brand
.
getId
();
if
(
id
==
null
){
if
(
id
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
brandService
.
deleteById
(
id
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCategoryController.java
View file @
a5c2aff4
...
...
@@ -3,19 +3,17 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.
admin
.util.
CatVo
;
import
org.linlinjava.litemall.
core
.util.
ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallCategory
;
import
org.linlinjava.litemall.db.service.LitemallCategoryService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -36,8 +34,8 @@ public class AdminCategoryController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -52,20 +50,20 @@ public class AdminCategoryController {
private
Object
validate
(
LitemallCategory
category
)
{
String
name
=
category
.
getName
();
if
(
StringUtils
.
isEmpty
(
name
)){
if
(
StringUtils
.
isEmpty
(
name
))
{
return
ResponseUtil
.
badArgument
();
}
String
level
=
category
.
getLevel
();
if
(
StringUtils
.
isEmpty
(
level
)){
if
(
StringUtils
.
isEmpty
(
level
))
{
return
ResponseUtil
.
badArgument
();
}
if
(!
level
.
equals
(
"L1"
)
&&
!
level
.
equals
(
"L2"
)){
if
(!
level
.
equals
(
"L1"
)
&&
!
level
.
equals
(
"L2"
))
{
return
ResponseUtil
.
badArgumentValue
();
}
Integer
pid
=
category
.
getPid
();
if
(
level
.
equals
(
"L2"
)
&&
(
pid
==
null
)){
if
(
level
.
equals
(
"L2"
)
&&
(
pid
==
null
))
{
return
ResponseUtil
.
badArgument
();
}
...
...
@@ -73,12 +71,12 @@ public class AdminCategoryController {
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
){
if
(
adminId
==
null
){
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
category
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
categoryService
.
add
(
category
);
...
...
@@ -86,8 +84,8 @@ public class AdminCategoryController {
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
){
if
(
adminId
==
null
){
public
Object
read
(
@LoginAdmin
Integer
adminId
,
@NotNull
Integer
id
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -96,28 +94,28 @@ public class AdminCategoryController {
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
){
if
(
adminId
==
null
){
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
category
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
if
(
categoryService
.
updateById
(
category
)
==
0
){
if
(
categoryService
.
updateById
(
category
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
return
ResponseUtil
.
ok
();
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
){
if
(
adminId
==
null
){
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Integer
id
=
category
.
getId
();
if
(
id
==
null
){
if
(
id
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
categoryService
.
deleteById
(
id
);
...
...
@@ -133,7 +131,7 @@ public class AdminCategoryController {
// 所有一级分类目录
List
<
LitemallCategory
>
l1CatList
=
categoryService
.
queryL1
();
List
<
Map
<
String
,
Object
>>
data
=
new
ArrayList
<>(
l1CatList
.
size
());
for
(
LitemallCategory
category
:
l1CatList
){
for
(
LitemallCategory
category
:
l1CatList
)
{
Map
<
String
,
Object
>
d
=
new
HashMap
<>(
2
);
d
.
put
(
"value"
,
category
.
getId
());
d
.
put
(
"label"
,
category
.
getName
());
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCollectController.java
View file @
a5c2aff4
...
...
@@ -3,16 +3,18 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallCollect
;
import
org.linlinjava.litemall.db.service.LitemallCollectService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -32,8 +34,8 @@ public class AdminCollectController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCommentController.java
View file @
a5c2aff4
...
...
@@ -3,17 +3,15 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallComment
;
import
org.linlinjava.litemall.db.service.LitemallCommentService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -33,8 +31,8 @@ public class AdminCommentController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -48,12 +46,12 @@ public class AdminCommentController {
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallComment
comment
){
if
(
adminId
==
null
){
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallComment
comment
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Integer
id
=
comment
.
getId
();
if
(
id
==
null
){
if
(
id
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
commentService
.
deleteById
(
id
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminDashbordController.java
View file @
a5c2aff4
...
...
@@ -3,14 +3,16 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.service.LitemallGoodsProductService
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallOrderService
;
import
org.linlinjava.litemall.db.service.LitemallGoodsProductService
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -31,8 +33,8 @@ public class AdminDashbordController {
private
LitemallOrderService
orderService
;
@GetMapping
(
""
)
public
Object
info
(
@LoginAdmin
Integer
adminId
){
if
(
adminId
==
null
){
public
Object
info
(
@LoginAdmin
Integer
adminId
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFeedbackController.java
View file @
a5c2aff4
...
...
@@ -3,7 +3,6 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.RegexUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
...
...
@@ -11,10 +10,11 @@ import org.linlinjava.litemall.db.domain.LitemallFeedback;
import
org.linlinjava.litemall.db.service.LitemallFeedbackService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -39,7 +39,7 @@ public class AdminFeedbackController {
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
){
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallFeedback
>
feedbackList
=
feedbackService
.
querySelective
(
userId
,
username
,
page
,
limit
,
sort
,
order
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminFootprintController.java
View file @
a5c2aff4
...
...
@@ -3,16 +3,18 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.LitemallFootprint
;
import
org.linlinjava.litemall.db.service.LitemallFootprintService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -32,8 +34,8 @@ public class AdminFootprintController {
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
limit
,
@Sort
@RequestParam
(
defaultValue
=
"add_time"
)
String
sort
,
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
){
if
(
adminId
==
null
){
@Order
@RequestParam
(
defaultValue
=
"desc"
)
String
order
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGoodsController.java
View file @
a5c2aff4
...
...
@@ -6,11 +6,11 @@ import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import
org.linlinjava.litemall.admin.dao.GoodsAllinone
;
import
org.linlinjava.litemall.admin.util.CatVo
;
import
org.linlinjava.litemall.core.qcode.QCodeService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.validator.Order
;
import
org.linlinjava.litemall.core.validator.Sort
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.TransactionDefinition
;
...
...
@@ -22,8 +22,10 @@ import org.springframework.web.bind.annotation.*;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/goods"
)
...
...
@@ -73,66 +75,66 @@ public class AdminGoodsController {
private
Object
validate
(
GoodsAllinone
goodsAllinone
)
{
LitemallGoods
goods
=
goodsAllinone
.
getGoods
();
String
name
=
goods
.
getName
();
if
(
StringUtils
.
isEmpty
(
name
)){
if
(
StringUtils
.
isEmpty
(
name
))
{
return
ResponseUtil
.
badArgument
();
}
String
goodsSn
=
goods
.
getGoodsSn
();
if
(
StringUtils
.
isEmpty
(
goodsSn
)){
if
(
StringUtils
.
isEmpty
(
goodsSn
))
{
return
ResponseUtil
.
badArgument
();
}
// 品牌商可以不设置,如果设置则需要验证品牌商存在
Integer
brandId
=
goods
.
getBrandId
();
if
(
brandId
!=
null
&&
brandId
!=
0
)
{
if
(
brandId
!=
null
&&
brandId
!=
0
)
{
if
(
brandService
.
findById
(
brandId
)
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
}
// 分类可以不设置,如果设置则需要验证分类存在
Integer
categoryId
=
goods
.
getCategoryId
();
if
(
categoryId
!=
null
&&
categoryId
!=
0
)
{
if
(
categoryId
!=
null
&&
categoryId
!=
0
)
{
if
(
categoryService
.
findById
(
categoryId
)
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
}
LitemallGoodsAttribute
[]
attributes
=
goodsAllinone
.
getAttributes
();
for
(
LitemallGoodsAttribute
attribute
:
attributes
){
for
(
LitemallGoodsAttribute
attribute
:
attributes
)
{
String
attr
=
attribute
.
getAttribute
();
if
(
StringUtils
.
isEmpty
(
attr
)){
if
(
StringUtils
.
isEmpty
(
attr
))
{
return
ResponseUtil
.
badArgument
();
}
String
value
=
attribute
.
getValue
();
if
(
StringUtils
.
isEmpty
(
value
)){
if
(
StringUtils
.
isEmpty
(
value
))
{
return
ResponseUtil
.
badArgument
();
}
}
LitemallGoodsSpecification
[]
specifications
=
goodsAllinone
.
getSpecifications
();
for
(
LitemallGoodsSpecification
specification
:
specifications
){
for
(
LitemallGoodsSpecification
specification
:
specifications
)
{
String
spec
=
specification
.
getSpecification
();
if
(
StringUtils
.
isEmpty
(
spec
)){
if
(
StringUtils
.
isEmpty
(
spec
))
{
return
ResponseUtil
.
badArgument
();
}
String
value
=
specification
.
getValue
();
if
(
StringUtils
.
isEmpty
(
value
)){
if
(
StringUtils
.
isEmpty
(
value
))
{
return
ResponseUtil
.
badArgument
();
}
}
LitemallGoodsProduct
[]
products
=
goodsAllinone
.
getProducts
();
for
(
LitemallGoodsProduct
product
:
products
){
for
(
LitemallGoodsProduct
product
:
products
)
{
Integer
number
=
product
.
getNumber
();
if
(
number
==
null
||
number
<
0
){
if
(
number
==
null
||
number
<
0
)
{
return
ResponseUtil
.
badArgument
();
}
BigDecimal
price
=
product
.
getPrice
();
if
(
price
==
null
){
if
(
price
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
String
[]
productSpecifications
=
product
.
getSpecifications
();
if
(
productSpecifications
.
length
==
0
){
if
(
productSpecifications
.
length
==
0
)
{
return
ResponseUtil
.
badArgument
();
}
}
...
...
@@ -158,7 +160,7 @@ public class AdminGoodsController {
}
Object
error
=
validate
(
goodsAllinone
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
...
...
@@ -178,7 +180,7 @@ public class AdminGoodsController {
goods
.
setShareUrl
(
url
);
// 商品基本信息表litemall_goods
if
(
goodsService
.
updateById
(
goods
)
==
0
){
if
(
goodsService
.
updateById
(
goods
)
==
0
)
{
throw
new
Exception
(
"跟新数据失败"
);
}
...
...
@@ -222,7 +224,7 @@ public class AdminGoodsController {
return
ResponseUtil
.
unlogin
();
}
Integer
id
=
goods
.
getId
();
if
(
id
==
null
){
if
(
id
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
...
...
@@ -253,7 +255,7 @@ public class AdminGoodsController {
}
Object
error
=
validate
(
goodsAllinone
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
...
...
@@ -278,7 +280,7 @@ public class AdminGoodsController {
//将生成的分享图片地址写入数据库
String
url
=
qCodeService
.
createGoodShareImage
(
goods
.
getId
().
toString
(),
goods
.
getPicUrl
(),
goods
.
getName
());
if
(!
StringUtils
.
isEmpty
(
url
))
{
if
(!
StringUtils
.
isEmpty
(
url
))
{
goods
.
setShareUrl
(
url
);
if
(
goodsService
.
updateById
(
goods
)
==
0
)
{
throw
new
Exception
(
"跟新数据失败"
);
...
...
Prev
1
2
3
4
5
…
7
Next
Write
Preview
Supports
Markdown
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