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
wwwanlingxiao
mall
Commits
dd4bc8f1
Commit
dd4bc8f1
authored
Jun 26, 2022
by
macro
Browse files
代码优化,废弃API修改
parent
dcb1b79f
Changes
16
Hide whitespace changes
Inline
Side-by-side
mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java
View file @
dd4bc8f1
...
...
@@ -3,6 +3,8 @@ package com.macro.mall.service;
import
com.macro.mall.dto.PmsProductCategoryParam
;
import
com.macro.mall.dto.PmsProductCategoryWithChildrenItem
;
import
com.macro.mall.model.PmsProductCategory
;
import
org.springframework.transaction.annotation.Isolation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
...
...
mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
View file @
dd4bc8f1
...
...
@@ -84,4 +84,9 @@ public interface UmsAdminService {
* 获取用户信息
*/
UserDetails
loadUserByUsername
(
String
username
);
/**
* 获取缓存服务
*/
UmsAdminCacheService
getCacheService
();
}
mall-admin/src/main/java/com/macro/mall/service/impl/CmsSubjectServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.CmsSubjectMapper
;
import
com.macro.mall.model.CmsSubject
;
...
...
@@ -30,7 +31,7 @@ public class CmsSubjectServiceImpl implements CmsSubjectService {
PageHelper
.
startPage
(
pageNum
,
pageSize
);
CmsSubjectExample
example
=
new
CmsSubjectExample
();
CmsSubjectExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
keyword
))
{
if
(!
StrUtil
.
isEmpty
(
keyword
))
{
criteria
.
andTitleLike
(
"%"
+
keyword
+
"%"
);
}
return
subjectMapper
.
selectByExample
(
example
);
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/PmsBrandServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dto.PmsBrandParam
;
import
com.macro.mall.mapper.PmsBrandMapper
;
...
...
@@ -37,7 +38,7 @@ public class PmsBrandServiceImpl implements PmsBrandService {
PmsBrand
pmsBrand
=
new
PmsBrand
();
BeanUtils
.
copyProperties
(
pmsBrandParam
,
pmsBrand
);
//如果创建时首字母为空,取名称的第一个为首字母
if
(
Str
ing
Util
s
.
isEmpty
(
pmsBrand
.
getFirstLetter
()))
{
if
(
StrUtil
.
isEmpty
(
pmsBrand
.
getFirstLetter
()))
{
pmsBrand
.
setFirstLetter
(
pmsBrand
.
getName
().
substring
(
0
,
1
));
}
return
brandMapper
.
insertSelective
(
pmsBrand
);
...
...
@@ -49,7 +50,7 @@ public class PmsBrandServiceImpl implements PmsBrandService {
BeanUtils
.
copyProperties
(
pmsBrandParam
,
pmsBrand
);
pmsBrand
.
setId
(
id
);
//如果创建时首字母为空,取名称的第一个为首字母
if
(
Str
ing
Util
s
.
isEmpty
(
pmsBrand
.
getFirstLetter
()))
{
if
(
StrUtil
.
isEmpty
(
pmsBrand
.
getFirstLetter
()))
{
pmsBrand
.
setFirstLetter
(
pmsBrand
.
getName
().
substring
(
0
,
1
));
}
//更新品牌时要更新商品中的品牌名称
...
...
@@ -79,7 +80,7 @@ public class PmsBrandServiceImpl implements PmsBrandService {
PmsBrandExample
pmsBrandExample
=
new
PmsBrandExample
();
pmsBrandExample
.
setOrderByClause
(
"sort desc"
);
PmsBrandExample
.
Criteria
criteria
=
pmsBrandExample
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
keyword
))
{
if
(!
StrUtil
.
isEmpty
(
keyword
))
{
criteria
.
andNameLike
(
"%"
+
keyword
+
"%"
);
}
return
brandMapper
.
selectByExample
(
pmsBrandExample
);
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dao.*
;
import
com.macro.mall.dto.PmsProductParam
;
...
...
@@ -98,7 +99,7 @@ public class PmsProductServiceImpl implements PmsProductService {
if
(
CollectionUtils
.
isEmpty
(
skuStockList
))
return
;
for
(
int
i
=
0
;
i
<
skuStockList
.
size
();
i
++){
PmsSkuStock
skuStock
=
skuStockList
.
get
(
i
);
if
(
Str
ing
Util
s
.
isEmpty
(
skuStock
.
getSkuCode
())){
if
(
StrUtil
.
isEmpty
(
skuStock
.
getSkuCode
())){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
StringBuilder
sb
=
new
StringBuilder
();
//日期
...
...
@@ -215,10 +216,10 @@ public class PmsProductServiceImpl implements PmsProductService {
if
(
productQueryParam
.
getVerifyStatus
()
!=
null
)
{
criteria
.
andVerifyStatusEqualTo
(
productQueryParam
.
getVerifyStatus
());
}
if
(!
Str
ing
Util
s
.
isEmpty
(
productQueryParam
.
getKeyword
()))
{
if
(!
StrUtil
.
isEmpty
(
productQueryParam
.
getKeyword
()))
{
criteria
.
andNameLike
(
"%"
+
productQueryParam
.
getKeyword
()
+
"%"
);
}
if
(!
Str
ing
Util
s
.
isEmpty
(
productQueryParam
.
getProductSn
()))
{
if
(!
StrUtil
.
isEmpty
(
productQueryParam
.
getProductSn
()))
{
criteria
.
andProductSnEqualTo
(
productQueryParam
.
getProductSn
());
}
if
(
productQueryParam
.
getBrandId
()
!=
null
)
{
...
...
@@ -293,7 +294,7 @@ public class PmsProductServiceImpl implements PmsProductService {
PmsProductExample
productExample
=
new
PmsProductExample
();
PmsProductExample
.
Criteria
criteria
=
productExample
.
createCriteria
();
criteria
.
andDeleteStatusEqualTo
(
0
);
if
(!
Str
ing
Util
s
.
isEmpty
(
keyword
)){
if
(!
StrUtil
.
isEmpty
(
keyword
)){
criteria
.
andNameLike
(
"%"
+
keyword
+
"%"
);
productExample
.
or
().
andDeleteStatusEqualTo
(
0
).
andProductSnLike
(
"%"
+
keyword
+
"%"
);
}
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/PmsSkuStockServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.macro.mall.dao.PmsSkuStockDao
;
import
com.macro.mall.mapper.PmsSkuStockMapper
;
import
com.macro.mall.model.PmsSkuStock
;
...
...
@@ -26,7 +27,7 @@ public class PmsSkuStockServiceImpl implements PmsSkuStockService {
public
List
<
PmsSkuStock
>
getList
(
Long
pid
,
String
keyword
)
{
PmsSkuStockExample
example
=
new
PmsSkuStockExample
();
PmsSkuStockExample
.
Criteria
criteria
=
example
.
createCriteria
().
andProductIdEqualTo
(
pid
);
if
(!
Str
ing
Util
s
.
isEmpty
(
keyword
))
{
if
(!
StrUtil
.
isEmpty
(
keyword
))
{
criteria
.
andSkuCodeLike
(
"%"
+
keyword
+
"%"
);
}
return
skuStockMapper
.
selectByExample
(
example
);
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponHistoryServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.SmsCouponHistoryMapper
;
import
com.macro.mall.model.SmsCouponHistory
;
...
...
@@ -30,7 +31,7 @@ public class SmsCouponHistoryServiceImpl implements SmsCouponHistoryService {
if
(
useStatus
!=
null
){
criteria
.
andUseStatusEqualTo
(
useStatus
);
}
if
(!
Str
ing
Util
s
.
isEmpty
(
orderSn
)){
if
(!
StrUtil
.
isEmpty
(
orderSn
)){
criteria
.
andOrderSnEqualTo
(
orderSn
);
}
return
historyMapper
.
selectByExample
(
example
);
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dao.SmsCouponDao
;
import
com.macro.mall.dao.SmsCouponProductCategoryRelationDao
;
...
...
@@ -108,7 +109,7 @@ public class SmsCouponServiceImpl implements SmsCouponService {
public
List
<
SmsCoupon
>
list
(
String
name
,
Integer
type
,
Integer
pageSize
,
Integer
pageNum
)
{
SmsCouponExample
example
=
new
SmsCouponExample
();
SmsCouponExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
name
)){
if
(!
StrUtil
.
isEmpty
(
name
)){
criteria
.
andNameLike
(
"%"
+
name
+
"%"
);
}
if
(
type
!=
null
){
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsFlashPromotionServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.SmsFlashPromotionMapper
;
import
com.macro.mall.model.SmsFlashPromotion
;
...
...
@@ -55,7 +56,7 @@ public class SmsFlashPromotionServiceImpl implements SmsFlashPromotionService {
public
List
<
SmsFlashPromotion
>
list
(
String
keyword
,
Integer
pageSize
,
Integer
pageNum
)
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
SmsFlashPromotionExample
example
=
new
SmsFlashPromotionExample
();
if
(!
Str
ing
Util
s
.
isEmpty
(
keyword
))
{
if
(!
StrUtil
.
isEmpty
(
keyword
))
{
example
.
createCriteria
().
andTitleLike
(
"%"
+
keyword
+
"%"
);
}
return
flashPromotionMapper
.
selectByExample
(
example
);
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeAdvertiseServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.SmsHomeAdvertiseMapper
;
import
com.macro.mall.model.SmsHomeAdvertise
;
...
...
@@ -61,13 +62,13 @@ public class SmsHomeAdvertiseServiceImpl implements SmsHomeAdvertiseService {
PageHelper
.
startPage
(
pageNum
,
pageSize
);
SmsHomeAdvertiseExample
example
=
new
SmsHomeAdvertiseExample
();
SmsHomeAdvertiseExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
name
))
{
if
(!
StrUtil
.
isEmpty
(
name
))
{
criteria
.
andNameLike
(
"%"
+
name
+
"%"
);
}
if
(
type
!=
null
)
{
criteria
.
andTypeEqualTo
(
type
);
}
if
(!
Str
ing
Util
s
.
isEmpty
(
endTime
))
{
if
(!
StrUtil
.
isEmpty
(
endTime
))
{
String
startStr
=
endTime
+
" 00:00:00"
;
String
endStr
=
endTime
+
" 23:59:59"
;
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeBrandServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.SmsHomeBrandMapper
;
import
com.macro.mall.model.SmsHomeBrand
;
...
...
@@ -58,7 +59,7 @@ public class SmsHomeBrandServiceImpl implements SmsHomeBrandService {
PageHelper
.
startPage
(
pageNum
,
pageSize
);
SmsHomeBrandExample
example
=
new
SmsHomeBrandExample
();
SmsHomeBrandExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
brandName
)){
if
(!
StrUtil
.
isEmpty
(
brandName
)){
criteria
.
andBrandNameLike
(
"%"
+
brandName
+
"%"
);
}
if
(
recommendStatus
!=
null
){
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeNewProductServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.SmsHomeNewProductMapper
;
import
com.macro.mall.model.SmsHomeNewProduct
;
...
...
@@ -58,7 +59,7 @@ public class SmsHomeNewProductServiceImpl implements SmsHomeNewProductService {
PageHelper
.
startPage
(
pageNum
,
pageSize
);
SmsHomeNewProductExample
example
=
new
SmsHomeNewProductExample
();
SmsHomeNewProductExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
productName
)){
if
(!
StrUtil
.
isEmpty
(
productName
)){
criteria
.
andProductNameLike
(
"%"
+
productName
+
"%"
);
}
if
(
recommendStatus
!=
null
){
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeRecommendProductServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.SmsHomeRecommendProductMapper
;
import
com.macro.mall.model.SmsHomeRecommendProduct
;
...
...
@@ -58,7 +59,7 @@ public class SmsHomeRecommendProductServiceImpl implements SmsHomeRecommendProdu
PageHelper
.
startPage
(
pageNum
,
pageSize
);
SmsHomeRecommendProductExample
example
=
new
SmsHomeRecommendProductExample
();
SmsHomeRecommendProductExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
productName
)){
if
(!
StrUtil
.
isEmpty
(
productName
)){
criteria
.
andProductNameLike
(
"%"
+
productName
+
"%"
);
}
if
(
recommendStatus
!=
null
){
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeRecommendSubjectServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.mapper.SmsHomeRecommendSubjectMapper
;
import
com.macro.mall.model.SmsHomeRecommendSubject
;
...
...
@@ -58,7 +59,7 @@ public class SmsHomeRecommendSubjectServiceImpl implements SmsHomeRecommendSubje
PageHelper
.
startPage
(
pageNum
,
pageSize
);
SmsHomeRecommendSubjectExample
example
=
new
SmsHomeRecommendSubjectExample
();
SmsHomeRecommendSubjectExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
subjectName
)){
if
(!
StrUtil
.
isEmpty
(
subjectName
)){
criteria
.
andSubjectNameLike
(
"%"
+
subjectName
+
"%"
);
}
if
(
recommendStatus
!=
null
){
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
View file @
dd4bc8f1
...
...
@@ -14,6 +14,7 @@ import com.macro.mall.mapper.UmsAdminMapper;
import
com.macro.mall.mapper.UmsAdminRoleRelationMapper
;
import
com.macro.mall.model.*
;
import
com.macro.mall.security.util.JwtTokenUtil
;
import
com.macro.mall.security.util.SpringUtil
;
import
com.macro.mall.service.UmsAdminCacheService
;
import
com.macro.mall.service.UmsAdminService
;
import
org.slf4j.Logger
;
...
...
@@ -56,19 +57,17 @@ public class UmsAdminServiceImpl implements UmsAdminService {
private
UmsAdminRoleRelationDao
adminRoleRelationDao
;
@Autowired
private
UmsAdminLoginLogMapper
loginLogMapper
;
@Autowired
private
UmsAdminCacheService
adminCacheService
;
@Override
public
UmsAdmin
getAdminByUsername
(
String
username
)
{
UmsAdmin
admin
=
admin
CacheService
.
getAdmin
(
username
);
UmsAdmin
admin
=
get
CacheService
()
.
getAdmin
(
username
);
if
(
admin
!=
null
)
return
admin
;
UmsAdminExample
example
=
new
UmsAdminExample
();
example
.
createCriteria
().
andUsernameEqualTo
(
username
);
List
<
UmsAdmin
>
adminList
=
adminMapper
.
selectByExample
(
example
);
if
(
adminList
!=
null
&&
adminList
.
size
()
>
0
)
{
admin
=
adminList
.
get
(
0
);
admin
CacheService
.
setAdmin
(
admin
);
get
CacheService
()
.
setAdmin
(
admin
);
return
admin
;
}
return
null
;
...
...
@@ -159,7 +158,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
PageHelper
.
startPage
(
pageNum
,
pageSize
);
UmsAdminExample
example
=
new
UmsAdminExample
();
UmsAdminExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
Str
ing
Util
s
.
isEmpty
(
keyword
))
{
if
(!
StrUtil
.
isEmpty
(
keyword
))
{
criteria
.
andUsernameLike
(
"%"
+
keyword
+
"%"
);
example
.
or
(
example
.
createCriteria
().
andNickNameLike
(
"%"
+
keyword
+
"%"
));
}
...
...
@@ -182,15 +181,15 @@ public class UmsAdminServiceImpl implements UmsAdminService {
}
}
int
count
=
adminMapper
.
updateByPrimaryKeySelective
(
admin
);
admin
CacheService
.
delAdmin
(
id
);
get
CacheService
()
.
delAdmin
(
id
);
return
count
;
}
@Override
public
int
delete
(
Long
id
)
{
admin
CacheService
.
delAdmin
(
id
);
get
CacheService
()
.
delAdmin
(
id
);
int
count
=
adminMapper
.
deleteByPrimaryKey
(
id
);
admin
CacheService
.
delResourceList
(
id
);
get
CacheService
()
.
delResourceList
(
id
);
return
count
;
}
...
...
@@ -212,7 +211,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
}
adminRoleRelationDao
.
insertList
(
list
);
}
admin
CacheService
.
delResourceList
(
adminId
);
get
CacheService
()
.
delResourceList
(
adminId
);
return
count
;
}
...
...
@@ -223,13 +222,13 @@ public class UmsAdminServiceImpl implements UmsAdminService {
@Override
public
List
<
UmsResource
>
getResourceList
(
Long
adminId
)
{
List
<
UmsResource
>
resourceList
=
admin
CacheService
.
getResourceList
(
adminId
);
List
<
UmsResource
>
resourceList
=
get
CacheService
()
.
getResourceList
(
adminId
);
if
(
CollUtil
.
isNotEmpty
(
resourceList
)){
return
resourceList
;
}
resourceList
=
adminRoleRelationDao
.
getResourceList
(
adminId
);
if
(
CollUtil
.
isNotEmpty
(
resourceList
)){
admin
CacheService
.
setResourceList
(
adminId
,
resourceList
);
get
CacheService
()
.
setResourceList
(
adminId
,
resourceList
);
}
return
resourceList
;
}
...
...
@@ -253,7 +252,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
}
umsAdmin
.
setPassword
(
passwordEncoder
.
encode
(
param
.
getNewPassword
()));
adminMapper
.
updateByPrimaryKey
(
umsAdmin
);
admin
CacheService
.
delAdmin
(
umsAdmin
.
getId
());
get
CacheService
()
.
delAdmin
(
umsAdmin
.
getId
());
return
1
;
}
...
...
@@ -267,4 +266,9 @@ public class UmsAdminServiceImpl implements UmsAdminService {
}
throw
new
UsernameNotFoundException
(
"用户名或密码错误"
);
}
@Override
public
UmsAdminCacheService
getCacheService
()
{
return
SpringUtil
.
getBean
(
UmsAdminCacheService
.
class
);
}
}
mall-admin/src/main/java/com/macro/mall/service/impl/UmsRoleServiceImpl.java
View file @
dd4bc8f1
package
com.macro.mall.service.impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dao.UmsRoleDao
;
import
com.macro.mall.mapper.UmsRoleMapper
;
...
...
@@ -63,7 +64,7 @@ public class UmsRoleServiceImpl implements UmsRoleService {
public
List
<
UmsRole
>
list
(
String
keyword
,
Integer
pageSize
,
Integer
pageNum
)
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
UmsRoleExample
example
=
new
UmsRoleExample
();
if
(!
Str
ing
Util
s
.
isEmpty
(
keyword
))
{
if
(!
StrUtil
.
isEmpty
(
keyword
))
{
example
.
createCriteria
().
andNameLike
(
"%"
+
keyword
+
"%"
);
}
return
roleMapper
.
selectByExample
(
example
);
...
...
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