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
b7ea7a20
Commit
b7ea7a20
authored
Jul 30, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
积分规则接口校验
parent
ed0ae6b3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
18 deletions
+63
-18
TransportType.java
...a/cn/iocoder/yudao/module/member/enums/TransportType.java
+23
-0
ScoreRuleController.java
...ember/controller/admin/scoreRule/ScoreRuleController.java
+7
-9
ScoreRuleDO.java
...o/module/member/dal/dataobject/scoreRule/ScoreRuleDO.java
+1
-1
ScoreRuleMapper.java
...ao/module/member/dal/mysql/scoreRule/ScoreRuleMapper.java
+2
-2
ScoreRuleServiceImpl.java
...module/member/service/scoreRule/ScoreRuleServiceImpl.java
+15
-6
IdReqVo.java
.../cn/iocoder/yudao/module/member/vo/scoreRule/IdReqVo.java
+15
-0
No files found.
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/TransportType.java
0 → 100644
View file @
b7ea7a20
package
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
;
public
enum
TransportType
{
OCEAN_LCL
(
1
,
"海运拼柜"
),
SPECIAL_LINE_AIR_FREIGHT
(
3
,
"专线空运"
);
private
final
int
value
;
private
final
String
name
;
TransportType
(
int
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
int
getValue
()
{
return
value
;
}
public
String
getName
()
{
return
name
;
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/admin/scoreRule/ScoreRuleController.java
View file @
b7ea7a20
...
...
@@ -54,19 +54,17 @@ public class ScoreRuleController {
@PostMapping
(
"/delete"
)
@ApiOperation
(
"删除积分规则"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"编号"
,
required
=
true
,
example
=
"1024"
,
dataTypeClass
=
Long
.
class
)
@PreAuthorize
(
"@ss.hasPermission('member:score-rule:delete')"
)
public
CommonResult
<
Boolean
>
deleteScoreRule
(
@
NotNull
@RequestBody
Long
id
)
{
scoreRuleService
.
deleteScoreRule
(
id
);
public
CommonResult
<
Boolean
>
deleteScoreRule
(
@
Valid
@RequestBody
IdReqVo
idReqVo
)
{
scoreRuleService
.
deleteScoreRule
(
id
ReqVo
.
getId
()
);
return
success
(
true
);
}
@PostMapping
(
"/get"
)
@ApiOperation
(
"获得积分规则详情"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"编号"
,
required
=
true
,
example
=
"1024"
,
dataTypeClass
=
Long
.
class
)
@PreAuthorize
(
"@ss.hasPermission('member:score-rule:query')"
)
public
CommonResult
<
ScoreRuleBackDetailVO
>
getScoreRule
(
@
NotNull
@RequestBody
Long
id
)
{
ScoreRuleBackDetailVO
scoreRuleBackDetailVO
=
scoreRuleService
.
getScoreRule
(
id
);
public
CommonResult
<
ScoreRuleBackDetailVO
>
getScoreRule
(
@
Valid
@RequestBody
IdReqVo
idReqVo
)
{
ScoreRuleBackDetailVO
scoreRuleBackDetailVO
=
scoreRuleService
.
getScoreRule
(
id
ReqVo
.
getId
()
);
return
success
(
scoreRuleBackDetailVO
);
}
...
...
@@ -74,7 +72,7 @@ public class ScoreRuleController {
@ApiOperation
(
"获得积分规则列表"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"编号列表"
,
required
=
true
,
example
=
"1024,2048"
,
dataTypeClass
=
List
.
class
)
@PreAuthorize
(
"@ss.hasPermission('member:score-rule:query')"
)
public
CommonResult
<
List
<
ScoreRuleBackVO
>>
getScoreRuleList
(
@NotNull
@Request
Body
Collection
<
Long
>
ids
)
{
public
CommonResult
<
List
<
ScoreRuleBackVO
>>
getScoreRuleList
(
@NotNull
@Request
Param
Collection
<
Long
>
ids
)
{
List
<
ScoreRuleBackVO
>
list
=
scoreRuleService
.
getScoreRuleList
(
ids
);
return
success
(
list
);
}
...
...
@@ -96,8 +94,8 @@ public class ScoreRuleController {
@PostMapping
(
"/copy"
)
@ApiOperation
(
"复制规则"
)
@PreAuthorize
(
"@ss.hasPermission('member:score-rule:create')"
)
public
CommonResult
<
Long
>
copyScoreRule
(
@
NotNull
@RequestBody
Long
id
)
{
return
success
(
scoreRuleService
.
copyScoreRule
(
id
));
public
CommonResult
<
Long
>
copyScoreRule
(
@
Valid
@RequestBody
IdReqVo
idReqVo
)
{
return
success
(
scoreRuleService
.
copyScoreRule
(
id
ReqVo
.
getId
()
));
}
@PostMapping
(
"/delay"
)
@ApiOperation
(
"延期规则"
)
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/scoreRule/ScoreRuleDO.java
View file @
b7ea7a20
...
...
@@ -71,7 +71,7 @@ public class ScoreRuleDO extends BaseDO {
/**
* 积分有效期
*/
private
Integer
s
oc
rePeriod
;
private
Integer
s
co
rePeriod
;
/**
* 排序值
*/
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/scoreRule/ScoreRuleMapper.java
View file @
b7ea7a20
...
...
@@ -31,7 +31,7 @@ public interface ScoreRuleMapper extends AbstractMapper<ScoreRuleDO> {
.
eqIfPresent
(
ScoreRuleDO:
:
getMaxScoreTotal
,
vo
.
getMaxScoreTotal
())
.
betweenIfPresent
(
ScoreRuleDO:
:
getStartTime
,
vo
.
getBeginStartTime
(),
vo
.
getEndStartTime
())
.
betweenIfPresent
(
ScoreRuleDO:
:
getEndTime
,
vo
.
getBeginEndTime
(),
vo
.
getEndEndTime
())
.
eqIfPresent
(
ScoreRuleDO:
:
getS
oc
rePeriod
,
vo
.
getSocrePeriod
())
.
eqIfPresent
(
ScoreRuleDO:
:
getS
co
rePeriod
,
vo
.
getSocrePeriod
())
.
eqIfPresent
(
ScoreRuleDO:
:
getOrderNum
,
vo
.
getOrderNum
())
.
eqIfPresent
(
ScoreRuleDO:
:
getPushActivity
,
vo
.
getPushActivity
())
.
eqIfPresent
(
ScoreRuleDO:
:
getShowPlatform
,
vo
.
getShowPlatform
())
...
...
@@ -60,7 +60,7 @@ public interface ScoreRuleMapper extends AbstractMapper<ScoreRuleDO> {
.
eqIfPresent
(
ScoreRuleDO:
:
getMaxScoreTotal
,
vo
.
getMaxScoreTotal
())
.
betweenIfPresent
(
ScoreRuleDO:
:
getStartTime
,
vo
.
getBeginStartTime
(),
vo
.
getEndStartTime
())
.
betweenIfPresent
(
ScoreRuleDO:
:
getEndTime
,
vo
.
getBeginEndTime
(),
vo
.
getEndEndTime
())
.
eqIfPresent
(
ScoreRuleDO:
:
getS
oc
rePeriod
,
vo
.
getSocrePeriod
())
.
eqIfPresent
(
ScoreRuleDO:
:
getS
co
rePeriod
,
vo
.
getSocrePeriod
())
.
eqIfPresent
(
ScoreRuleDO:
:
getOrderNum
,
vo
.
getOrderNum
())
.
eqIfPresent
(
ScoreRuleDO:
:
getPushActivity
,
vo
.
getPushActivity
())
.
eqIfPresent
(
ScoreRuleDO:
:
getShowPlatform
,
vo
.
getShowPlatform
())
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreRule/ScoreRuleServiceImpl.java
View file @
b7ea7a20
...
...
@@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import
cn.iocoder.yudao.module.member.dal.mysql.scoreRule.ScoreRuleMapper
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleStatusEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.TransportType
;
import
cn.iocoder.yudao.module.member.enums.YesOrNoTypeEnum
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.*
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO
;
...
...
@@ -43,6 +44,9 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
@Override
public
Long
createScoreRule
(
ScoreRuleCreateReqVO
createReqVO
)
{
ScoreRuleDO
scoreRule
=
ScoreRuleConvert
.
INSTANCE
.
convert
(
createReqVO
);
if
(
scoreRule
.
getStatus
()
!=
ScoreRuleStatusEnum
.
DISABLED
.
getValue
()
&&
scoreRule
.
getStatus
()
!=
ScoreRuleStatusEnum
.
ENABLED
.
getValue
()){
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
verifyCommon
(
scoreRule
);
Integer
scoreRuleType
=
scoreRule
.
getType
();
verifyAndSetExtraDO
(
createReqVO
,
scoreRuleType
,
scoreRule
);
...
...
@@ -62,7 +66,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
scoreRule
.
getStartTime
().
after
((
scoreRule
.
getEndTime
()))
||
scoreRule
.
getEndTime
().
before
(
Date
.
from
(
Instant
.
now
())))
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
if
(
scoreRule
.
getS
oc
rePeriod
()
<=
0
)
{
if
(
scoreRule
.
getS
co
rePeriod
()
<=
0
)
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
//如果是启用,校验同一个规则下,有效期内有没有重复的规则设置,分享不校验
...
...
@@ -72,7 +76,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
.
eq
(
ScoreRuleDO:
:
getType
,
scoreRule
.
getType
())
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
());
Long
count
=
scoreRuleMapper
.
selectCount
(
scoreRuleDOLambdaQuery
);
if
(
count
>
1
)
{
if
(
count
>
0
)
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
}
...
...
@@ -85,7 +89,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
scoreRuleDO
==
null
)
{
throw
exception
(
SCORE_RULE_NOT_EXISTS
);
}
if
(
scoreRuleDO
.
getStatus
()
==
ScoreRuleStatusEnum
.
EN
ABLED
.
getValue
())
{
if
(
scoreRuleDO
.
getStatus
()
!=
ScoreRuleStatusEnum
.
DIS
ABLED
.
getValue
())
{
throw
exception
(
SCORE_RULE_UPDATE_ERROR
);
}
ScoreRuleDO
scoreRule
=
ScoreRuleConvert
.
INSTANCE
.
convert
(
updateReqVO
);
...
...
@@ -111,6 +115,9 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
YES
.
ordinal
()
&&
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
NO
.
ordinal
())
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
if
(
extraOrderV
.
getTransportType
()
!=
TransportType
.
OCEAN_LCL
.
getValue
()
&&
extraOrderV
.
getFirstOrder
()
!=
TransportType
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
if
(
StringUtils
.
isAnyBlank
(
extraOrderV
.
getTargetCountry
(),
extraOrderV
.
getTargetCity
(),
extraOrderV
.
getReceiveAddr
(),
extraOrderV
.
getOrderEntry
()))
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
...
...
@@ -172,7 +179,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
scoreRuleDO
==
null
)
{
throw
exception
(
SCORE_RULE_NOT_EXISTS
);
}
if
(
scoreRuleDO
.
getStatus
()
==
ScoreRuleStatusEnum
.
EN
ABLED
.
getValue
())
{
if
(
scoreRuleDO
.
getStatus
()
!=
ScoreRuleStatusEnum
.
DIS
ABLED
.
getValue
())
{
throw
exception
(
SCORE_RULE_DELETE_ERROR
);
}
// 删除
...
...
@@ -255,11 +262,13 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
.
eq
(
ScoreRuleDO:
:
getType
,
scoreRuleDO
.
getType
())
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
());
Long
count
=
scoreRuleMapper
.
selectCount
(
scoreRuleDOLambdaQuery
);
if
(
count
>
1
)
{
if
(
count
>
0
)
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
}
upScoreRuleDO
.
setStatus
(
scoreRuleStatusReqVO
.
getStatus
());
}
else
{
throw
exception
(
SCORE_RULE_UPDATE_ERROR
);
}
scoreRuleMapper
.
updateById
(
upScoreRuleDO
);
}
...
...
@@ -290,7 +299,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
Instant
now
=
Instant
.
now
();
//结束时间不能小于当前时间
if
(!
delayReqVO
.
getEndTime
().
toInstant
().
isAfter
(
now
))
{
if
(!
delayReqVO
.
getEndTime
().
toInstant
().
isAfter
(
now
)
||
!
delayReqVO
.
getEndTime
().
toInstant
().
isAfter
(
scoreRuleDO
.
getStartTime
().
toInstant
())
)
{
throw
exception
(
SCORE_RULE_UPDATE_ERROR
);
}
ScoreRuleDO
upScoreRuleDO
=
new
ScoreRuleDO
();
...
...
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/vo/scoreRule/IdReqVo.java
0 → 100644
View file @
b7ea7a20
package
cn
.
iocoder
.
yudao
.
module
.
member
.
vo
.
scoreRule
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
@Data
@ApiModel
(
"管理后台 - 积分规则id请求 VO"
)
public
class
IdReqVo
{
@ApiModelProperty
(
value
=
"主键"
,
required
=
true
)
@NotNull
(
message
=
"主键不能为空"
)
private
Long
id
;
}
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