Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lingxi-lxy-yanshou
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
后端-黄柯铭
lingxi-lxy-yanshou
Commits
0860c6ad
Commit
0860c6ad
authored
Aug 06, 2021
by
fhj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模板服务 -> 活动页需求
parent
50ef02ba
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
263 additions
and
8 deletions
+263
-8
ShopEnvironmentEnum.java
...sy/lingxi/common/constant/manage/ShopEnvironmentEnum.java
+10
-0
ActivityPageStatusEnum.java
...orm/template/service/constant/ActivityPageStatusEnum.java
+71
-0
ActivityPageWebController.java
...ate/service/controller/web/ActivityPageWebController.java
+1
-1
ActivityPage.java
.../platform/template/service/entity/adorn/ActivityPage.java
+8
-0
ActivityPageWebServiceImpl.java
...e/service/serviceimpl/web/ActivityPageWebServiceImpl.java
+173
-7
No files found.
common/src/main/java/com/ssy/lingxi/common/constant/manage/ShopEnvironmentEnum.java
View file @
0860c6ad
package
com
.
ssy
.
lingxi
.
common
.
constant
.
manage
;
import
java.util.Arrays
;
/**
* 商城适用环境 - enum
* @author fhj
...
...
@@ -21,6 +23,14 @@ public enum ShopEnvironmentEnum {
this
.
message
=
message
;
}
/**
* 根据code获取message
* */
public
static
String
getMessage
(
Integer
code
)
{
ShopEnvironmentEnum
shopEnvironmentEnum
=
Arrays
.
stream
(
ShopEnvironmentEnum
.
values
()).
filter
(
e
->
e
.
getCode
().
equals
(
code
)).
findFirst
().
orElse
(
null
);
return
shopEnvironmentEnum
!=
null
?
shopEnvironmentEnum
.
getMessage
()
:
"无效环境"
;
}
public
Integer
getCode
()
{
return
code
;
}
...
...
platform-template-service/src/main/java/com/ssy/lingxi/platform/template/service/constant/ActivityPageStatusEnum.java
0 → 100644
View file @
0860c6ad
package
com
.
ssy
.
lingxi
.
platform
.
template
.
service
.
constant
;
import
java.util.Arrays
;
/**
* 活动页状态 - enum
* @author fhj
* @date 2021/08/06
* @version 2.0.0
*/
public
enum
ActivityPageStatusEnum
{
WAIT_OPEN_LINE
(
1
,
"待上线"
),
ALREADY_OPEN_LINE
(
2
,
"已上线"
),
START
(
3
,
"进行中"
),
OFF_LINE
(
4
,
"已下线"
),
END
(
5
,
"已结束"
)
;
private
final
Integer
code
;
private
final
String
message
;
ActivityPageStatusEnum
(
Integer
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
/**
* 根据code获取message
* */
public
static
String
getMessage
(
Integer
code
)
{
ActivityPageStatusEnum
activityPageStatusEnum
=
Arrays
.
stream
(
ActivityPageStatusEnum
.
values
()).
filter
(
e
->
e
.
getCode
().
equals
(
code
)).
findFirst
().
orElse
(
null
);
return
activityPageStatusEnum
!=
null
?
activityPageStatusEnum
.
getMessage
()
:
"无效状态"
;
}
/**
* 判断是否能修改
* */
public
static
Boolean
isUpdate
(
Integer
code
)
{
return
code
.
equals
(
WAIT_OPEN_LINE
.
code
)
||
code
.
equals
(
OFF_LINE
.
code
);
}
/**
* 判断是否能删除
* */
public
static
Boolean
isDelete
(
Integer
code
)
{
return
code
.
equals
(
WAIT_OPEN_LINE
.
code
);
}
/**
* 判断是否能上线
* */
public
static
Boolean
isOpenLine
(
Integer
code
)
{
return
code
.
equals
(
WAIT_OPEN_LINE
.
code
)
||
code
.
equals
(
OFF_LINE
.
code
);
}
/**
* 判断是否能下线
* */
public
static
Boolean
isOffLine
(
Integer
code
)
{
return
code
.
equals
(
ALREADY_OPEN_LINE
.
code
)
||
code
.
equals
(
START
.
code
);
}
public
Integer
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
}
platform-template-service/src/main/java/com/ssy/lingxi/platform/template/service/controller/web/ActivityPageWebController.java
View file @
0860c6ad
...
...
@@ -23,7 +23,7 @@ import javax.validation.Valid;
* @version 2.0.0
* @date 2021/04/15
*/
@Api
(
tags
=
"web -
SEO
"
)
@Api
(
tags
=
"web -
活动页
"
)
@RestController
@RequestMapping
(
"/template/web/activityPage"
)
public
class
ActivityPageWebController
extends
BaseController
{
...
...
platform-template-service/src/main/java/com/ssy/lingxi/platform/template/service/entity/adorn/ActivityPage.java
View file @
0860c6ad
...
...
@@ -52,6 +52,10 @@ public class ActivityPage {
@ApiModelProperty
(
value
=
"适用环境: 1.WEB 2.H5 3.小程序 4.APP"
)
private
Integer
environment
;
@Column
(
columnDefinition
=
"varchar(20)"
)
@ApiModelProperty
(
value
=
"适用环境(冗余)"
)
private
String
environmentName
;
@Column
(
columnDefinition
=
"int8"
)
@ApiModelProperty
(
value
=
"活动模板ID"
)
private
Long
templateId
;
...
...
@@ -72,6 +76,10 @@ public class ActivityPage {
@ApiModelProperty
(
value
=
"状态: 1.待上线 2.已上线 3.进行中 4.已下线 5.已结束"
)
private
Integer
status
=
1
;
@Column
(
columnDefinition
=
"varchar(20)"
)
@ApiModelProperty
(
value
=
"状态(冗余)"
)
private
String
statusName
;
@Convert
(
converter
=
JpaJsonToJsonObjectConverter
.
class
)
@Column
(
columnDefinition
=
"jsonb"
)
@ApiModelProperty
(
value
=
"装修内容"
)
...
...
platform-template-service/src/main/java/com/ssy/lingxi/platform/template/service/serviceimpl/web/ActivityPageWebServiceImpl.java
View file @
0860c6ad
package
com
.
ssy
.
lingxi
.
platform
.
template
.
service
.
serviceimpl
.
web
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.querydsl.core.BooleanBuilder
;
import
com.querydsl.jpa.impl.JPAQuery
;
import
com.querydsl.jpa.impl.JPAQueryFactory
;
import
com.ssy.lingxi.common.constant.manage.ShopEnvironmentEnum
;
import
com.ssy.lingxi.common.exception.BusinessException
;
import
com.ssy.lingxi.common.model.dto.UserLoginCacheDTO
;
import
com.ssy.lingxi.common.response.PageData
;
import
com.ssy.lingxi.common.response.ResponseCode
;
import
com.ssy.lingxi.common.response.Wrapper
;
import
com.ssy.lingxi.platform.template.service.constant.ActivityPageStatusEnum
;
import
com.ssy.lingxi.platform.template.service.constant.CommonBooleanEnum
;
import
com.ssy.lingxi.platform.template.service.entity.adorn.ActivityPage
;
import
com.ssy.lingxi.platform.template.service.entity.adorn.QActivityPage
;
import
com.ssy.lingxi.platform.template.service.model.dto.common.CommonStatusDTO
;
import
com.ssy.lingxi.platform.template.service.model.dto.common.IdDTO
;
import
com.ssy.lingxi.platform.template.service.model.dto.web.SaveActivityPageDTO
;
import
com.ssy.lingxi.platform.template.service.model.qo.ActivityPageQO
;
import
com.ssy.lingxi.platform.template.service.repository.ActivityPageRepository
;
import
com.ssy.lingxi.platform.template.service.service.web.ActivityPageWebService
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @menu web - 活动页 - 业务实现层
...
...
@@ -22,38 +40,186 @@ import org.springframework.stereotype.Service;
@Service
public
class
ActivityPageWebServiceImpl
implements
ActivityPageWebService
{
@Resource
private
JPAQueryFactory
jpaQueryFactory
;
@Resource
private
ActivityPageRepository
activityPageRepository
;
@Override
@ApiOperation
(
value
=
"列表"
)
public
Wrapper
<
PageData
<
ActivityPage
>>
page
(
ActivityPageQO
qo
,
UserLoginCacheDTO
user
)
{
return
null
;
//查询表实体 - 活动页
QActivityPage
activityPage
=
QActivityPage
.
activityPage
;
//查询条件构造 - 必要条件
BooleanBuilder
predicates
=
new
BooleanBuilder
();
predicates
.
and
(
activityPage
.
memberId
.
eq
(
user
.
getMemberId
()));
predicates
.
and
(
activityPage
.
roleId
.
eq
(
user
.
getMemberRoleId
()));
predicates
.
and
(
activityPage
.
type
.
eq
(
qo
.
getType
()));
//搜索条件
if
(
StringUtils
.
isNotBlank
(
qo
.
getName
()))
{
predicates
.
and
(
activityPage
.
name
.
like
(
"%"
+
qo
.
getName
()
+
"%"
));
}
if
(
qo
.
getStartTime
()
!=
null
)
{
predicates
.
and
(
activityPage
.
startTime
.
goe
(
qo
.
getStartTime
()));
}
if
(
qo
.
getEndTime
()
!=
null
)
{
predicates
.
and
(
activityPage
.
endTime
.
loe
(
qo
.
getEndTime
()));
}
if
(
qo
.
getEnvironment
()
!=
null
)
{
predicates
.
and
(
activityPage
.
environment
.
eq
(
qo
.
getEnvironment
()));
}
if
(
qo
.
getStatus
()
!=
null
)
{
predicates
.
and
(
activityPage
.
status
.
eq
(
qo
.
getStatus
()));
}
//查询
JPAQuery
<
ActivityPage
>
query
=
jpaQueryFactory
.
select
(
activityPage
).
from
(
activityPage
).
where
(
predicates
);
//总记录数
long
totalCount
=
query
.
fetchCount
();
//列表数据
List
<
ActivityPage
>
list
=
query
.
orderBy
(
activityPage
.
createTime
.
desc
()).
offset
((
qo
.
getCurrent
()
-
1
)
*
qo
.
getPageSize
()).
limit
(
qo
.
getPageSize
()).
fetch
();
return
Wrapper
.
success
(
new
PageData
<>(
totalCount
,
list
));
}
@Override
@ApiOperation
(
value
=
"详情"
)
public
Wrapper
<
ActivityPage
>
get
(
IdDTO
dto
)
{
return
null
;
ActivityPage
activityPage
=
activityPageRepository
.
findById
(
dto
.
getId
()).
orElse
(
null
);
if
(
activityPage
==
null
)
{
throw
new
BusinessException
(
ResponseCode
.
PT_RECORDS_DON_T_EXIST
);
}
return
Wrapper
.
success
(
activityPage
);
}
@Override
@Transactional
@ApiOperation
(
value
=
"新增"
)
public
Wrapper
<
Void
>
add
(
SaveActivityPageDTO
dto
,
UserLoginCacheDTO
user
)
{
return
null
;
//校验
if
(
dto
.
getStartTime
()
>=
dto
.
getEndTime
()
||
System
.
currentTimeMillis
()
>=
dto
.
getEndTime
())
{
return
Wrapper
.
fail
(
"截止时间必须大于开始时间并且还要大于当前时间"
);
}
//新增
ActivityPage
activityPage
=
new
ActivityPage
();
BeanUtils
.
copyProperties
(
dto
,
activityPage
);
activityPage
.
setMemberId
(
user
.
getMemberId
());
activityPage
.
setRoleId
(
user
.
getMemberRoleId
());
activityPage
.
setEnvironmentName
(
ShopEnvironmentEnum
.
getMessage
(
dto
.
getEnvironment
()));
activityPage
.
setStatusName
(
ActivityPageStatusEnum
.
getMessage
(
activityPage
.
getStatus
()));
activityPageRepository
.
saveAndFlush
(
activityPage
);
return
Wrapper
.
success
();
}
@Override
@Transactional
@ApiOperation
(
value
=
"修改"
)
public
Wrapper
<
Void
>
update
(
SaveActivityPageDTO
dto
,
UserLoginCacheDTO
user
)
{
return
null
;
//获取活动页
ActivityPage
activityPage
=
activityPageRepository
.
findById
(
dto
.
getId
()).
orElse
(
null
);
//校验
if
(
activityPage
==
null
)
{
throw
new
BusinessException
(
ResponseCode
.
PT_RECORDS_DON_T_EXIST
);
}
if
(
dto
.
getStartTime
()
>=
dto
.
getEndTime
()
||
System
.
currentTimeMillis
()
>=
dto
.
getEndTime
())
{
return
Wrapper
.
fail
(
"截止时间必须大于开始时间并且还要大于当前时间"
);
}
if
(!
ActivityPageStatusEnum
.
isUpdate
(
activityPage
.
getStatus
()))
{
return
Wrapper
.
fail
(
"只能修改'待上线'或'已下线'的活动页"
);
}
//修改
activityPage
.
setName
(
dto
.
getName
());
activityPage
.
setStartTime
(
dto
.
getStartTime
());
activityPage
.
setEndTime
(
dto
.
getEndTime
());
activityPageRepository
.
saveAndFlush
(
activityPage
);
return
Wrapper
.
success
();
}
@Override
@Transactional
@ApiOperation
(
value
=
"删除"
)
public
Wrapper
<
Void
>
delete
(
IdDTO
dto
,
UserLoginCacheDTO
user
)
{
return
null
;
//获取活动页
ActivityPage
activityPage
=
activityPageRepository
.
findById
(
dto
.
getId
()).
orElse
(
null
);
//校验
if
(
activityPage
==
null
)
{
throw
new
BusinessException
(
ResponseCode
.
PT_RECORDS_DON_T_EXIST
);
}
if
(!
ActivityPageStatusEnum
.
isDelete
(
activityPage
.
getStatus
()))
{
return
Wrapper
.
fail
(
"只能删除'待上线'的活动页"
);
}
activityPageRepository
.
deleteById
(
dto
.
getId
());
return
Wrapper
.
success
();
}
@Override
@Transactional
@ApiOperation
(
value
=
"上下线"
)
public
Wrapper
<
Void
>
openOffLine
(
CommonStatusDTO
dto
,
UserLoginCacheDTO
user
)
{
return
null
;
//获取活动页
ActivityPage
activityPage
=
activityPageRepository
.
findById
(
dto
.
getId
()).
orElse
(
null
);
//校验
if
(
activityPage
==
null
)
{
throw
new
BusinessException
(
ResponseCode
.
PT_RECORDS_DON_T_EXIST
);
}
if
(
dto
.
getStatus
().
equals
(
CommonBooleanEnum
.
YES
.
getCode
()))
{
if
(!
ActivityPageStatusEnum
.
isOpenLine
(
activityPage
.
getStatus
()))
{
return
Wrapper
.
fail
(
"只能上线'待上线'或'已下线'的活动页"
);
}
if
(
CollectionUtil
.
isEmpty
(
activityPage
.
getAdornContent
()))
{
return
Wrapper
.
fail
(
"请先去装修活动页再去上线"
);
}
if
(
System
.
currentTimeMillis
()
-
10000
>=
activityPage
.
getEndTime
())
{
activityPage
.
setStatus
(
ActivityPageStatusEnum
.
START
.
getCode
());
activityPage
.
setStatusName
(
ActivityPageStatusEnum
.
START
.
getMessage
());
}
else
{
activityPage
.
setStatus
(
ActivityPageStatusEnum
.
ALREADY_OPEN_LINE
.
getCode
());
activityPage
.
setStatusName
(
ActivityPageStatusEnum
.
ALREADY_OPEN_LINE
.
getMessage
());
}
}
if
(
dto
.
getStatus
().
equals
(
CommonBooleanEnum
.
NO
.
getCode
()))
{
if
(!
ActivityPageStatusEnum
.
isOffLine
(
activityPage
.
getStatus
()))
{
return
Wrapper
.
fail
(
"只能下线'已上线'或'进行中'的活动页"
);
}
activityPage
.
setStatus
(
ActivityPageStatusEnum
.
OFF_LINE
.
getCode
());
activityPage
.
setStatusName
(
ActivityPageStatusEnum
.
OFF_LINE
.
getMessage
());
}
//更新活动页状态
activityPageRepository
.
saveAndFlush
(
activityPage
);
return
Wrapper
.
success
();
}
@Override
@Transactional
@ApiOperation
(
value
=
"装修"
)
public
Wrapper
<
Void
>
adorn
(
SaveActivityPageDTO
dto
,
UserLoginCacheDTO
user
)
{
return
null
;
//获取活动页
ActivityPage
activityPage
=
activityPageRepository
.
findById
(
dto
.
getId
()).
orElse
(
null
);
//校验
if
(
activityPage
==
null
)
{
throw
new
BusinessException
(
ResponseCode
.
PT_RECORDS_DON_T_EXIST
);
}
//保存装修内容
activityPage
.
setAdornContent
(
dto
.
getAdornContent
());
activityPageRepository
.
saveAndFlush
(
activityPage
);
return
Wrapper
.
success
();
}
}
Write
Preview
Markdown
is supported
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