Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
lanbaoming
jiedao-api-boot-master
Commits
9f576514
Commit
9f576514
authored
Jul 24, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature-reward:接口基础功能完成
parent
7b20bfe6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
5 deletions
+101
-5
RewardConvert.java
...der/yudao/module/reward/convert/reward/RewardConvert.java
+7
-0
ErrorCodeConstants.java
...iocoder/yudao/module/reward/enums/ErrorCodeConstants.java
+2
-1
RewardService.java
...der/yudao/module/reward/service/reward/RewardService.java
+11
-0
RewardServiceImpl.java
...yudao/module/reward/service/reward/RewardServiceImpl.java
+40
-1
RewardDelayReqVO.java
...coder/yudao/module/reward/vo/reward/RewardDelayReqVO.java
+24
-0
RewardController.java
...dule/reward/controller/admin/reward/RewardController.java
+17
-3
No files found.
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/convert/reward/RewardConvert.java
View file @
9f576514
...
...
@@ -58,4 +58,11 @@ public interface RewardConvert {
* @return
*/
RewardDO
convertStatusReqVO
(
RewardStatusReqVO
bean
);
/***
* 礼品延期VO转实体
* @param bean
* @return
*/
RewardDO
convertDelayReqVO
(
RewardDelayReqVO
bean
);
}
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/enums/ErrorCodeConstants.java
View file @
9f576514
...
...
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
// TODO 待办:请将下面的错误码复制到 yudao-module-reward-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!!
// ========== 礼品 TODO 补充编号 ==========
public
interface
ErrorCodeConstants
{
ErrorCode
_NOT_EXISTS
=
new
ErrorCode
(
1009011000
,
"礼品不存在"
);
ErrorCode
REWARD_NOT_EXISTS
=
new
ErrorCode
(
1010011001
,
"礼品不存在"
);
ErrorCode
REWARD_ENDTIME_ERROR
=
new
ErrorCode
(
1001011002
,
"礼品结束时间不能早于当前时间"
);
}
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/service/reward/RewardService.java
View file @
9f576514
...
...
@@ -62,4 +62,15 @@ public interface RewardService extends IService<RewardDO> {
* @return 礼品列表
*/
List
<
RewardDO
>
getList
(
RewardQueryVO
query
);
/**
* 复制礼品
* @param id 编号
* @return 新的礼品id
*/
Long
copyReward
(
Long
id
);
void
delayReward
(
RewardDelayReqVO
delayVO
);
void
updateStatus
(
RewardStatusReqVO
statusVO
);
}
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/service/reward/RewardServiceImpl.java
View file @
9f576514
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
service
.
reward
;
import
java.time.Instant
;
import
java.util.*
;
import
javax.annotation.Resource
;
import
cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery
;
import
cn.iocoder.yudao.module.reward.enums.ErrorCodeConstants
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
import
cn.iocoder.yudao.framework.mybatis.core.vo.PageVO
;
...
...
@@ -59,7 +62,7 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
private
void
validateExists
(
Long
id
)
{
if
(
rewardMapper
.
selectById
(
id
)
==
null
)
{
throw
exception
(
_NOT_EXISTS
);
throw
exception
(
REWARD
_NOT_EXISTS
);
}
}
...
...
@@ -126,6 +129,42 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
return
rewardMapper
.
selectList
(
query
);
}
@Override
public
Long
copyReward
(
Long
id
)
{
RewardDO
reward
=
rewardMapper
.
selectById
(
id
);
if
(
reward
==
null
)
{
throw
exception
(
REWARD_NOT_EXISTS
);
}
//重新生成礼品ID
reward
.
setCode
(
generateRewardCode
());
//设置为未启用
reward
.
setStatus
(
2
);
reward
.
setId
(
null
);
reward
.
setCreateTime
(
null
);
reward
.
setUpdateTime
(
null
);
reward
.
setDeleted
(
null
);
rewardMapper
.
insert
(
reward
);
return
reward
.
getId
();
}
@Override
public
void
delayReward
(
RewardDelayReqVO
delayVO
)
{
this
.
validateExists
(
delayVO
.
getId
());
Instant
now
=
Instant
.
now
();
//结束时间不能小于当前时间
if
(!
delayVO
.
getEndTime
().
toInstant
().
isAfter
(
now
))
{
throw
ServiceExceptionUtil
.
exception
(
ErrorCodeConstants
.
REWARD_ENDTIME_ERROR
);
}
rewardMapper
.
updateById
(
RewardConvert
.
INSTANCE
.
convertDelayReqVO
(
delayVO
));
}
@Override
public
void
updateStatus
(
RewardStatusReqVO
statusVO
)
{
this
.
validateExists
(
statusVO
.
getId
());
rewardMapper
.
updateById
(
RewardConvert
.
INSTANCE
.
convertStatusReqVO
(
statusVO
));
}
//生成礼品ID
private
String
generateRewardCode
()
{
String
uuid
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
...
...
yudao-module-reward/yudao-module-reward-api/src/main/java/cn/iocoder/yudao/module/reward/vo/reward/RewardDelayReqVO.java
0 → 100644
View file @
9f576514
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
vo
.
reward
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Data
@ApiModel
(
"管理后台 - 礼品延期 VO"
)
public
class
RewardDelayReqVO
{
@ApiModelProperty
(
value
=
""
,
required
=
true
)
@NotNull
(
message
=
"不能为空"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"活动结束时间"
)
@DateTimeFormat
(
pattern
=
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
)
@NotNull
(
message
=
"结束时间不能为空"
)
private
Date
endTime
;
}
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/admin/reward/RewardController.java
View file @
9f576514
...
...
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotNull
;
import
java.io.IOException
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -88,7 +89,20 @@ public class RewardController {
@ApiOperation
(
"礼品状态变更"
)
//@PreAuthorize("@ss.hasPermission('reward::query')")
public
CommonResult
<
Boolean
>
updateStatus
(
@Valid
@RequestBody
RewardStatusReqVO
statusVO
)
{
rewardService
.
updateById
(
RewardConvert
.
INSTANCE
.
convertStatusReqVO
(
statusVO
));
rewardService
.
updateStatus
(
statusVO
);
return
success
(
true
);
}
@PostMapping
(
"/copy/{id}"
)
@ApiOperation
(
"复制礼品"
)
public
CommonResult
<
Long
>
copyReward
(
@NotNull
@PathVariable
Long
id
)
{
return
success
(
rewardService
.
copyReward
(
id
));
}
@PostMapping
(
"/delay"
)
@ApiOperation
(
"礼品延期"
)
public
CommonResult
<
Boolean
>
delayReward
(
@Valid
@RequestBody
RewardDelayReqVO
delayVO
)
{
rewardService
.
delayReward
(
delayVO
);
return
success
(
true
);
}
...
...
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