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
6c14c43c
Commit
6c14c43c
authored
Mar 23, 2018
by
Junling Bu
Browse files
V 0.1.0, 项目架构基本完成。
parents
Changes
346
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 346+
files are displayed.
Plain diff
Email patch
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/dao/AdminToken.java
0 → 100644
View file @
6c14c43c
package
org.linlinjava.litemall.admin.dao
;
import
java.time.LocalDateTime
;
public
class
AdminToken
{
private
Integer
userId
;
private
String
token
;
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
String
getToken
()
{
return
token
;
}
public
LocalDateTime
getExpireTime
()
{
return
expireTime
;
}
public
LocalDateTime
getUpdateTime
()
{
return
updateTime
;
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/service/AdminTokenManager.java
0 → 100644
View file @
6c14c43c
package
org.linlinjava.litemall.admin.service
;
import
org.linlinjava.litemall.admin.dao.AdminToken
;
import
org.linlinjava.litemall.db.util.CharUtil
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
AdminTokenManager
{
private
static
Map
<
String
,
AdminToken
>
tokenMap
=
new
HashMap
<>();
private
static
Map
<
Integer
,
AdminToken
>
idMap
=
new
HashMap
<>();
public
static
Integer
getUserId
(
String
token
)
{
AdminToken
userToken
=
tokenMap
.
get
(
token
);
if
(
userToken
==
null
){
return
null
;
}
if
(
userToken
.
getExpireTime
().
isBefore
(
LocalDateTime
.
now
())){
tokenMap
.
remove
(
token
);
idMap
.
remove
(
userToken
.
getUserId
());
return
null
;
}
return
userToken
.
getUserId
();
}
public
static
AdminToken
generateToken
(
Integer
id
){
AdminToken
userToken
=
idMap
.
get
(
id
);
if
(
userToken
!=
null
)
{
tokenMap
.
remove
(
userToken
.
getToken
());
idMap
.
remove
(
id
);
}
String
token
=
CharUtil
.
getRandomString
(
32
);
while
(
tokenMap
.
containsKey
(
token
))
{
token
=
CharUtil
.
getRandomString
(
32
);
}
LocalDateTime
update
=
LocalDateTime
.
now
();
LocalDateTime
expire
=
update
.
plusDays
(
1
);
userToken
=
new
AdminToken
();
userToken
.
setToken
(
token
);
userToken
.
setUpdateTime
(
update
);
userToken
.
setExpireTime
(
expire
);
userToken
.
setUserId
(
id
);
tokenMap
.
put
(
token
,
userToken
);
idMap
.
put
(
id
,
userToken
);
return
userToken
;
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallAd
;
import
org.linlinjava.litemall.db.service.LitemallAdService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/ad"
)
public
class
AdController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AdController
.
class
);
@Autowired
private
LitemallAdService
adService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
name
,
String
content
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallAd
>
adList
=
adService
.
querySelective
(
name
,
content
,
page
,
limit
,
sort
,
order
);
int
total
=
adService
.
countSelective
(
name
,
content
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
adList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
adService
.
add
(
ad
);
return
ResponseUtil
.
ok
(
ad
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallAd
brand
=
adService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
brand
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
adService
.
updateById
(
ad
);
return
ResponseUtil
.
ok
(
ad
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAd
ad
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
adService
.
deleteById
(
ad
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AddressController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallAddress
;
import
org.linlinjava.litemall.db.service.LitemallAddressService
;
import
org.linlinjava.litemall.db.service.LitemallRegionService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/address"
)
public
class
AddressController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AddressController
.
class
);
@Autowired
private
LitemallAddressService
addressService
;
@Autowired
private
LitemallRegionService
regionService
;
private
Map
<
String
,
Object
>
toVo
(
LitemallAddress
address
){
Map
<
String
,
Object
>
addressVo
=
new
HashMap
<>();
addressVo
.
put
(
"id"
,
address
.
getId
());
addressVo
.
put
(
"userId"
,
address
.
getUserId
());
addressVo
.
put
(
"name"
,
address
.
getName
());
addressVo
.
put
(
"mobile"
,
address
.
getMobile
());
addressVo
.
put
(
"isDefault"
,
address
.
getIsDefault
());
addressVo
.
put
(
"provinceId"
,
address
.
getProvinceId
());
addressVo
.
put
(
"cityId"
,
address
.
getCityId
());
addressVo
.
put
(
"areaId"
,
address
.
getAreaId
());
addressVo
.
put
(
"address"
,
address
.
getAddress
());
String
province
=
regionService
.
findById
(
address
.
getProvinceId
()).
getName
();
String
city
=
regionService
.
findById
(
address
.
getCityId
()).
getName
();
String
area
=
regionService
.
findById
(
address
.
getAreaId
()).
getName
();
addressVo
.
put
(
"province"
,
province
);
addressVo
.
put
(
"city"
,
city
);
addressVo
.
put
(
"area"
,
area
);
return
addressVo
;
}
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
Integer
userId
,
String
name
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
List
<
LitemallAddress
>
addressList
=
addressService
.
querySelective
(
userId
,
name
,
page
,
limit
,
sort
,
order
);
int
total
=
addressService
.
countSelective
(
userId
,
name
,
page
,
limit
,
sort
,
order
);
List
<
Map
<
String
,
Object
>>
addressVoList
=
new
ArrayList
<>(
addressList
.
size
());
for
(
LitemallAddress
address
:
addressList
){
Map
<
String
,
Object
>
addressVo
=
toVo
(
address
);
addressVoList
.
add
(
addressVo
);
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
addressVoList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAddress
address
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
addressService
.
add
(
address
);
Map
<
String
,
Object
>
addressVo
=
toVo
(
address
);
return
ResponseUtil
.
ok
(
addressVo
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
addressId
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
LitemallAddress
address
=
addressService
.
findById
(
addressId
);
Map
<
String
,
Object
>
addressVo
=
toVo
(
address
);
return
ResponseUtil
.
ok
(
addressVo
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAddress
address
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
addressService
.
updateById
(
address
);
Map
<
String
,
Object
>
addressVo
=
toVo
(
address
);
return
ResponseUtil
.
ok
(
addressVo
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAddress
address
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
addressService
.
delete
(
address
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminController.java
0 → 100644
View file @
6c14c43c
package
org.linlinjava.litemall.admin.web
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.admin.service.AdminTokenManager
;
import
org.linlinjava.litemall.db.domain.LitemallAdmin
;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/admin"
)
public
class
AdminController
{
@Autowired
private
LitemallAdminService
adminService
;
@GetMapping
(
"/info"
)
public
Object
info
(
String
token
){
Integer
adminId
=
AdminTokenManager
.
getUserId
(
token
);
if
(
adminId
==
null
){
return
ResponseUtil
.
badArgumentValue
();
}
LitemallAdmin
admin
=
adminService
.
findById
(
adminId
);
if
(
admin
==
null
){
return
ResponseUtil
.
badArgumentValue
();
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"name"
,
admin
.
getUsername
());
data
.
put
(
"avatar"
,
admin
.
getAvatar
());
// 目前roles不支持,这里简单设置admin
List
<
String
>
roles
=
new
ArrayList
<>();
roles
.
add
(
"admin"
);
data
.
put
(
"roles"
,
roles
);
data
.
put
(
"introduction"
,
"admin introduction"
);
return
ResponseUtil
.
ok
(
data
);
}
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
username
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallAdmin
>
adminList
=
adminService
.
querySelective
(
username
,
page
,
limit
,
sort
,
order
);
int
total
=
adminService
.
countSelective
(
username
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
adminList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
adminService
.
add
(
admin
);
return
ResponseUtil
.
ok
(
admin
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallAdmin
admin
=
adminService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
admin
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
adminService
.
updateById
(
admin
);
return
ResponseUtil
.
ok
(
admin
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallAdmin
admin
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
Integer
anotherAdminId
=
admin
.
getId
();
if
(
anotherAdminId
.
intValue
()
==
1
){
return
ResponseUtil
.
fail
(
403
,
"超级用户不能删除"
);
}
adminService
.
deleteById
(
anotherAdminId
);
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AuthController.java
0 → 100644
View file @
6c14c43c
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.service.AdminTokenManager
;
import
org.linlinjava.litemall.db.domain.LitemallAdmin
;
import
org.linlinjava.litemall.db.service.LitemallAdminService
;
import
org.linlinjava.litemall.db.util.JacksonUtil
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
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
@RequestMapping
(
"/admin/login"
)
public
class
AuthController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AuthController
.
class
);
@Autowired
private
LitemallAdminService
adminService
;
/*
* { username : value, password : value }
*/
@PostMapping
(
"/login"
)
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
)){
return
ResponseUtil
.
badArgument
();
}
List
<
LitemallAdmin
>
adminList
=
adminService
.
findAdmin
(
username
,
password
);
Assert
.
state
(
adminList
.
size
()
<
2
,
"同一个用户名存在两个账户"
);
if
(
adminList
.
size
()
==
0
){
return
ResponseUtil
.
badArgumentValue
();
}
LitemallAdmin
admin
=
adminList
.
get
(
0
);
Integer
adminId
=
admin
.
getId
();
// token
AdminToken
adminToken
=
AdminTokenManager
.
generateToken
(
adminId
);
return
ResponseUtil
.
ok
(
adminToken
.
getToken
());
}
/*
*
*/
@PostMapping
(
"/logout"
)
public
Object
login
(
@LoginAdmin
Integer
adminId
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/BrandController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallBrand
;
import
org.linlinjava.litemall.db.service.LitemallBrandService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/brand"
)
public
class
BrandController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
BrandController
.
class
);
@Autowired
private
LitemallBrandService
brandService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
id
,
String
name
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallBrand
>
brandList
=
brandService
.
querySelective
(
id
,
name
,
page
,
limit
,
sort
,
order
);
int
total
=
brandService
.
countSelective
(
id
,
name
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
brandList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
brandService
.
add
(
brand
);
return
ResponseUtil
.
ok
(
brand
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallBrand
brand
=
brandService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
brand
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
brandService
.
updateById
(
brand
);
return
ResponseUtil
.
ok
(
brand
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallBrand
brand
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
brandService
.
deleteById
(
brand
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/CartController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallCart
;
import
org.linlinjava.litemall.db.service.LitemallCartService
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallProductService
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/cart"
)
public
class
CartController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
CartController
.
class
);
@Autowired
private
LitemallCartService
cartService
;
@Autowired
private
LitemallUserService
userService
;
@Autowired
private
LitemallGoodsService
goodsService
;
@Autowired
private
LitemallProductService
productService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
Integer
userId
,
Integer
goodsId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
List
<
LitemallCart
>
cartList
=
cartService
.
querySelective
(
userId
,
goodsId
,
page
,
limit
,
sort
,
order
);
int
total
=
cartService
.
countSelective
(
userId
,
goodsId
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
cartList
);
return
ResponseUtil
.
ok
(
data
);
}
/*
* 目前的逻辑不支持管理员创建
*/
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCart
cart
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
return
ResponseUtil
.
fail501
();
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
LitemallCart
cart
=
cartService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
cart
);
}
/*
* 目前的逻辑不支持管理员创建
*/
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCart
cart
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
return
ResponseUtil
.
fail501
();
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCart
cart
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
cartService
.
deleteById
(
cart
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/CategoryController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallCategory
;
import
org.linlinjava.litemall.db.service.LitemallCategoryService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/category"
)
public
class
CategoryController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
CategoryController
.
class
);
@Autowired
private
LitemallCategoryService
categoryService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
id
,
String
name
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallCategory
>
collectList
=
categoryService
.
querySelective
(
id
,
name
,
page
,
limit
,
sort
,
order
);
int
total
=
categoryService
.
countSelective
(
id
,
name
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
collectList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
categoryService
.
add
(
category
);
return
ResponseUtil
.
ok
();
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallCategory
category
=
categoryService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
category
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
categoryService
.
updateById
(
category
);
return
ResponseUtil
.
ok
();
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCategory
category
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
categoryService
.
deleteById
(
category
.
getId
());
return
ResponseUtil
.
ok
();
}
@GetMapping
(
"/l1"
)
public
Object
catL1
(
@LoginAdmin
Integer
adminId
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
// 所有一级分类目录
List
<
LitemallCategory
>
l1CatList
=
categoryService
.
queryL1
();
HashMap
<
Integer
,
String
>
data
=
new
HashMap
<>(
l1CatList
.
size
());
for
(
LitemallCategory
category
:
l1CatList
){
data
.
put
(
category
.
getId
(),
category
.
getName
());
}
return
ResponseUtil
.
ok
(
data
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/CollectController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallCollect
;
import
org.linlinjava.litemall.db.service.LitemallCollectService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/collect"
)
public
class
CollectController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
CollectController
.
class
);
@Autowired
private
LitemallCollectService
collectService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
userId
,
String
valueId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallCollect
>
collectList
=
collectService
.
querySelective
(
userId
,
valueId
,
page
,
limit
,
sort
,
order
);
int
total
=
collectService
.
countSelective
(
userId
,
valueId
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
collectList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCollect
collect
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
return
ResponseUtil
.
unsupport
();
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallCollect
collect
=
collectService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
collect
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCollect
collect
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
collectService
.
updateById
(
collect
);
return
ResponseUtil
.
ok
();
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallCollect
collect
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
collectService
.
deleteById
(
collect
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/CommentController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallComment
;
import
org.linlinjava.litemall.db.service.LitemallCommentService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/comment"
)
public
class
CommentController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
CommentController
.
class
);
@Autowired
private
LitemallCommentService
commentService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
userId
,
String
valueId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallComment
>
brandList
=
commentService
.
querySelective
(
userId
,
valueId
,
page
,
limit
,
sort
,
order
);
int
total
=
commentService
.
countSelective
(
userId
,
valueId
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
brandList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallComment
comment
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
commentService
.
add
(
comment
);
return
ResponseUtil
.
ok
(
comment
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallComment
comment
=
commentService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
comment
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallComment
comment
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
commentService
.
updateById
(
comment
);
return
ResponseUtil
.
ok
(
comment
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallComment
comment
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
commentService
.
deleteById
(
comment
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/DashbordController.java
0 → 100644
View file @
6c14c43c
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.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallOrderService
;
import
org.linlinjava.litemall.db.service.LitemallProductService
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/dashboard"
)
public
class
DashbordController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
DashbordController
.
class
);
@Autowired
private
LitemallUserService
userService
;
@Autowired
private
LitemallGoodsService
goodsService
;
@Autowired
private
LitemallProductService
productService
;
@Autowired
private
LitemallOrderService
orderService
;
@GetMapping
(
""
)
public
Object
info
(
@LoginAdmin
Integer
adminId
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
int
userTotal
=
userService
.
count
();
int
goodsTotal
=
goodsService
.
count
();
int
productTotal
=
productService
.
count
();
int
orderTotal
=
orderService
.
count
();
Map
<
String
,
Integer
>
data
=
new
HashMap
<>();
data
.
put
(
"userTotal"
,
userTotal
);
data
.
put
(
"goodsTotal"
,
goodsTotal
);
data
.
put
(
"productTotal"
,
productTotal
);
data
.
put
(
"orderTotal"
,
orderTotal
);
return
ResponseUtil
.
ok
(
data
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/FootprintController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallFootprint
;
import
org.linlinjava.litemall.db.service.LitemallFootprintService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/footprint"
)
public
class
FootprintController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
FootprintController
.
class
);
@Autowired
private
LitemallFootprintService
footprintService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
userId
,
String
goodsId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallFootprint
>
footprintList
=
footprintService
.
querySelective
(
userId
,
goodsId
,
page
,
limit
,
sort
,
order
);
int
total
=
footprintService
.
countSelective
(
userId
,
goodsId
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
footprintList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallFootprint
footprint
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
return
ResponseUtil
.
unsupport
();
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallFootprint
footprint
=
footprintService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
footprint
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallFootprint
footprint
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
footprintService
.
updateById
(
footprint
);
return
ResponseUtil
.
ok
();
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallFootprint
footprint
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
footprintService
.
deleteById
(
footprint
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/GoodsAttributeController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallGoodsAttribute
;
import
org.linlinjava.litemall.db.service.LitemallGoodsAttributeService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/goods-attribute"
)
public
class
GoodsAttributeController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
GoodsAttributeController
.
class
);
@Autowired
private
LitemallGoodsAttributeService
goodsAttributeService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
Integer
goodsId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallGoodsAttribute
>
goodsAttributeList
=
goodsAttributeService
.
querySelective
(
goodsId
,
page
,
limit
,
sort
,
order
);
int
total
=
goodsAttributeService
.
countSelective
(
goodsId
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
goodsAttributeList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoodsAttribute
goodsAttribute
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsAttributeService
.
add
(
goodsAttribute
);
return
ResponseUtil
.
ok
(
goodsAttribute
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallGoodsAttribute
goodsAttribute
=
goodsAttributeService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
goodsAttribute
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoodsAttribute
goodsAttribute
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsAttributeService
.
updateById
(
goodsAttribute
);
return
ResponseUtil
.
ok
(
goodsAttribute
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoodsAttribute
goodsAttribute
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsAttributeService
.
deleteById
(
goodsAttribute
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/GoodsController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallGoods
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/goods"
)
public
class
GoodsController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
GoodsController
.
class
);
@Autowired
private
LitemallGoodsService
goodsService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
goodsSn
,
String
name
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallGoods
>
goodsList
=
goodsService
.
querySelective
(
goodsSn
,
name
,
page
,
limit
,
sort
,
order
);
int
total
=
goodsService
.
countSelective
(
goodsSn
,
name
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
goodsList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoods
goods
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsService
.
add
(
goods
);
return
ResponseUtil
.
ok
(
goods
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallGoods
goods
=
goodsService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
goods
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoods
goods
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsService
.
updateById
(
goods
);
return
ResponseUtil
.
ok
(
goods
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoods
goods
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsService
.
deleteById
(
goods
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/GoodsSpecificationController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallGoodsSpecification
;
import
org.linlinjava.litemall.db.service.LitemallGoodsSpecificationService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/goods-specification"
)
public
class
GoodsSpecificationController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
GoodsSpecificationController
.
class
);
@Autowired
private
LitemallGoodsSpecificationService
goodsSpecificationService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
Integer
goodsId
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallGoodsSpecification
>
goodsSpecificationList
=
goodsSpecificationService
.
querySelective
(
goodsId
,
page
,
limit
,
sort
,
order
);
int
total
=
goodsSpecificationService
.
countSelective
(
goodsId
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
goodsSpecificationList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoodsSpecification
goodsSpecification
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsSpecificationService
.
add
(
goodsSpecification
);
return
ResponseUtil
.
ok
(
goodsSpecification
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallGoodsSpecification
goodsSpecification
=
goodsSpecificationService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
goodsSpecification
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoodsSpecification
goodsSpecification
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsSpecificationService
.
updateById
(
goodsSpecification
);
return
ResponseUtil
.
ok
(
goodsSpecification
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoodsSpecification
goodsSpecification
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
goodsSpecificationService
.
deleteById
(
goodsSpecification
.
getId
());
return
ResponseUtil
.
ok
();
}
@GetMapping
(
"/volist"
)
public
Object
volist
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
Object
goodsSpecificationVoList
=
goodsSpecificationService
.
getSpecificationVoList
(
id
);
return
ResponseUtil
.
ok
(
goodsSpecificationVoList
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/HistoryController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallSearchHistory
;
import
org.linlinjava.litemall.db.service.LitemallSearchHistoryService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/history"
)
public
class
HistoryController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
HistoryController
.
class
);
@Autowired
private
LitemallSearchHistoryService
searchHistoryService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
userId
,
String
keyword
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallSearchHistory
>
footprintList
=
searchHistoryService
.
querySelective
(
userId
,
keyword
,
page
,
limit
,
sort
,
order
);
int
total
=
searchHistoryService
.
countSelective
(
userId
,
keyword
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
footprintList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallSearchHistory
history
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
return
ResponseUtil
.
fail501
();
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallSearchHistory
history
=
searchHistoryService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
history
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallSearchHistory
history
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
searchHistoryService
.
updateById
(
history
);
return
ResponseUtil
.
ok
();
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallSearchHistory
history
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
searchHistoryService
.
deleteById
(
history
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/IndexController.java
0 → 100644
View file @
6c14c43c
package
org.linlinjava.litemall.admin.web
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/admin/index"
)
public
class
IndexController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
IndexController
.
class
);
@RequestMapping
(
"/index"
)
public
Object
index
(){
return
ResponseUtil
.
ok
(
"hello world"
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/IssueController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallIssue
;
import
org.linlinjava.litemall.db.service.LitemallIssueService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/issue"
)
public
class
IssueController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
IssueController
.
class
);
@Autowired
private
LitemallIssueService
issueService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
question
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallIssue
>
issueList
=
issueService
.
querySelective
(
question
,
page
,
limit
,
sort
,
order
);
int
total
=
issueService
.
countSelective
(
question
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
issueList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
brand
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
issueService
.
add
(
brand
);
return
ResponseUtil
.
ok
(
brand
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallIssue
brand
=
issueService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
brand
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
brand
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
issueService
.
updateById
(
brand
);
return
ResponseUtil
.
ok
(
brand
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
brand
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
issueService
.
deleteById
(
brand
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/KeywordController.java
0 → 100644
View file @
6c14c43c
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.db.domain.LitemallKeyword
;
import
org.linlinjava.litemall.db.service.LitemallKeywordService
;
import
org.linlinjava.litemall.db.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/keyword"
)
public
class
KeywordController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
KeywordController
.
class
);
@Autowired
private
LitemallKeywordService
keywordService
;
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
String
keyword
,
String
url
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallKeyword
>
brandList
=
keywordService
.
querySelective
(
keyword
,
url
,
page
,
limit
,
sort
,
order
);
int
total
=
keywordService
.
countSelective
(
keyword
,
url
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
brandList
);
return
ResponseUtil
.
ok
(
data
);
}
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallKeyword
keywords
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
keywordService
.
add
(
keywords
);
return
ResponseUtil
.
ok
(
keywords
);
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
if
(
id
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallKeyword
brand
=
keywordService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
brand
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallKeyword
keywords
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
keywordService
.
updateById
(
keywords
);
return
ResponseUtil
.
ok
(
keywords
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallKeyword
brand
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
keywordService
.
deleteById
(
brand
.
getId
());
return
ResponseUtil
.
ok
();
}
}
Prev
1
2
3
4
5
6
7
…
18
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