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
b68151cb
Unverified
Commit
b68151cb
authored
Jul 13, 2018
by
Menethil
Committed by
GitHub
Jul 13, 2018
Browse files
Merge pull request #1 from linlinjava/master
update
parents
126d027a
02679509
Changes
251
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminAdminController.java
View file @
b68151cb
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.db.service.LitemallAdminService;
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.db.service.LitemallAdminService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -72,6 +73,7 @@ public class AdminAdminController {
...
@@ -72,6 +73,7 @@ public class AdminAdminController {
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
String
encodedPassword
=
encoder
.
encode
(
rawPassword
);
String
encodedPassword
=
encoder
.
encode
(
rawPassword
);
admin
.
setPassword
(
encodedPassword
);
admin
.
setPassword
(
encodedPassword
);
admin
.
setAddTime
(
LocalDateTime
.
now
());
adminService
.
add
(
admin
);
adminService
.
add
(
admin
);
return
ResponseUtil
.
ok
(
admin
);
return
ResponseUtil
.
ok
(
admin
);
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminBrandController.java
View file @
b68151cb
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -45,6 +46,7 @@ public class AdminBrandController {
...
@@ -45,6 +46,7 @@ public class AdminBrandController {
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
brand
.
setAddTime
(
LocalDateTime
.
now
());
brandService
.
add
(
brand
);
brandService
.
add
(
brand
);
return
ResponseUtil
.
ok
(
brand
);
return
ResponseUtil
.
ok
(
brand
);
}
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCartController.java
deleted
100644 → 0
View file @
126d027a
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.core.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
AdminCartController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AdminCartController
.
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/AdminCategoryController.java
View file @
b68151cb
...
@@ -3,12 +3,15 @@ package org.linlinjava.litemall.admin.web;
...
@@ -3,12 +3,15 @@ package org.linlinjava.litemall.admin.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.admin.util.CatVo
;
import
org.linlinjava.litemall.db.domain.LitemallCategory
;
import
org.linlinjava.litemall.db.domain.LitemallCategory
;
import
org.linlinjava.litemall.db.service.LitemallCategoryService
;
import
org.linlinjava.litemall.db.service.LitemallCategoryService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -45,6 +48,7 @@ public class AdminCategoryController {
...
@@ -45,6 +48,7 @@ public class AdminCategoryController {
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
category
.
setAddTime
(
LocalDateTime
.
now
());
categoryService
.
add
(
category
);
categoryService
.
add
(
category
);
return
ResponseUtil
.
ok
();
return
ResponseUtil
.
ok
();
}
}
...
@@ -89,11 +93,13 @@ public class AdminCategoryController {
...
@@ -89,11 +93,13 @@ public class AdminCategoryController {
// 所有一级分类目录
// 所有一级分类目录
List
<
LitemallCategory
>
l1CatList
=
categoryService
.
queryL1
();
List
<
LitemallCategory
>
l1CatList
=
categoryService
.
queryL1
();
HashMap
<
Integer
,
String
>
data
=
new
HashMap
<>(
l1CatList
.
size
());
List
<
Map
<
String
,
Object
>
>
data
=
new
ArrayList
<>(
l1CatList
.
size
());
for
(
LitemallCategory
category
:
l1CatList
){
for
(
LitemallCategory
category
:
l1CatList
){
data
.
put
(
category
.
getId
(),
category
.
getName
());
Map
<
String
,
Object
>
d
=
new
HashMap
<>(
2
);
d
.
put
(
"value"
,
category
.
getId
());
d
.
put
(
"label"
,
category
.
getName
());
data
.
add
(
d
);
}
}
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
ok
(
data
);
}
}
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminCommentController.java
View file @
b68151cb
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -45,6 +46,7 @@ public class AdminCommentController {
...
@@ -45,6 +46,7 @@ public class AdminCommentController {
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
comment
.
setAddTime
(
LocalDateTime
.
now
());
commentService
.
add
(
comment
);
commentService
.
add
(
comment
);
return
ResponseUtil
.
ok
(
comment
);
return
ResponseUtil
.
ok
(
comment
);
}
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGoodsAttributeController.java
deleted
100644 → 0
View file @
126d027a
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.core.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
AdminGoodsAttributeController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AdminGoodsAttributeController
.
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/AdminGoodsController.java
View file @
b68151cb
package
org.linlinjava.litemall.admin.web
;
package
org.linlinjava.litemall.admin.web
;
import
io.swagger.models.auth.In
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.db.domain.LitemallGoods
;
import
org.linlinjava.litemall.admin.dao.GoodsAllinone
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.admin.dao.Product
;
import
org.linlinjava.litemall.admin.util.CatVo
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.TransactionDefinition
;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.support.DefaultTransactionDefinition
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.
util.HashMap
;
import
java.
math.BigDecimal
;
import
java.
u
ti
l.List
;
import
java.ti
me.LocalDateTime
;
import
java.util.
Map
;
import
java.util.
*
;
@RestController
@RestController
@RequestMapping
(
"/admin/goods"
)
@RequestMapping
(
"/admin/goods"
)
public
class
AdminGoodsController
{
public
class
AdminGoodsController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AdminGoodsController
.
class
);
private
final
Log
logger
=
LogFactory
.
getLog
(
AdminGoodsController
.
class
);
@Autowired
private
PlatformTransactionManager
txManager
;
@Autowired
@Autowired
private
LitemallGoodsService
goodsService
;
private
LitemallGoodsService
goodsService
;
@Autowired
private
LitemallGoodsSpecificationService
specificationService
;
@Autowired
private
LitemallGoodsAttributeService
attributeService
;
@Autowired
private
LitemallProductService
productService
;
@Autowired
private
LitemallCategoryService
categoryService
;
@Autowired
private
LitemallBrandService
brandService
;
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
Object
list
(
@LoginAdmin
Integer
adminId
,
public
Object
list
(
@LoginAdmin
Integer
adminId
,
...
@@ -40,45 +61,234 @@ public class AdminGoodsController {
...
@@ -40,45 +61,234 @@ public class AdminGoodsController {
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
ok
(
data
);
}
}
@PostMapping
(
"/create"
)
/*
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoods
goods
){
* TODO
* 目前商品修改的逻辑是
* 1. 更新litemall_goods表
* 2. 逻辑删除litemall_goods_specification、litemall_goods_attribute、litemall_product
* 3. 添加litemall_goods_specification、litemall_goods_attribute、litemall_product
*
* 这里商品三个表的数据采用删除再跟新的策略是因为
* 商品编辑页面,管理员可以添加删除商品规格、添加删除商品属性,因此这里仅仅更新表是不可能的,
* 因此这里只能删除所有旧的数据,然后添加新的数据
*/
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
GoodsAllinone
goodsAllinone
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
goodsService
.
add
(
goods
);
return
ResponseUtil
.
ok
(
goods
);
LitemallGoods
goods
=
goodsAllinone
.
getGoods
();
LitemallGoodsAttribute
[]
attributes
=
goodsAllinone
.
getAttributes
();
LitemallGoodsSpecification
[]
specifications
=
goodsAllinone
.
getSpecifications
();
LitemallProduct
[]
products
=
goodsAllinone
.
getProducts
();
// 开启事务管理
DefaultTransactionDefinition
def
=
new
DefaultTransactionDefinition
();
def
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRED
);
TransactionStatus
status
=
txManager
.
getTransaction
(
def
);
try
{
// 商品基本信息表litemall_goods
goodsService
.
updateById
(
goods
);
Integer
gid
=
goods
.
getId
();
specificationService
.
deleteByGid
(
gid
);
attributeService
.
deleteByGid
(
gid
);
productService
.
deleteByGid
(
gid
);
// 商品规格表litemall_goods_specification
Map
<
String
,
Integer
>
specIds
=
new
HashMap
<>();
for
(
LitemallGoodsSpecification
specification
:
specifications
){
specification
.
setGoodsId
(
goods
.
getId
());
specification
.
setAddTime
(
LocalDateTime
.
now
());
specificationService
.
add
(
specification
);
specIds
.
put
(
specification
.
getValue
(),
specification
.
getId
());
}
// 商品参数表litemall_goods_attribute
for
(
LitemallGoodsAttribute
attribute
:
attributes
){
attribute
.
setGoodsId
(
goods
.
getId
());
attribute
.
setAddTime
(
LocalDateTime
.
now
());
attributeService
.
add
(
attribute
);
}
// 商品货品表litemall_product
for
(
LitemallProduct
product
:
products
){
product
.
setGoodsId
(
goods
.
getId
());
product
.
setAddTime
(
LocalDateTime
.
now
());
productService
.
add
(
product
);
}
}
catch
(
Exception
ex
)
{
txManager
.
rollback
(
status
);
logger
.
error
(
"系统内部错误"
,
ex
);
}
txManager
.
commit
(
status
);
return
ResponseUtil
.
ok
();
}
}
@
Ge
tMapping
(
"/
read
"
)
@
Pos
tMapping
(
"/
delete
"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoods
goods
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
if
(
id
==
null
){
// 开启事务管理
return
ResponseUtil
.
badArgument
();
DefaultTransactionDefinition
def
=
new
DefaultTransactionDefinition
();
}
def
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRED
);
TransactionStatus
status
=
txManager
.
getTransaction
(
def
);
try
{
LitemallGoods
goods
=
goodsService
.
findById
(
id
);
Integer
gid
=
goods
.
getId
();
return
ResponseUtil
.
ok
(
goods
);
goodsService
.
deleteById
(
gid
);
specificationService
.
deleteByGid
(
gid
);
attributeService
.
deleteByGid
(
gid
);
productService
.
deleteByGid
(
gid
);
}
catch
(
Exception
ex
)
{
txManager
.
rollback
(
status
);
logger
.
error
(
"系统内部错误"
,
ex
);
}
txManager
.
commit
(
status
);
return
ResponseUtil
.
ok
();
}
}
@PostMapping
(
"/
upd
ate"
)
@PostMapping
(
"/
cre
ate"
)
public
Object
upd
ate
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoods
goods
){
public
Object
cre
ate
(
@LoginAdmin
Integer
adminId
,
@RequestBody
GoodsAllinone
goodsAllinone
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
goodsService
.
updateById
(
goods
);
return
ResponseUtil
.
ok
(
goods
);
LitemallGoods
goods
=
goodsAllinone
.
getGoods
();
LitemallGoodsAttribute
[]
attributes
=
goodsAllinone
.
getAttributes
();
LitemallGoodsSpecification
[]
specifications
=
goodsAllinone
.
getSpecifications
();
LitemallProduct
[]
products
=
goodsAllinone
.
getProducts
();
String
name
=
goods
.
getName
();
if
(
goodsService
.
checkExistByName
(
name
)){
return
ResponseUtil
.
fail
(
403
,
"商品名已经存在"
);
}
// 开启事务管理
DefaultTransactionDefinition
def
=
new
DefaultTransactionDefinition
();
def
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRED
);
TransactionStatus
status
=
txManager
.
getTransaction
(
def
);
try
{
// 商品基本信息表litemall_goods
goods
.
setAddTime
(
LocalDateTime
.
now
());
goodsService
.
add
(
goods
);
// 商品规格表litemall_goods_specification
Map
<
String
,
Integer
>
specIds
=
new
HashMap
<>();
for
(
LitemallGoodsSpecification
specification
:
specifications
){
specification
.
setGoodsId
(
goods
.
getId
());
specification
.
setAddTime
(
LocalDateTime
.
now
());
specificationService
.
add
(
specification
);
specIds
.
put
(
specification
.
getValue
(),
specification
.
getId
());
}
// 商品参数表litemall_goods_attribute
for
(
LitemallGoodsAttribute
attribute
:
attributes
){
attribute
.
setGoodsId
(
goods
.
getId
());
attribute
.
setAddTime
(
LocalDateTime
.
now
());
attributeService
.
add
(
attribute
);
}
// 商品货品表litemall_product
for
(
LitemallProduct
product
:
products
){
product
.
setGoodsId
(
goods
.
getId
());
product
.
setAddTime
(
LocalDateTime
.
now
());
productService
.
add
(
product
);
}
}
catch
(
Exception
ex
)
{
txManager
.
rollback
(
status
);
logger
.
error
(
"系统内部错误"
,
ex
);
}
txManager
.
commit
(
status
);
return
ResponseUtil
.
ok
();
}
@GetMapping
(
"/catAndBrand"
)
public
Object
list2
(
@LoginAdmin
Integer
adminId
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
// http://element-cn.eleme.io/#/zh-CN/component/cascader
// 管理员设置“所属分类”
List
<
LitemallCategory
>
l1CatList
=
categoryService
.
queryL1
();
List
<
CatVo
>
categoryList
=
new
ArrayList
<>(
l1CatList
.
size
());
for
(
LitemallCategory
l1
:
l1CatList
){
CatVo
l1CatVo
=
new
CatVo
();
l1CatVo
.
setValue
(
l1
.
getId
());
l1CatVo
.
setLabel
(
l1
.
getName
());
List
<
LitemallCategory
>
l2CatList
=
categoryService
.
queryByPid
(
l1
.
getId
());
List
<
CatVo
>
children
=
new
ArrayList
<>(
l2CatList
.
size
());
for
(
LitemallCategory
l2
:
l2CatList
)
{
CatVo
l2CatVo
=
new
CatVo
();
l2CatVo
.
setValue
(
l2
.
getId
());
l2CatVo
.
setLabel
(
l2
.
getName
());
children
.
add
(
l2CatVo
);
}
l1CatVo
.
setChildren
(
children
);
categoryList
.
add
(
l1CatVo
);
}
// http://element-cn.eleme.io/#/zh-CN/component/select
// 管理员设置“所属品牌商”
List
<
LitemallBrand
>
list
=
brandService
.
all
();
List
<
Map
<
String
,
Object
>>
brandList
=
new
ArrayList
<>(
l1CatList
.
size
());
for
(
LitemallBrand
brand
:
list
){
Map
<
String
,
Object
>
b
=
new
HashMap
<>(
2
);
b
.
put
(
"value"
,
brand
.
getId
());
b
.
put
(
"label"
,
brand
.
getName
());
brandList
.
add
(
b
);
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"categoryList"
,
categoryList
);
data
.
put
(
"brandList"
,
brandList
);
return
ResponseUtil
.
ok
(
data
);
}
}
@
Pos
tMapping
(
"/de
lete
"
)
@
Ge
tMapping
(
"/de
tail
"
)
public
Object
de
lete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallGoods
goods
)
{
public
Object
de
tail
(
@LoginAdmin
Integer
adminId
,
Integer
id
)
{
if
(
adminId
==
null
){
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
goodsService
.
deleteById
(
goods
.
getId
());
return
ResponseUtil
.
ok
();
if
(
id
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
LitemallGoods
goods
=
goodsService
.
findById
(
id
);
List
<
LitemallProduct
>
products
=
productService
.
queryByGid
(
id
);
List
<
LitemallGoodsSpecification
>
specifications
=
specificationService
.
queryByGid
(
id
);
List
<
LitemallGoodsAttribute
>
attributes
=
attributeService
.
queryByGid
(
id
);
Integer
categoryId
=
goods
.
getCategoryId
();
LitemallCategory
category
=
categoryService
.
findById
(
categoryId
);
Integer
[]
categoryIds
=
new
Integer
[]{};
if
(
category
!=
null
)
{
Integer
parentCategoryId
=
category
.
getPid
();
categoryIds
=
new
Integer
[]
{
parentCategoryId
,
categoryId
};
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"goods"
,
goods
);
data
.
put
(
"specifications"
,
specifications
);
data
.
put
(
"products"
,
products
);
data
.
put
(
"attributes"
,
attributes
);
data
.
put
(
"categoryIds"
,
categoryIds
);
return
ResponseUtil
.
ok
(
data
);
}
}
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminGoodsSpecificationController.java
deleted
100644 → 0
View file @
126d027a
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.core.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
AdminGoodsSpecificationController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AdminGoodsSpecificationController
.
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/AdminHistoryController.java
View file @
b68151cb
...
@@ -43,9 +43,9 @@ public class AdminHistoryController {
...
@@ -43,9 +43,9 @@ public class AdminHistoryController {
@PostMapping
(
"/create"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallSearchHistory
history
){
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallSearchHistory
history
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
return
ResponseUtil
.
unlogin
();
}
}
return
ResponseUtil
.
fail501
();
return
ResponseUtil
.
unsupport
();
}
}
@GetMapping
(
"/read"
)
@GetMapping
(
"/read"
)
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminIssueController.java
View file @
b68151cb
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -41,12 +42,13 @@ public class AdminIssueController {
...
@@ -41,12 +42,13 @@ public class AdminIssueController {
}
}
@PostMapping
(
"/create"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
brand
){
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
issue
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
issueService
.
add
(
brand
);
issue
.
setAddTime
(
LocalDateTime
.
now
());
return
ResponseUtil
.
ok
(
brand
);
issueService
.
add
(
issue
);
return
ResponseUtil
.
ok
(
issue
);
}
}
@GetMapping
(
"/read"
)
@GetMapping
(
"/read"
)
...
@@ -59,25 +61,25 @@ public class AdminIssueController {
...
@@ -59,25 +61,25 @@ public class AdminIssueController {
return
ResponseUtil
.
badArgument
();
return
ResponseUtil
.
badArgument
();
}
}
LitemallIssue
brand
=
issueService
.
findById
(
id
);
LitemallIssue
issue
=
issueService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
brand
);
return
ResponseUtil
.
ok
(
issue
);
}
}
@PostMapping
(
"/update"
)
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
brand
){
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
issue
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
issueService
.
updateById
(
brand
);
issueService
.
updateById
(
issue
);
return
ResponseUtil
.
ok
(
brand
);
return
ResponseUtil
.
ok
(
issue
);
}
}
@PostMapping
(
"/delete"
)
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
brand
){
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallIssue
issue
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
issueService
.
deleteById
(
brand
.
getId
());
issueService
.
deleteById
(
issue
.
getId
());
return
ResponseUtil
.
ok
();
return
ResponseUtil
.
ok
();
}
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminKeywordController.java
View file @
b68151cb
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -45,6 +46,7 @@ public class AdminKeywordController {
...
@@ -45,6 +46,7 @@ public class AdminKeywordController {
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
keywords
.
setAddTime
(
LocalDateTime
.
now
());
keywordService
.
add
(
keywords
);
keywordService
.
add
(
keywords
);
return
ResponseUtil
.
ok
(
keywords
);
return
ResponseUtil
.
ok
(
keywords
);
}
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminOrderController.java
View file @
b68151cb
...
@@ -21,6 +21,7 @@ import org.springframework.transaction.TransactionStatus;
...
@@ -21,6 +21,7 @@ import org.springframework.transaction.TransactionStatus;
import
org.springframework.transaction.support.DefaultTransactionDefinition
;
import
org.springframework.transaction.support.DefaultTransactionDefinition
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -48,7 +49,7 @@ public class AdminOrderController {
...
@@ -48,7 +49,7 @@ public class AdminOrderController {
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
String
sort
,
String
order
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
return
ResponseUtil
.
unlogin
();
}
}
List
<
LitemallOrder
>
orderList
=
orderService
.
querySelective
(
userId
,
orderSn
,
page
,
limit
,
sort
,
order
);
List
<
LitemallOrder
>
orderList
=
orderService
.
querySelective
(
userId
,
orderSn
,
page
,
limit
,
sort
,
order
);
int
total
=
orderService
.
countSelective
(
userId
,
orderSn
,
page
,
limit
,
sort
,
order
);
int
total
=
orderService
.
countSelective
(
userId
,
orderSn
,
page
,
limit
,
sort
,
order
);
...
@@ -60,73 +61,6 @@ public class AdminOrderController {
...
@@ -60,73 +61,6 @@ public class AdminOrderController {
return
ResponseUtil
.
ok
(
data
);
return
ResponseUtil
.
ok
(
data
);
}
}
/*
* 目前的逻辑不支持管理员创建
*/
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallOrder
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
return
ResponseUtil
.
unsupport
();
}
@GetMapping
(
"/read"
)
public
Object
read
(
@LoginAdmin
Integer
adminId
,
Integer
id
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
}
LitemallOrder
order
=
orderService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
order
);
}
/*
* 目前仅仅支持管理员设置发货相关的信息
*/
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallOrder
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
Integer
orderId
=
order
.
getId
();
if
(
orderId
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallOrder
litemallOrder
=
orderService
.
findById
(
orderId
);
if
(
litemallOrder
==
null
){
return
ResponseUtil
.
badArgumentValue
();
}
if
(
OrderUtil
.
isPayStatus
(
litemallOrder
)
||
OrderUtil
.
isShipStatus
(
litemallOrder
)){
LitemallOrder
newOrder
=
new
LitemallOrder
();
newOrder
.
setId
(
orderId
);
newOrder
.
setShipChannel
(
order
.
getShipChannel
());
newOrder
.
setShipSn
(
order
.
getOrderSn
());
newOrder
.
setShipStartTime
(
order
.
getShipStartTime
());
newOrder
.
setShipEndTime
(
order
.
getShipEndTime
());
newOrder
.
setOrderStatus
(
OrderUtil
.
STATUS_SHIP
);
orderService
.
update
(
newOrder
);
}
else
{
return
ResponseUtil
.
badArgumentValue
();
}
litemallOrder
=
orderService
.
findById
(
orderId
);
return
ResponseUtil
.
ok
(
litemallOrder
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallOrder
order
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
return
ResponseUtil
.
unsupport
();
}
/**
/**
* 订单退款确认
* 订单退款确认
* 1. 检测当前订单是否能够退款确认
* 1. 检测当前订单是否能够退款确认
...
@@ -139,12 +73,13 @@ public class AdminOrderController {
...
@@ -139,12 +73,13 @@ public class AdminOrderController {
* 成功则 { errno: 0, errmsg: '成功' }
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
* 失败则 { errno: XXX, errmsg: XXX }
*/
*/
@PostMapping
(
"refund
Confirm
"
)
@PostMapping
(
"refund"
)
public
Object
refund
Confirm
(
@LoginAdmin
Integer
adminId
,
@RequestBody
String
body
)
{
public
Object
refund
(
@LoginAdmin
Integer
adminId
,
@RequestBody
String
body
)
{
if
(
adminId
==
null
)
{
if
(
adminId
==
null
)
{
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
Integer
orderId
=
JacksonUtil
.
parseInteger
(
body
,
"orderId"
);
Integer
orderId
=
JacksonUtil
.
parseInteger
(
body
,
"orderId"
);
Integer
refundMoney
=
JacksonUtil
.
parseInteger
(
body
,
"refundMoney"
);
if
(
orderId
==
null
)
{
if
(
orderId
==
null
)
{
return
ResponseUtil
.
badArgument
();
return
ResponseUtil
.
badArgument
();
}
}
...
@@ -153,13 +88,14 @@ public class AdminOrderController {
...
@@ -153,13 +88,14 @@ public class AdminOrderController {
if
(
order
==
null
)
{
if
(
order
==
null
)
{
return
ResponseUtil
.
badArgument
();
return
ResponseUtil
.
badArgument
();
}
}
if
(!
order
.
getUserId
().
equals
(
adminId
))
{
if
(
order
.
getActualPrice
().
compareTo
(
new
BigDecimal
(
refundMoney
))
!=
0
){
return
ResponseUtil
.
badArgumentValue
();
return
ResponseUtil
.
badArgumentValue
();
}
}
OrderHandleOption
handleOption
=
OrderUtil
.
build
(
order
);
// 如果订单不是退款状态,则不能退款
if
(!
handleOption
.
isRefund
(
))
{
if
(!
order
.
getOrderStatus
().
equals
(
OrderUtil
.
STATUS_REFUND
))
{
return
ResponseUtil
.
fail
(
403
,
"订单不能
取消
"
);
return
ResponseUtil
.
fail
(
403
,
"订单不能
确认收货
"
);
}
}
// 开启事务管理
// 开启事务管理
...
@@ -176,8 +112,8 @@ public class AdminOrderController {
...
@@ -176,8 +112,8 @@ public class AdminOrderController {
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
Integer
productId
=
orderGoods
.
getProductId
();
Integer
productId
=
orderGoods
.
getProductId
();
LitemallProduct
product
=
productService
.
findById
(
productId
);
LitemallProduct
product
=
productService
.
findById
(
productId
);
Integer
number
=
product
.
get
Goods
Number
()
+
orderGoods
.
getNumber
();
Integer
number
=
product
.
getNumber
()
+
orderGoods
.
getNumber
();
product
.
set
Goods
Number
(
number
);
product
.
setNumber
(
number
);
productService
.
updateById
(
product
);
productService
.
updateById
(
product
);
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
...
@@ -217,9 +153,6 @@ public class AdminOrderController {
...
@@ -217,9 +153,6 @@ public class AdminOrderController {
if
(
order
==
null
)
{
if
(
order
==
null
)
{
return
ResponseUtil
.
badArgument
();
return
ResponseUtil
.
badArgument
();
}
}
if
(!
order
.
getUserId
().
equals
(
adminId
))
{
return
ResponseUtil
.
badArgumentValue
();
}
// 如果订单不是已付款状态,则不能发货
// 如果订单不是已付款状态,则不能发货
if
(!
order
.
getOrderStatus
().
equals
(
OrderUtil
.
STATUS_PAY
))
{
if
(!
order
.
getOrderStatus
().
equals
(
OrderUtil
.
STATUS_PAY
))
{
...
@@ -229,7 +162,7 @@ public class AdminOrderController {
...
@@ -229,7 +162,7 @@ public class AdminOrderController {
order
.
setOrderStatus
(
OrderUtil
.
STATUS_SHIP
);
order
.
setOrderStatus
(
OrderUtil
.
STATUS_SHIP
);
order
.
setShipSn
(
shipSn
);
order
.
setShipSn
(
shipSn
);
order
.
setShipChannel
(
shipChannel
);
order
.
setShipChannel
(
shipChannel
);
order
.
setShip
Start
Time
(
LocalDateTime
.
now
());
order
.
setShipTime
(
LocalDateTime
.
now
());
orderService
.
update
(
order
);
orderService
.
update
(
order
);
return
ResponseUtil
.
ok
();
return
ResponseUtil
.
ok
();
...
@@ -274,8 +207,8 @@ public class AdminOrderController {
...
@@ -274,8 +207,8 @@ public class AdminOrderController {
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
for
(
LitemallOrderGoods
orderGoods
:
orderGoodsList
)
{
Integer
productId
=
orderGoods
.
getProductId
();
Integer
productId
=
orderGoods
.
getProductId
();
LitemallProduct
product
=
productService
.
findById
(
productId
);
LitemallProduct
product
=
productService
.
findById
(
productId
);
Integer
number
=
product
.
get
Goods
Number
()
+
orderGoods
.
getNumber
();
Integer
number
=
product
.
getNumber
()
+
orderGoods
.
getNumber
();
product
.
set
Goods
Number
(
number
);
product
.
setNumber
(
number
);
productService
.
updateById
(
product
);
productService
.
updateById
(
product
);
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
...
@@ -298,7 +231,7 @@ public class AdminOrderController {
...
@@ -298,7 +231,7 @@ public class AdminOrderController {
* 早点清理未付款情况,这里八天再确认是可以的。
* 早点清理未付款情况,这里八天再确认是可以的。
*
*
* TODO
* TODO
* 目前自动确认是基于管理后台管理员所设置的商品快递
到达
时间,见orderService.queryUnconfirm。
* 目前自动确认是基于管理后台管理员所设置的商品快递时间,见orderService.queryUnconfirm。
* 那么在实际业务上有可能存在商品寄出以后商品因为一些原因快递最终没有到达,
* 那么在实际业务上有可能存在商品寄出以后商品因为一些原因快递最终没有到达,
* 也就是商品快递失败而shipEndTime一直是空的情况,因此这里业务可能需要扩展,以防止订单一直
* 也就是商品快递失败而shipEndTime一直是空的情况,因此这里业务可能需要扩展,以防止订单一直
* 处于发货状态。
* 处于发货状态。
...
@@ -309,9 +242,9 @@ public class AdminOrderController {
...
@@ -309,9 +242,9 @@ public class AdminOrderController {
List
<
LitemallOrder
>
orderList
=
orderService
.
queryUnconfirm
();
List
<
LitemallOrder
>
orderList
=
orderService
.
queryUnconfirm
();
for
(
LitemallOrder
order
:
orderList
){
for
(
LitemallOrder
order
:
orderList
){
LocalDateTime
ship
End
=
order
.
getShip
End
Time
();
LocalDateTime
ship
=
order
.
getShipTime
();
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
expired
=
ship
End
.
plusDays
(
7
);
LocalDateTime
expired
=
ship
.
plusDays
(
7
);
if
(
expired
.
isAfter
(
now
)){
if
(
expired
.
isAfter
(
now
)){
continue
;
continue
;
}
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminProductController.java
deleted
100644 → 0
View file @
126d027a
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.domain.LitemallProduct
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallGoodsSpecificationService
;
import
org.linlinjava.litemall.db.service.LitemallProductService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/product"
)
public
class
AdminProductController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AdminProductController
.
class
);
@Autowired
private
LitemallProductService
productService
;
@Autowired
private
LitemallGoodsService
goodsService
;
@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
<
LitemallProduct
>
productList
=
productService
.
querySelective
(
goodsId
,
page
,
limit
,
sort
,
order
);
int
total
=
productService
.
countSelective
(
goodsId
,
page
,
limit
,
sort
,
order
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"total"
,
total
);
data
.
put
(
"items"
,
productList
);
return
ResponseUtil
.
ok
(
data
);
}
/**
*
* @param adminId
* @param litemallProduct
* @return
*/
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallProduct
litemallProduct
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
Integer
goodsId
=
litemallProduct
.
getGoodsId
();
if
(
goodsId
==
null
){
return
ResponseUtil
.
badArgument
();
}
LitemallGoods
goods
=
goodsService
.
findById
(
goodsId
);
if
(
goods
==
null
){
return
ResponseUtil
.
badArgumentValue
();
}
List
<
LitemallProduct
>
productList
=
productService
.
queryByGid
(
goodsId
);
if
(
productList
.
size
()
!=
0
){
return
ResponseUtil
.
badArgumentValue
();
}
Integer
[]
goodsSpecificationIds
=
goodsSpecificationService
.
queryIdsByGid
(
goodsId
);
if
(
goodsSpecificationIds
.
length
==
0
)
{
return
ResponseUtil
.
serious
();
}
LitemallProduct
product
=
new
LitemallProduct
();
product
.
setGoodsId
(
goodsId
);
product
.
setGoodsNumber
(
0
);
product
.
setRetailPrice
(
new
BigDecimal
(
0.00
));
product
.
setGoodsSpecificationIds
(
goodsSpecificationIds
);
productService
.
add
(
product
);
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
();
}
LitemallProduct
product
=
productService
.
findById
(
id
);
return
ResponseUtil
.
ok
(
product
);
}
@PostMapping
(
"/update"
)
public
Object
update
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallProduct
product
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
productService
.
updateById
(
product
);
return
ResponseUtil
.
ok
(
product
);
}
@PostMapping
(
"/delete"
)
public
Object
delete
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallProduct
product
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
productService
.
deleteById
(
product
.
getId
());
return
ResponseUtil
.
ok
();
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminStatController.java
0 → 100644
View file @
b68151cb
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.StatVo
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.dao.StatMapper
;
import
org.linlinjava.litemall.db.service.LitemallOrderService
;
import
org.linlinjava.litemall.db.service.StatService
;
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/stat"
)
public
class
AdminStatController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AdminStatController
.
class
);
@Autowired
private
StatService
statService
;
@GetMapping
(
"/user"
)
public
Object
statUser
(
@LoginAdmin
Integer
adminId
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
Map
>
rows
=
statService
.
statUser
();
String
[]
columns
=
new
String
[]{
"day"
,
"users"
};
StatVo
statVo
=
new
StatVo
();
statVo
.
setColumns
(
columns
);
statVo
.
setRows
(
rows
);
return
ResponseUtil
.
ok
(
statVo
);
}
@GetMapping
(
"/order"
)
public
Object
statOrder
(
@LoginAdmin
Integer
adminId
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
Map
>
rows
=
statService
.
statOrder
();
String
[]
columns
=
new
String
[]{
"day"
,
"orders"
,
"customers"
,
"amount"
,
"pcr"
};
StatVo
statVo
=
new
StatVo
();
statVo
.
setColumns
(
columns
);
statVo
.
setRows
(
rows
);
return
ResponseUtil
.
ok
(
statVo
);
}
@GetMapping
(
"/goods"
)
public
Object
statGoods
(
@LoginAdmin
Integer
adminId
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
}
List
<
Map
>
rows
=
statService
.
statGoods
();
String
[]
columns
=
new
String
[]{
"day"
,
"orders"
,
"products"
,
"amount"
};
StatVo
statVo
=
new
StatVo
();
statVo
.
setColumns
(
columns
);
statVo
.
setRows
(
rows
);
return
ResponseUtil
.
ok
(
statVo
);
}
}
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminTopicController.java
View file @
b68151cb
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
...
@@ -9,6 +9,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -45,6 +46,7 @@ public class AdminTopicController {
...
@@ -45,6 +46,7 @@ public class AdminTopicController {
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
unlogin
();
return
ResponseUtil
.
unlogin
();
}
}
topic
.
setAddTime
(
LocalDateTime
.
now
());
topicService
.
add
(
topic
);
topicService
.
add
(
topic
);
return
ResponseUtil
.
ok
(
topic
);
return
ResponseUtil
.
ok
(
topic
);
}
}
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.java
View file @
b68151cb
...
@@ -10,6 +10,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
...
@@ -10,6 +10,7 @@ import org.linlinjava.litemall.core.util.ResponseUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -29,7 +30,7 @@ public class AdminUserController {
...
@@ -29,7 +30,7 @@ public class AdminUserController {
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
String
sort
,
String
order
){
String
sort
,
String
order
){
if
(
adminId
==
null
){
if
(
adminId
==
null
){
return
ResponseUtil
.
fail401
();
return
ResponseUtil
.
unlogin
();
}
}
List
<
LitemallUser
>
userList
=
userService
.
querySelective
(
username
,
mobile
,
page
,
limit
,
sort
,
order
);
List
<
LitemallUser
>
userList
=
userService
.
querySelective
(
username
,
mobile
,
page
,
limit
,
sort
,
order
);
int
total
=
userService
.
countSeletive
(
username
,
mobile
,
page
,
limit
,
sort
,
order
);
int
total
=
userService
.
countSeletive
(
username
,
mobile
,
page
,
limit
,
sort
,
order
);
...
@@ -43,7 +44,7 @@ public class AdminUserController {
...
@@ -43,7 +44,7 @@ public class AdminUserController {
@GetMapping
(
"/username"
)
@GetMapping
(
"/username"
)
public
Object
username
(
String
username
){
public
Object
username
(
String
username
){
if
(
StringUtil
.
isEmpty
(
username
)){
if
(
StringUtil
.
isEmpty
(
username
)){
return
ResponseUtil
.
fail402
();
return
ResponseUtil
.
badArgument
();
}
}
int
total
=
userService
.
countSeletive
(
username
,
null
,
null
,
null
,
null
,
null
);
int
total
=
userService
.
countSeletive
(
username
,
null
,
null
,
null
,
null
,
null
);
...
@@ -57,7 +58,7 @@ public class AdminUserController {
...
@@ -57,7 +58,7 @@ public class AdminUserController {
@PostMapping
(
"/create"
)
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallUser
user
){
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallUser
user
){
logger
.
debug
(
user
);
logger
.
debug
(
user
);
user
.
setAddTime
(
LocalDateTime
.
now
());
userService
.
add
(
user
);
userService
.
add
(
user
);
return
ResponseUtil
.
ok
(
user
);
return
ResponseUtil
.
ok
(
user
);
}
}
...
...
litemall-admin-api/src/main/resources/application-dep.properties
View file @
b68151cb
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.username
=
litemall
spring.datasource.druid.username
=
litemall
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.initial-size
=
5
0
spring.datasource.druid.initial-size
=
1
0
spring.datasource.druid.max-active
=
10
0
spring.datasource.druid.max-active
=
5
0
spring.datasource.druid.min-idle
=
2
0
spring.datasource.druid.min-idle
=
1
0
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
...
...
litemall-admin-api/src/main/resources/application-dev.properties
View file @
b68151cb
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.username
=
litemall
spring.datasource.druid.username
=
litemall
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.initial-size
=
5
0
spring.datasource.druid.initial-size
=
1
0
spring.datasource.druid.max-active
=
10
0
spring.datasource.druid.max-active
=
5
0
spring.datasource.druid.min-idle
=
2
0
spring.datasource.druid.min-idle
=
1
0
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
...
...
litemall-admin-api/src/main/resources/application-prod.properties
View file @
b68151cb
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
...
@@ -7,9 +7,9 @@ spring.datasource.druid.url=jdbc:mysql://localhost:3306/litemall?useUnicode=true
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.druid.username
=
litemall
spring.datasource.druid.username
=
litemall
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.password
=
litemall123456
spring.datasource.druid.initial-size
=
5
0
spring.datasource.druid.initial-size
=
1
0
spring.datasource.druid.max-active
=
10
0
spring.datasource.druid.max-active
=
5
0
spring.datasource.druid.min-idle
=
2
0
spring.datasource.druid.min-idle
=
1
0
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.max-wait
=
60000
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.pool-prepared-statements
=
true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
spring.datasource.druid.max-pool-prepared-statement-per-connection-size
=
20
...
...
litemall-admin/package.json
View file @
b68151cb
...
@@ -13,9 +13,10 @@
...
@@ -13,9 +13,10 @@
"test"
:
"npm run lint"
"test"
:
"npm run lint"
},
},
"dependencies"
:
{
"dependencies"
:
{
"@tinymce/tinymce-vue"
:
"^1.0.8"
,
"axios"
:
"0.17.1"
,
"axios"
:
"0.17.1"
,
"clipboard"
:
"1.7.1"
,
"clipboard"
:
"1.7.1"
,
"echarts"
:
"
3.8.5
"
,
"echarts"
:
"
^4.1.0
"
,
"element-ui"
:
"2.0.8"
,
"element-ui"
:
"2.0.8"
,
"file-saver"
:
"1.3.3"
,
"file-saver"
:
"1.3.3"
,
"font-awesome"
:
"4.7.0"
,
"font-awesome"
:
"4.7.0"
,
...
@@ -24,13 +25,13 @@
...
@@ -24,13 +25,13 @@
"normalize.css"
:
"7.0.0"
,
"normalize.css"
:
"7.0.0"
,
"nprogress"
:
"0.2.0"
,
"nprogress"
:
"0.2.0"
,
"screenfull"
:
"3.3.2"
,
"screenfull"
:
"3.3.2"
,
"v-charts"
:
"^1.16.19"
,
"vue"
:
"2.5.10"
,
"vue"
:
"2.5.10"
,
"vue-count-to"
:
"1.0.13"
,
"vue-count-to"
:
"1.0.13"
,
"vue-router"
:
"3.0.1"
,
"vue-router"
:
"3.0.1"
,
"vue-splitpane"
:
"1.0.2"
,
"vue-splitpane"
:
"1.0.2"
,
"vuex"
:
"3.0.1"
,
"vuex"
:
"3.0.1"
,
"xlsx"
:
"^0.11.16"
,
"xlsx"
:
"^0.11.16"
"@tinymce/tinymce-vue"
:
"1.0.8"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"autoprefixer"
:
"7.2.3"
,
"autoprefixer"
:
"7.2.3"
,
...
...
Prev
1
2
3
4
5
6
…
13
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