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
Mall4j
Commits
8aeef4e0
Commit
8aeef4e0
authored
Aug 31, 2023
by
gu-jinli1118
Browse files
20230831
parent
646116b0
Pipeline
#31
failed with stages
in 0 seconds
Changes
677
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
17 of 677+
files are displayed.
Plain diff
Email patch
yami-shop-admin/src/main/java/com/yami/shop/admin/controller/ShopDetailController.java
0 → 100644
View file @
8aeef4e0
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package
com.yami.shop.admin.controller
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.yami.shop.bean.model.ShopDetail
;
import
com.yami.shop.bean.param.ShopDetailParam
;
import
com.yami.shop.common.util.PageParam
;
import
com.yami.shop.security.admin.util.SecurityUtils
;
import
com.yami.shop.service.ShopDetailService
;
import
cn.hutool.core.bean.BeanUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.yami.shop.common.response.ServerResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
jakarta.validation.Valid
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
*
* @author lgh on 2018/08/29.
*/
@RestController
@RequestMapping
(
"/shop/shopDetail"
)
public
class
ShopDetailController
{
@Autowired
private
ShopDetailService
shopDetailService
;
/**
* 修改分销开关
*/
@PutMapping
(
"/isDistribution"
)
public
ServerResponseEntity
<
Void
>
updateIsDistribution
(
@RequestParam
Integer
isDistribution
){
ShopDetail
shopDetail
=
new
ShopDetail
();
shopDetail
.
setShopId
(
SecurityUtils
.
getSysUser
().
getShopId
());
shopDetail
.
setIsDistribution
(
isDistribution
);
shopDetailService
.
updateById
(
shopDetail
);
// 更新完成后删除缓存
shopDetailService
.
removeShopDetailCacheByShopId
(
shopDetail
.
getShopId
());
return
ServerResponseEntity
.
success
();
}
/**
* 获取信息
*/
@GetMapping
(
"/info"
)
@PreAuthorize
(
"@pms.hasPermission('shop:shopDetail:info')"
)
public
ServerResponseEntity
<
ShopDetail
>
info
(){
ShopDetail
shopDetail
=
shopDetailService
.
getShopDetailByShopId
(
SecurityUtils
.
getSysUser
().
getShopId
());
return
ServerResponseEntity
.
success
(
shopDetail
);
}
/**
* 分页获取
*/
@GetMapping
(
"/page"
)
@PreAuthorize
(
"@pms.hasPermission('shop:shopDetail:page')"
)
public
ServerResponseEntity
<
IPage
<
ShopDetail
>>
page
(
ShopDetail
shopDetail
,
PageParam
<
ShopDetail
>
page
){
IPage
<
ShopDetail
>
shopDetails
=
shopDetailService
.
page
(
page
,
new
LambdaQueryWrapper
<
ShopDetail
>()
.
like
(
StrUtil
.
isNotBlank
(
shopDetail
.
getShopName
()),
ShopDetail:
:
getShopName
,
shopDetail
.
getShopName
())
.
orderByDesc
(
ShopDetail:
:
getShopId
));
return
ServerResponseEntity
.
success
(
shopDetails
);
}
/**
* 获取信息
*/
@GetMapping
(
"/info/{shopId}"
)
@PreAuthorize
(
"@pms.hasPermission('shop:shopDetail:info')"
)
public
ServerResponseEntity
<
ShopDetail
>
info
(
@PathVariable
(
"shopId"
)
Long
shopId
){
ShopDetail
shopDetail
=
shopDetailService
.
getShopDetailByShopId
(
shopId
);
// 店铺图片
return
ServerResponseEntity
.
success
(
shopDetail
);
}
/**
* 保存
*/
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('shop:shopDetail:save')"
)
public
ServerResponseEntity
<
Void
>
save
(
@Valid
ShopDetailParam
shopDetailParam
){
ShopDetail
shopDetail
=
BeanUtil
.
copyProperties
(
shopDetailParam
,
ShopDetail
.
class
);
shopDetail
.
setCreateTime
(
new
Date
());
shopDetail
.
setShopStatus
(
1
);
shopDetailService
.
save
(
shopDetail
);
return
ServerResponseEntity
.
success
();
}
/**
* 修改
*/
@PutMapping
@PreAuthorize
(
"@pms.hasPermission('shop:shopDetail:update')"
)
public
ServerResponseEntity
<
Void
>
update
(
@Valid
ShopDetailParam
shopDetailParam
){
ShopDetail
daShopDetail
=
shopDetailService
.
getShopDetailByShopId
(
shopDetailParam
.
getShopId
());
ShopDetail
shopDetail
=
BeanUtil
.
copyProperties
(
shopDetailParam
,
ShopDetail
.
class
);
shopDetail
.
setUpdateTime
(
new
Date
());
shopDetailService
.
updateShopDetail
(
shopDetail
,
daShopDetail
);
return
ServerResponseEntity
.
success
();
}
/**
* 删除
*/
@DeleteMapping
(
"/{id}"
)
@PreAuthorize
(
"@pms.hasPermission('shop:shopDetail:delete')"
)
public
ServerResponseEntity
<
Void
>
delete
(
@PathVariable
Long
id
){
shopDetailService
.
deleteShopDetailByShopId
(
id
);
return
ServerResponseEntity
.
success
();
}
/**
* 更新店铺状态
*/
@PutMapping
(
"/shopStatus"
)
@PreAuthorize
(
"@pms.hasPermission('shop:shopDetail:shopStatus')"
)
public
ServerResponseEntity
<
Void
>
shopStatus
(
@RequestParam
Long
shopId
,
@RequestParam
Integer
shopStatus
){
ShopDetail
shopDetail
=
new
ShopDetail
();
shopDetail
.
setShopId
(
shopId
);
shopDetail
.
setShopStatus
(
shopStatus
);
shopDetailService
.
updateById
(
shopDetail
);
// 更新完成后删除缓存
shopDetailService
.
removeShopDetailCacheByShopId
(
shopDetail
.
getShopId
());
return
ServerResponseEntity
.
success
();
}
/**
* 获取所有的店铺名称
*/
@GetMapping
(
"/listShopName"
)
public
ServerResponseEntity
<
List
<
ShopDetail
>>
listShopName
(){
List
<
ShopDetail
>
list
=
shopDetailService
.
list
().
stream
().
map
((
dbShopDetail
)
->{
ShopDetail
shopDetail
=
new
ShopDetail
();
shopDetail
.
setShopId
(
dbShopDetail
.
getShopId
());
shopDetail
.
setShopName
(
dbShopDetail
.
getShopName
());
return
shopDetail
;
}).
collect
(
Collectors
.
toList
());
return
ServerResponseEntity
.
success
(
list
);
}
}
yami-shop-admin/src/main/java/com/yami/shop/admin/controller/SpecController.java
0 → 100644
View file @
8aeef4e0
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package
com.yami.shop.admin.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.yami.shop.bean.enums.ProdPropRule
;
import
com.yami.shop.bean.model.ProdProp
;
import
com.yami.shop.bean.model.ProdPropValue
;
import
com.yami.shop.common.exception.YamiShopBindException
;
import
com.yami.shop.common.util.PageParam
;
import
com.yami.shop.security.admin.util.SecurityUtils
;
import
com.yami.shop.service.ProdPropService
;
import
com.yami.shop.service.ProdPropValueService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.yami.shop.common.response.ServerResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
jakarta.validation.Valid
;
import
java.util.List
;
import
java.util.Objects
;
/**
* 规格管理
*
* @author lgh
*/
@RestController
@RequestMapping
(
"/prod/spec"
)
public
class
SpecController
{
@Autowired
private
ProdPropService
prodPropService
;
@Autowired
private
ProdPropValueService
prodPropValueService
;
/**
* 分页获取
*/
@GetMapping
(
"/page"
)
@PreAuthorize
(
"@pms.hasPermission('prod:spec:page')"
)
public
ServerResponseEntity
<
IPage
<
ProdProp
>>
page
(
ProdProp
prodProp
,
PageParam
<
ProdProp
>
page
)
{
prodProp
.
setRule
(
ProdPropRule
.
SPEC
.
value
());
prodProp
.
setShopId
(
SecurityUtils
.
getSysUser
().
getShopId
());
IPage
<
ProdProp
>
list
=
prodPropService
.
pagePropAndValue
(
prodProp
,
page
);
return
ServerResponseEntity
.
success
(
list
);
}
/**
* 获取所有的规格
*/
@GetMapping
(
"/list"
)
public
ServerResponseEntity
<
List
<
ProdProp
>>
list
()
{
List
<
ProdProp
>
list
=
prodPropService
.
list
(
new
LambdaQueryWrapper
<
ProdProp
>().
eq
(
ProdProp:
:
getRule
,
ProdPropRule
.
SPEC
.
value
()).
eq
(
ProdProp:
:
getShopId
,
SecurityUtils
.
getSysUser
().
getShopId
()));
return
ServerResponseEntity
.
success
(
list
);
}
/**
* 根据规格id获取规格值
*/
@GetMapping
(
"/listSpecValue/{specId}"
)
public
ServerResponseEntity
<
List
<
ProdPropValue
>>
listSpecValue
(
@PathVariable
(
"specId"
)
Long
specId
)
{
List
<
ProdPropValue
>
list
=
prodPropValueService
.
list
(
new
LambdaQueryWrapper
<
ProdPropValue
>().
eq
(
ProdPropValue:
:
getPropId
,
specId
));
return
ServerResponseEntity
.
success
(
list
);
}
/**
* 保存
*/
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('prod:spec:save')"
)
public
ServerResponseEntity
<
Void
>
save
(
@Valid
@RequestBody
ProdProp
prodProp
)
{
prodProp
.
setRule
(
ProdPropRule
.
SPEC
.
value
());
prodProp
.
setShopId
(
SecurityUtils
.
getSysUser
().
getShopId
());
prodPropService
.
saveProdPropAndValues
(
prodProp
);
return
ServerResponseEntity
.
success
();
}
/**
* 修改
*/
@PutMapping
@PreAuthorize
(
"@pms.hasPermission('prod:spec:update')"
)
public
ServerResponseEntity
<
Void
>
update
(
@Valid
@RequestBody
ProdProp
prodProp
)
{
ProdProp
dbProdProp
=
prodPropService
.
getById
(
prodProp
.
getPropId
());
if
(!
Objects
.
equals
(
dbProdProp
.
getShopId
(),
SecurityUtils
.
getSysUser
().
getShopId
()))
{
throw
new
YamiShopBindException
(
"没有权限获取该商品规格信息"
);
}
prodProp
.
setRule
(
ProdPropRule
.
SPEC
.
value
());
prodProp
.
setShopId
(
SecurityUtils
.
getSysUser
().
getShopId
());
prodPropService
.
updateProdPropAndValues
(
prodProp
);
return
ServerResponseEntity
.
success
();
}
/**
* 删除
*/
@DeleteMapping
(
"/{id}"
)
@PreAuthorize
(
"@pms.hasPermission('prod:spec:delete')"
)
public
ServerResponseEntity
<
Void
>
delete
(
@PathVariable
Long
id
)
{
prodPropService
.
deleteProdPropAndValues
(
id
,
ProdPropRule
.
SPEC
.
value
(),
SecurityUtils
.
getSysUser
().
getShopId
());
return
ServerResponseEntity
.
success
();
}
/**
* 根据获取规格值最大的自增id
*/
@GetMapping
(
"/listSpecMaxValueId"
)
public
ServerResponseEntity
<
Long
>
listSpecMaxValueId
()
{
ProdPropValue
propValue
=
prodPropValueService
.
getOne
(
new
LambdaQueryWrapper
<
ProdPropValue
>()
.
orderByDesc
(
ProdPropValue:
:
getValueId
).
last
(
"limit 1"
));
return
ServerResponseEntity
.
success
(
Objects
.
isNull
(
propValue
)
?
0L
:
propValue
.
getValueId
());
}
}
yami-shop-admin/src/main/java/com/yami/shop/admin/controller/TransportController.java
0 → 100644
View file @
8aeef4e0
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package
com.yami.shop.admin.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.yami.shop.bean.model.Transport
;
import
com.yami.shop.common.util.PageParam
;
import
com.yami.shop.security.admin.util.SecurityUtils
;
import
com.yami.shop.service.TransportService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.yami.shop.common.response.ServerResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author lgh on 2018/11/16.
*/
@RestController
@RequestMapping
(
"/shop/transport"
)
public
class
TransportController
{
@Autowired
private
TransportService
transportService
;
/**
* 分页获取
*/
@GetMapping
(
"/page"
)
@PreAuthorize
(
"@pms.hasPermission('shop:transport:page')"
)
public
ServerResponseEntity
<
IPage
<
Transport
>>
page
(
Transport
transport
,
PageParam
<
Transport
>
page
)
{
Long
shopId
=
SecurityUtils
.
getSysUser
().
getShopId
();
IPage
<
Transport
>
transports
=
transportService
.
page
(
page
,
new
LambdaQueryWrapper
<
Transport
>()
.
eq
(
Transport:
:
getShopId
,
shopId
)
.
like
(
StringUtils
.
isNotBlank
(
transport
.
getTransName
()),
Transport:
:
getTransName
,
transport
.
getTransName
()));
return
ServerResponseEntity
.
success
(
transports
);
}
/**
* 获取信息
*/
@GetMapping
(
"/info/{id}"
)
@PreAuthorize
(
"@pms.hasPermission('shop:transport:info')"
)
public
ServerResponseEntity
<
Transport
>
info
(
@PathVariable
(
"id"
)
Long
id
)
{
Transport
transport
=
transportService
.
getTransportAndAllItems
(
id
);
return
ServerResponseEntity
.
success
(
transport
);
}
/**
* 保存
*/
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('shop:transport:save')"
)
public
ServerResponseEntity
<
Void
>
save
(
@RequestBody
Transport
transport
)
{
Long
shopId
=
SecurityUtils
.
getSysUser
().
getShopId
();
transport
.
setShopId
(
shopId
);
Date
createTime
=
new
Date
();
transport
.
setCreateTime
(
createTime
);
transportService
.
insertTransportAndTransfee
(
transport
);
return
ServerResponseEntity
.
success
();
}
/**
* 修改
*/
@PutMapping
@PreAuthorize
(
"@pms.hasPermission('shop:transport:update')"
)
public
ServerResponseEntity
<
Void
>
update
(
@RequestBody
Transport
transport
)
{
transportService
.
updateTransportAndTransfee
(
transport
);
return
ServerResponseEntity
.
success
();
}
/**
* 删除
*/
@DeleteMapping
@PreAuthorize
(
"@pms.hasPermission('shop:transport:delete')"
)
public
ServerResponseEntity
<
Void
>
delete
(
@RequestBody
Long
[]
ids
)
{
transportService
.
deleteTransportAndTransfeeAndTranscity
(
ids
);
// 删除运费模板的缓存
for
(
Long
id
:
ids
)
{
transportService
.
removeTransportAndAllItemsCache
(
id
);
}
return
ServerResponseEntity
.
success
();
}
/**
* 获取运费模板列表
*/
@GetMapping
(
"/list"
)
public
ServerResponseEntity
<
List
<
Transport
>>
list
()
{
Long
shopId
=
SecurityUtils
.
getSysUser
().
getShopId
();
List
<
Transport
>
list
=
transportService
.
list
(
new
LambdaQueryWrapper
<
Transport
>().
eq
(
Transport:
:
getShopId
,
shopId
));
return
ServerResponseEntity
.
success
(
list
);
}
}
yami-shop-admin/src/main/java/com/yami/shop/admin/controller/UserAddrController.java
0 → 100644
View file @
8aeef4e0
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package
com.yami.shop.admin.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.yami.shop.common.util.PageParam
;
import
com.yami.shop.bean.model.UserAddr
;
import
com.yami.shop.common.annotation.SysLog
;
import
com.yami.shop.service.UserAddrService
;
import
lombok.AllArgsConstructor
;
import
com.yami.shop.common.response.ServerResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
jakarta.validation.Valid
;
/**
* 用户地址管理
*
* @author hzm
* @date 2019-04-15 10:49:40
*/
@RestController
@AllArgsConstructor
@RequestMapping
(
"/user/addr"
)
public
class
UserAddrController
{
private
final
UserAddrService
userAddrService
;
/**
* 分页查询
*
* @param page 分页对象
* @param userAddr 用户地址管理
* @return 分页数据
*/
@GetMapping
(
"/page"
)
public
ServerResponseEntity
<
IPage
<
UserAddr
>>
getUserAddrPage
(
PageParam
page
,
UserAddr
userAddr
)
{
return
ServerResponseEntity
.
success
(
userAddrService
.
page
(
page
,
new
LambdaQueryWrapper
<
UserAddr
>()));
}
/**
* 通过id查询用户地址管理
*
* @param addrId id
* @return 单个数据
*/
@GetMapping
(
"/info/{addrId}"
)
public
ServerResponseEntity
<
UserAddr
>
getById
(
@PathVariable
(
"addrId"
)
Long
addrId
)
{
return
ServerResponseEntity
.
success
(
userAddrService
.
getById
(
addrId
));
}
/**
* 新增用户地址管理
*
* @param userAddr 用户地址管理
* @return 是否新增成功
*/
@SysLog
(
"新增用户地址管理"
)
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('user:addr:save')"
)
public
ServerResponseEntity
<
Boolean
>
save
(
@RequestBody
@Valid
UserAddr
userAddr
)
{
return
ServerResponseEntity
.
success
(
userAddrService
.
save
(
userAddr
));
}
/**
* 修改用户地址管理
*
* @param userAddr 用户地址管理
* @return 是否修改成功
*/
@SysLog
(
"修改用户地址管理"
)
@PutMapping
@PreAuthorize
(
"@pms.hasPermission('user:addr:update')"
)
public
ServerResponseEntity
<
Boolean
>
updateById
(
@RequestBody
@Valid
UserAddr
userAddr
)
{
return
ServerResponseEntity
.
success
(
userAddrService
.
updateById
(
userAddr
));
}
/**
* 通过id删除用户地址管理
*
* @param addrId id
* @return 是否删除成功
*/
@SysLog
(
"删除用户地址管理"
)
@DeleteMapping
(
"/{addrId}"
)
@PreAuthorize
(
"@pms.hasPermission('user:addr:delete')"
)
public
ServerResponseEntity
<
Boolean
>
removeById
(
@PathVariable
Long
addrId
)
{
return
ServerResponseEntity
.
success
(
userAddrService
.
removeById
(
addrId
));
}
}
yami-shop-admin/src/main/java/com/yami/shop/admin/controller/UserController.java
0 → 100644
View file @
8aeef4e0
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package
com.yami.shop.admin.controller
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.yami.shop.bean.model.User
;
import
com.yami.shop.common.util.PageParam
;
import
com.yami.shop.service.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.yami.shop.common.response.ServerResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Arrays
;
import
java.util.Date
;
/**
* @author lgh on 2018/10/16.
*/
@RestController
@RequestMapping
(
"/admin/user"
)
public
class
UserController
{
@Autowired
private
UserService
userService
;
/**
* 分页获取
*/
@GetMapping
(
"/page"
)
@PreAuthorize
(
"@pms.hasPermission('admin:user:page')"
)
public
ServerResponseEntity
<
IPage
<
User
>>
page
(
User
user
,
PageParam
<
User
>
page
)
{
IPage
<
User
>
userPage
=
userService
.
page
(
page
,
new
LambdaQueryWrapper
<
User
>()
.
like
(
StrUtil
.
isNotBlank
(
user
.
getNickName
()),
User:
:
getNickName
,
user
.
getNickName
())
.
eq
(
user
.
getStatus
()
!=
null
,
User:
:
getStatus
,
user
.
getStatus
()));
for
(
User
userResult
:
userPage
.
getRecords
())
{
userResult
.
setNickName
(
userResult
.
getNickName
()
==
null
?
""
:
userResult
.
getNickName
());
}
return
ServerResponseEntity
.
success
(
userPage
);
}
/**
* 获取信息
*/
@GetMapping
(
"/info/{userId}"
)
@PreAuthorize
(
"@pms.hasPermission('admin:user:info')"
)
public
ServerResponseEntity
<
User
>
info
(
@PathVariable
(
"userId"
)
String
userId
)
{
User
user
=
userService
.
getById
(
userId
);
user
.
setNickName
(
user
.
getNickName
()
==
null
?
""
:
user
.
getNickName
());
return
ServerResponseEntity
.
success
(
user
);
}
/**
* 修改
*/
@PutMapping
@PreAuthorize
(
"@pms.hasPermission('admin:user:update')"
)
public
ServerResponseEntity
<
Void
>
update
(
@RequestBody
User
user
)
{
user
.
setModifyTime
(
new
Date
());
user
.
setNickName
(
user
.
getNickName
()
==
null
?
""
:
user
.
getNickName
());
userService
.
updateById
(
user
);
return
ServerResponseEntity
.
success
();
}
/**
* 删除
*/
@DeleteMapping
@PreAuthorize
(
"@pms.hasPermission('admin:user:delete')"
)
public
ServerResponseEntity
<
Void
>
delete
(
@RequestBody
String
[]
userIds
)
{
userService
.
removeByIds
(
Arrays
.
asList
(
userIds
));
return
ServerResponseEntity
.
success
();
}
}
yami-shop-admin/src/main/java/com/yami/shop/admin/task/OrderTask.java
0 → 100644
View file @
8aeef4e0
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package
com.yami.shop.admin.task
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.xxl.job.core.handler.annotation.XxlJob
;
import
com.yami.shop.bean.enums.OrderStatus
;
import
com.yami.shop.bean.model.Order
;
import
com.yami.shop.bean.model.OrderItem
;
import
com.yami.shop.service.OrderService
;
import
com.yami.shop.service.ProductService
;
import
com.yami.shop.service.SkuService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author FrozenWatermelon
* 定时任务的配置,请查看xxl-job的java配置文件。
* @see com.yami.shop.admin.config.XxlJobConfig
*/
@Component
(
"orderTask"
)
public
class
OrderTask
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OrderTask
.
class
);
@Autowired
private
OrderService
orderService
;
@Autowired
private
ProductService
productService
;
@Autowired
private
SkuService
skuService
;
@XxlJob
(
"cancelOrder"
)
public
void
cancelOrder
(){
Date
now
=
new
Date
();
logger
.
info
(
"取消超时未支付订单。。。"
);
// 获取30分钟之前未支付的订单
List
<
Order
>
orders
=
orderService
.
listOrderAndOrderItems
(
OrderStatus
.
UNPAY
.
value
(),
DateUtil
.
offsetMinute
(
now
,
-
30
));
if
(
CollectionUtil
.
isEmpty
(
orders
))
{
return
;
}
orderService
.
cancelOrders
(
orders
);
for
(
Order
order
:
orders
)
{
List
<
OrderItem
>
orderItems
=
order
.
getOrderItems
();
for
(
OrderItem
orderItem
:
orderItems
)
{
productService
.
removeProductCacheByProdId
(
orderItem
.
getProdId
());
skuService
.
removeSkuCacheBySkuId
(
orderItem
.
getSkuId
(),
orderItem
.
getProdId
());
}
}
}
/**
* 确认收货
*/
@XxlJob
(
"confirmOrder"
)
public
void
confirmOrder
(){
Date
now
=
new
Date
();
logger
.
info
(
"系统自动确认收货订单。。。"
);
// 获取15天之前未支付的订单
List
<
Order
>
orders
=
orderService
.
listOrderAndOrderItems
(
OrderStatus
.
CONSIGNMENT
.
value
(),
DateUtil
.
offsetDay
(
now
,
-
15
));
if
(
CollectionUtil
.
isEmpty
(
orders
))
{
return
;
}
orderService
.
confirmOrder
(
orders
);
for
(
Order
order
:
orders
)
{
List
<
OrderItem
>
orderItems
=
order
.
getOrderItems
();
for
(
OrderItem
orderItem
:
orderItems
)
{
productService
.
removeProductCacheByProdId
(
orderItem
.
getProdId
());
skuService
.
removeSkuCacheBySkuId
(
orderItem
.
getSkuId
(),
orderItem
.
getProdId
());
}
}
}
}
yami-shop-admin/src/main/resources/admin.properties
0 → 100644
View file @
8aeef4e0
admin.datacenterId
=
1
admin.workerId
=
0
yami-shop-admin/src/main/resources/application-dev.yml
0 → 100644
View file @
8aeef4e0
server
:
port
:
8085
spring
:
datasource
:
url
:
jdbc:mysql://127.0.0.1:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username
:
root
password
:
root
driver-class-name
:
com.mysql.cj.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
hikari
:
minimum-idle
:
0
maximum-pool-size
:
20
idle-timeout
:
10000
auto-commit
:
true
connection-test-query
:
SELECT
1
data
:
redis
:
host
:
127.0.0.1
port
:
6379
database
:
0
logging
:
config
:
classpath:logback/logback-dev.xml
xxl-job
:
accessToken
:
default_token
logPath
:
/data/applogs/xxl-job/jobhandler
admin
:
addresses
:
http://localhost:8080/xxl-job-admin
yami-shop-admin/src/main/resources/application-docker.yml
0 → 100644
View file @
8aeef4e0
server
:
port
:
8085
spring
:
datasource
:
url
:
jdbc:mysql://${MYSQL_HOST:mall4j-mysql}:${MYSQL_PORT:3306}/${MYSQL_DATABASE:yami_shops}?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username
:
${MYSQL_USERNAME:root}
password
:
${MYSQL_PASSWORD:root}
driver-class-name
:
com.mysql.cj.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
hikari
:
minimum-idle
:
0
maximum-pool-size
:
20
idle-timeout
:
25000
auto-commit
:
true
connection-test-query
:
SELECT
1
data
:
redis
:
host
:
${REDIS_HOST}
port
:
${REDIS_PORT}
database
:
${REDIS_DATABASE:0}
logging
:
config
:
classpath:logback/logback-prod.xml
xxl-job
:
accessToken
:
${XXL_JOB_ACCESS_TOKEN:default_token}
logPath
:
${XXL_JOB_LOG_PATH:/data/applogs/xxl-job/jobhandler}
admin
:
addresses
:
${XXL_JOB_ADDRESS:http://mall4j-job:8080/xxl-job-admin}
yami-shop-admin/src/main/resources/application-prod.yml
0 → 100644
View file @
8aeef4e0
server
:
port
:
8111
spring
:
datasource
:
url
:
jdbc:mysql://127.0.0.1:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username
:
root
password
:
root
driver-class-name
:
com.mysql.cj.jdbc.Driver
type
:
com.zaxxer.hikari.HikariDataSource
hikari
:
minimum-idle
:
0
maximum-pool-size
:
20
idle-timeout
:
25000
auto-commit
:
true
connection-test-query
:
SELECT
1
data
:
redis
:
host
:
127.0.0.1
port
:
6379
database
:
${REDIS_DATABASE:0}
logging
:
config
:
classpath:logback/logback-prod.xml
xxl-job
:
accessToken
:
default_token
logPath
:
/data/applogs/xxl-job/jobhandler
admin
:
addresses
:
http://localhost:8080/xxl-job-admin
yami-shop-admin/src/main/resources/application.yml
0 → 100644
View file @
8aeef4e0
spring
:
# 环境 dev|test|prod
profiles
:
active
:
dev
#文件上传设置
servlet
:
multipart
:
max-file-size
:
100MB
max-request-size
:
100MB
enabled
:
true
jackson
:
date-format
:
yyyy-MM-dd HH:mm:ss
time-zone
:
GMT+8
# mybaits-plus配置
mybatis-plus
:
# MyBatis Mapper所对应的XML文件位置
mapper-locations
:
classpath*:/mapper/*Mapper.xml
global-config
:
# 关闭MP3.0自带的banner
banner
:
false
db-config
:
# 主键类型 0:数据库ID自增 1.未定义 2.用户输入 3 id_worker 4.uuid 5.id_worker字符串表示
id-type
:
AUTO
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy
:
NOT_NULL
# 默认数据库表下划线命名
table-underline
:
true
sa-token
:
# token名称 (同时也是cookie名称)
token-name
:
Authorization
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent
:
true
# 在多人登录同一账号时,是否共用一个token(不共用,避免登出时导致其他用户也登出)
is-share
:
false
# token风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
token-style
:
uuid
# 是否输出操作日志
is-log
:
false
yami-shop-admin/src/main/resources/banner.txt
0 → 100644
View file @
8aeef4e0
.----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
| | ____ ____ | || | __ | || | _____ | || | _____ | || | _ _ | || | _____ | |
| ||_ \ / _|| || | / \ | || | |_ _| | || | |_ _| | || | | | | | | || | |_ _| | |
| | | \/ | | || | / /\ \ | || | | | | || | | | | || | | |__| |_ | || | | | | |
| | | |\ /| | | || | / ____ \ | || | | | _ | || | | | _ | || | |____ _| | || | _ | | | |
| | _| |_\/_| |_ | || | _/ / \ \_ | || | _| |__/ | | || | _| |__/ | | || | _| |_ | || | | |_' | | |
| ||_____||_____|| || ||____| |____|| || | |________| | || | |________| | || | |_____| | || | `.___.' | |
| | | || | | || | | || | | || | | || | | |
| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
yami-shop-admin/src/main/resources/logback/logback-dev.xml
0 → 100644
View file @
8aeef4e0
<configuration
scan=
"true"
scanPeriod=
"60 seconds"
debug=
"false"
>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<include
resource=
"org/springframework/boot/logging/logback/console-appender.xml"
/>
<root
level=
"info"
>
<appender-ref
ref=
"CONSOLE"
/>
</root>
<logger
name=
"com.yami.shop"
level=
"debug"
/>
<logger
name=
"springfox.documentation.swagger2"
level=
"off"
/>
<logger
name=
"io.swagger.models.parameters"
level=
"off"
/>
<logger
name=
"springfox.documentation.swagger.readers.operation.OperationImplicitParameterReader"
level=
"off"
/>
<logger
name=
"springfox.documentation.spring.web.readers.operation"
level=
"off"
/>
</configuration>
yami-shop-admin/src/main/resources/logback/logback-prod.xml
0 → 100644
View file @
8aeef4e0
<configuration
scan=
"true"
scanPeriod=
"60 seconds"
debug=
"false"
>
<property
name=
"PROJECT_PATH"
value=
"/opt/projects/yami-shops"
/>
<property
name=
"LOG_FILE_MAX_HISTORY"
value=
"30"
/>
<property
name=
"LOG_FILE_MAX_SIZE"
value=
"50MB"
/>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<include
resource=
"org/springframework/boot/logging/logback/console-appender.xml"
/>
<appender
name=
"DefaultFile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<append>
true
</append>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${FILE_LOG_PATTERN}
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<file>
${PROJECT_PATH}/log/admin.log
</file>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
${logging.level}
</level>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<fileNamePattern>
${PROJECT_PATH}/log/api/%d{yyyy-MM}/api-%d{yyyy-MM-dd}-%i.log.gz
</fileNamePattern>
<maxFileSize>
${LOG_FILE_MAX_SIZE}
</maxFileSize>
<maxHistory>
${LOG_FILE_MAX_HISTORY}
</maxHistory>
</rollingPolicy>
</appender>
<root
level=
"info"
>
<appender-ref
ref=
"CONSOLE"
/>
<appender-ref
ref=
"DefaultFile"
/>
</root>
<logger
name=
"com.yami.shop"
level=
"debug"
/>
<logger
name=
"springfox.documentation.swagger2"
level=
"off"
/>
<logger
name=
"io.swagger.models.parameters"
level=
"off"
/>
<logger
name=
"springfox.documentation.swagger.readers.operation.OperationImplicitParameterReader"
level=
"off"
/>
<logger
name=
"springfox.documentation.spring.web.readers.operation"
level=
"off"
/>
</configuration>
yami-shop-api/Dockerfile
0 → 100644
View file @
8aeef4e0
FROM
openjdk:17.0.2
RUN
ln
-sf
/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN
mkdir
-p
/opt/projects/mall4j
WORKDIR
/opt/projects/mall4j
EXPOSE
8086
ADD
./yami-shop-api/target/yami-shop-api-0.0.1-SNAPSHOT.jar ./
CMD
java -jar -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -Dspring.profiles.active=docker yami-shop-api-0.0.1-SNAPSHOT.jar
yami-shop-api/pom.xml
0 → 100644
View file @
8aeef4e0
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
yami-shop
</artifactId>
<groupId>
com.yami.shop
</groupId>
<version>
0.0.1-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
yami-shop-api
</artifactId>
<packaging>
jar
</packaging>
<dependencies>
<dependency>
<groupId>
com.yami.shop
</groupId>
<artifactId>
yami-shop-service
</artifactId>
<version>
${yami.shop.version}
</version>
</dependency>
<dependency>
<groupId>
com.yami.shop
</groupId>
<artifactId>
yami-shop-security-api
</artifactId>
<version>
${yami.shop.version}
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
${spring-boot.version}
</version>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
<!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
yami-shop-api/src/main/java/com/yami/shop/api/ApiApplication.java
0 → 100644
View file @
8aeef4e0
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package
com.yami.shop.api
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.context.annotation.ComponentScan
;
/**
* @author lgh
*/
@SpringBootApplication
@ComponentScan
(
basePackages
=
{
"com.yami.shop"
})
public
class
ApiApplication
extends
SpringBootServletInitializer
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ApiApplication
.
class
,
args
);
}
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
builder
)
{
return
builder
.
sources
(
ApiApplication
.
class
);
}
}
Prev
1
…
30
31
32
33
34
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