Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
9a3b7087
提交
9a3b7087
authored
5月 06, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 前端 + 后端:完善首页广告
上级
2890af63
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
86 行增加
和
72 行删除
+86
-72
PicturesWall.js
admin-web/src/components/Image/PicturesWall.js
+2
-1
menu.js
admin-web/src/locales/zh-CN/menu.js
+1
-1
BannerList.js
admin-web/src/pages/Promotion/BannerList.js
+19
-15
MVCConfiguration.java
...r/mall/promotion/application/config/MVCConfiguration.java
+4
-4
AdminsBannerController.java
...application/controller/admins/AdminsBannerController.java
+10
-6
AdminsCouponController.java
...application/controller/admins/AdminsCouponController.java
+2
-0
AdminsProductRecommendController.java
...n/controller/admins/AdminsProductRecommendController.java
+2
-0
UsersBannerController.java
...n/application/controller/users/UsersBannerController.java
+2
-2
BannerConvert.java
...der/mall/promotion/application/convert/BannerConvert.java
+19
-13
BannerService.java
...ain/java/cn/iocoder/mall/promotion/api/BannerService.java
+10
-9
BannerServiceImpl.java
...iocoder/mall/promotion/biz/service/BannerServiceImpl.java
+15
-21
没有找到文件。
admin-web/src/components/Image/PicturesWall.js
浏览文件 @
9a3b7087
...
...
@@ -101,7 +101,7 @@ class PicturesWall extends React.Component {
// })
// .catch(onError);
let
key
=
uuid
.
v4
();
// TODO 芋艿,可能后面要优化。MD5?
let
observable
=
qiniu
.
upload
(
e
,
key
,
this
.
state
.
token
);
// TODO 芋艿,最后后面去掉 qiniu 的库依赖,直接 http 请求,这样更轻量
let
observable
=
qiniu
.
upload
(
fil
e
,
key
,
this
.
state
.
token
);
// TODO 芋艿,最后后面去掉 qiniu 的库依赖,直接 http 请求,这样更轻量
observable
.
subscribe
(
function
()
{
// next
},
function
()
{
...
...
@@ -109,6 +109,7 @@ class PicturesWall extends React.Component {
// TODO 芋艿,后续补充
debugger
;
},
function
(
response
)
{
debugger
;
// complete
// debugger;
response
.
url
=
'http://static.shop.iocoder.cn/'
+
response
.
key
;
// 需要设置,用于后续 onSuccess ,合并到 file 中,从而设置到 fileList
...
...
admin-web/src/locales/zh-CN/menu.js
浏览文件 @
9a3b7087
...
...
@@ -55,7 +55,7 @@ export default {
'menu.order.order-list'
:
'订单管理'
,
'menu.order.order-refunds'
:
'退货维权'
,
// 营销相关
'menu.promotion.promotion-banner-list'
:
'
Banner 管理
'
,
'menu.promotion.promotion-banner-list'
:
'
首页广告
'
,
'menu.promotion.product-recommend-list'
:
'商品推荐'
,
'menu.promotion.coupon-card-template-list'
:
'优惠劵管理'
,
};
admin-web/src/pages/Promotion/BannerList.js
浏览文件 @
9a3b7087
...
...
@@ -25,9 +25,9 @@ import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import
styles
from
'./BannerList.less'
;
import
moment
from
"moment"
;
import
PaginationHelper
from
"../../../helpers/PaginationHelper"
;
import
PicturesWall
from
"../../components/Image/PicturesWall"
;
const
FormItem
=
Form
.
Item
;
const
{
TreeNode
}
=
Tree
;
const
status
=
[
'未知'
,
'正常'
,
'禁用'
];
// 列表
...
...
@@ -70,11 +70,13 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
const
columns
=
[
{
title
:
'标题'
,
dataIndex
:
'title'
dataIndex
:
'title'
,
width
:
120
,
},
{
title
:
'跳转链接'
,
dataIndex
:
'url'
,
width
:
120
,
},
{
title
:
'图片'
,
...
...
@@ -97,15 +99,17 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
{
title
:
'备注'
,
dataIndex
:
'memo'
,
width
:
150
,
},
{
title
:
'创建时间'
,
dataIndex
:
'createTime'
,
render
:
val
=>
<
span
>
{
moment
(
val
).
format
(
'YYYY-MM-DD HH:mm'
)}
<
/span>
,
width
:
120
,
render
:
val
=>
<
span
>
{
moment
(
val
).
format
(
'YYYY-MM-DD'
)}
<
/span>
,
},
{
title
:
'操作'
,
width
:
36
0
,
width
:
15
0
,
render
:
(
text
,
record
)
=>
{
const
statusText
=
record
.
status
===
1
?
'禁用'
:
'开启'
;
// TODO 芋艿,此处要改
return
(
...
...
@@ -214,6 +218,7 @@ const SearchForm = Form.create()(props => {
// 添加 or 修改 Form 表单
const
AddOrUpdateForm
=
Form
.
create
()(
props
=>
{
const
{
dispatch
,
modalVisible
,
form
,
handleModalVisible
,
modalType
,
formVals
}
=
props
;
let
picturesWall
=
null
;
const
okHandle
=
()
=>
{
form
.
validateFields
((
err
,
fields
)
=>
{
...
...
@@ -225,6 +230,7 @@ const AddOrUpdateForm = Form.create()(props => {
payload
:
{
body
:
{
...
fields
,
picUrl
:
picturesWall
?
picturesWall
.
getUrl
()
:
undefined
,
},
callback
:
()
=>
{
// 清空表单
...
...
@@ -244,12 +250,13 @@ const AddOrUpdateForm = Form.create()(props => {
body
:
{
id
:
formVals
.
id
,
...
fields
,
picUrl
:
picturesWall
?
picturesWall
.
getUrl
()
:
undefined
,
},
callback
:
()
=>
{
// 清空表单
form
.
resetFields
();
// 提示
message
.
success
(
'
更新
成功'
);
message
.
success
(
'
编辑
成功'
);
// 关闭弹窗
handleModalVisible
();
},
...
...
@@ -259,7 +266,7 @@ const AddOrUpdateForm = Form.create()(props => {
});
};
const
title
=
modalType
===
'add'
?
'新建
Banner'
:
'更新 Banner
'
;
const
title
=
modalType
===
'add'
?
'新建
广告'
:
'编辑广告
'
;
return
(
<
Modal
destroyOnClose
...
...
@@ -286,11 +293,9 @@ const AddOrUpdateForm = Form.create()(props => {
initialValue
:
formVals
.
picUrl
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"图片"
>
{
form
.
getFieldDecorator
(
'picUrl'
,
{
rules
:
[{
required
:
true
,
message
:
'请输入跳转链接!'
},],
initialValue
:
formVals
.
picUrl
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"分类图片"
extra
=
"建议尺寸:640*340px,大小不超过 2M"
required
=
{
true
}
>
<
PicturesWall
urls
=
{
formVals
.
picUrl
?
[
formVals
.
picUrl
]
:
undefined
}
ref
=
{(
node
)
=>
picturesWall
=
node
}
maxLength
=
{
1
}
/
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"排序值"
>
{
form
.
getFieldDecorator
(
'sort'
,
{
...
...
@@ -365,7 +370,7 @@ class BannerList extends PureComponent {
dispatch
,
};
// 添加 or
更新
表单属性
// 添加 or
编辑
表单属性
const
addOrUpdateFormProps
=
{
modalVisible
,
modalType
,
...
...
@@ -387,7 +392,7 @@ class BannerList extends PureComponent {
type
=
"primary"
onClick
=
{()
=>
this
.
handleModalVisible
(
true
,
'add'
,
{})}
>
新建
Banner
新建
广告
<
/Button
>
<
/div
>
<
/div
>
...
...
@@ -401,4 +406,4 @@ class BannerList extends PureComponent {
}
}
export
default
BannerList
;
\ No newline at end of file
export
default
BannerList
;
promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/config/MVCConfiguration.java
浏览文件 @
9a3b7087
...
...
@@ -39,11 +39,11 @@ public class MVCConfiguration implements WebMvcConfigurer {
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
// 用户
registry
.
addInterceptor
(
userAccessLogInterceptor
).
addPathPatterns
(
"/users/**"
);
registry
.
addInterceptor
(
userSecurityInterceptor
).
addPathPatterns
(
"/users/**"
);
// 只拦截我们定义的接口
//
registry.addInterceptor(userAccessLogInterceptor).addPathPatterns("/users/**");
//
registry.addInterceptor(userSecurityInterceptor).addPathPatterns("/users/**"); // 只拦截我们定义的接口
// 管理员
registry
.
addInterceptor
(
adminAccessLogInterceptor
).
addPathPatterns
(
"/admins/**"
);
registry
.
addInterceptor
(
adminSecurityInterceptor
).
addPathPatterns
(
"/admins/**"
);
//
registry.addInterceptor(adminAccessLogInterceptor).addPathPatterns("/admins/**");
//
registry.addInterceptor(adminSecurityInterceptor).addPathPatterns("/admins/**");
}
@Override
...
...
promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsBannerController.java
浏览文件 @
9a3b7087
...
...
@@ -15,14 +15,18 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
static
cn
.
iocoder
.
common
.
framework
.
vo
.
CommonResult
.
success
;
@RestController
@RequestMapping
(
"admins/banner"
)
@Api
(
"Banner 模块"
)
public
class
AdminsBannerController
{
@Reference
(
validation
=
"true"
)
@Autowired
private
BannerService
bannerService
;
@GetMapping
(
"/page"
)
...
...
@@ -35,8 +39,8 @@ public class AdminsBannerController {
public
CommonResult
<
AdminsBannerPageVO
>
page
(
@RequestParam
(
value
=
"title"
,
required
=
false
)
String
title
,
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
Integer
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
)
{
CommonResult
<
BannerPageBO
>
result
=
bannerService
.
getBannerPage
(
new
BannerPageDTO
().
setTitle
(
title
).
setPageNo
(
pageNo
).
setPageSize
(
pageSize
));
return
BannerConvert
.
INSTANCE
.
convert
(
result
);
BannerPageBO
result
=
bannerService
.
getBannerPage
(
new
BannerPageDTO
().
setTitle
(
title
).
setPageNo
(
pageNo
).
setPageSize
(
pageSize
));
return
success
(
BannerConvert
.
ADMINS
.
convert3
(
result
)
);
}
@PostMapping
(
"/add"
)
...
...
@@ -55,7 +59,7 @@ public class AdminsBannerController {
@RequestParam
(
value
=
"memo"
,
required
=
false
)
String
memo
)
{
BannerAddDTO
bannerAddDTO
=
new
BannerAddDTO
().
setTitle
(
title
).
setUrl
(
url
).
setPicUrl
(
picUrl
)
.
setSort
(
sort
).
setMemo
(
memo
);
return
BannerConvert
.
INSTANCE
.
convert2
(
bannerService
.
addBanner
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
bannerAddDTO
));
return
success
(
BannerConvert
.
ADMINS
.
convert
(
bannerService
.
addBanner
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
bannerAddDTO
)
));
}
@PostMapping
(
"/update"
)
...
...
@@ -75,7 +79,7 @@ public class AdminsBannerController {
@RequestParam
(
value
=
"memo"
,
required
=
false
)
String
memo
)
{
BannerUpdateDTO
bannerUpdateDTO
=
new
BannerUpdateDTO
().
setId
(
id
).
setTitle
(
title
).
setUrl
(
url
).
setPicUrl
(
picUrl
)
.
setSort
(
sort
).
setMemo
(
memo
);
return
bannerService
.
updateBanner
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
bannerUpdateDTO
);
return
success
(
bannerService
.
updateBanner
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
bannerUpdateDTO
)
);
}
@PostMapping
(
"/update_status"
)
...
...
@@ -86,14 +90,14 @@ public class AdminsBannerController {
})
public
CommonResult
<
Boolean
>
updateStatus
(
@RequestParam
(
"id"
)
Integer
id
,
@RequestParam
(
"status"
)
Integer
status
)
{
return
bannerService
.
updateBannerStatus
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
id
,
status
);
return
success
(
bannerService
.
updateBannerStatus
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
id
,
status
)
);
}
@PostMapping
(
"/delete"
)
@ApiOperation
(
value
=
"删除 Banner"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"Banner 编号"
,
required
=
true
,
example
=
"1"
)
public
CommonResult
<
Boolean
>
delete
(
@RequestParam
(
"id"
)
Integer
id
)
{
return
bannerService
.
deleteBanner
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
id
);
return
success
(
bannerService
.
deleteBanner
(
AdminSecurityContextHolder
.
getContext
().
getAdminId
(),
id
)
);
}
}
promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponController.java
浏览文件 @
9a3b7087
...
...
@@ -17,6 +17,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -28,6 +29,7 @@ import java.util.Date;
public
class
AdminsCouponController
{
@Reference
(
validation
=
"true"
)
@Autowired
private
CouponService
couponService
;
// ========== 优惠劵(码)模板 ==========
...
...
promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsProductRecommendController.java
浏览文件 @
9a3b7087
...
...
@@ -15,6 +15,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@RestController
...
...
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
public
class
AdminsProductRecommendController
{
@Reference
(
validation
=
"true"
)
@Autowired
private
ProductRecommendService
productRecommendService
;
@GetMapping
(
"/page"
)
...
...
promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/users/UsersBannerController.java
浏览文件 @
9a3b7087
...
...
@@ -30,11 +30,11 @@ public class UsersBannerController {
@PermitAll
public
CommonResult
<
List
<
UsersBannerVO
>>
list
()
{
// 查询 Banner 列表
List
<
BannerBO
>
result
=
bannerService
.
getBannerListByStatus
(
CommonStatusEnum
.
ENABLE
.
getValue
())
.
getData
()
;
List
<
BannerBO
>
result
=
bannerService
.
getBannerListByStatus
(
CommonStatusEnum
.
ENABLE
.
getValue
());
// 排序,按照 sort 升序
result
.
sort
(
Comparator
.
comparing
(
BannerBO:
:
getSort
));
// 返回
return
CommonResult
.
success
(
BannerConvert
.
INSTANCE
.
convertList
(
result
));
return
CommonResult
.
success
(
BannerConvert
.
USERS
.
convertList
(
result
));
}
}
promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/BannerConvert.java
浏览文件 @
9a3b7087
package
cn
.
iocoder
.
mall
.
promotion
.
application
.
convert
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.promotion.api.bo.BannerBO
;
import
cn.iocoder.mall.promotion.api.bo.BannerPageBO
;
import
cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO
;
...
...
@@ -12,21 +11,29 @@ import org.mapstruct.factory.Mappers;
import
java.util.List
;
@Mapper
public
interface
BannerConvert
{
BannerConvert
INSTANCE
=
Mappers
.
getMapper
(
BannerConvert
.
class
);
Users
USERS
=
Mappers
.
getMapper
(
Users
.
class
);
@Mappings
({})
AdminsBannerVO
convert
(
BannerBO
bannerBO
);
Admins
ADMINS
=
Mappers
.
getMapper
(
Admins
.
class
);
@Mapp
ings
({})
CommonResult
<
AdminsBannerVO
>
convert2
(
CommonResult
<
BannerBO
>
result
);
@Mapp
er
interface
Admins
{
@Mappings
({})
CommonResult
<
AdminsBannerPageVO
>
convert
(
CommonResult
<
BannerPageBO
>
result
);
@Mappings
({})
AdminsBannerVO
convert
(
BannerBO
bannerBO
);
@Mappings
({})
List
<
UsersBannerVO
>
convertList
(
List
<
BannerBO
>
banners
);
@Mappings
({})
AdminsBannerPageVO
convert3
(
BannerPageBO
bannerPageBO
);
}
\ No newline at end of file
}
@Mapper
interface
Users
{
@Mappings
({})
List
<
UsersBannerVO
>
convertList
(
List
<
BannerBO
>
banners
);
}
}
promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/BannerService.java
浏览文件 @
9a3b7087
package
cn
.
iocoder
.
mall
.
promotion
.
api
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.common.framework.constant.CommonStatusEnum
;
import
cn.iocoder.common.framework.validator.InEnum
;
import
cn.iocoder.mall.promotion.api.bo.BannerBO
;
import
cn.iocoder.mall.promotion.api.bo.BannerPageBO
;
import
cn.iocoder.mall.promotion.api.dto.BannerAddDTO
;
...
...
@@ -11,16 +12,17 @@ import java.util.List;
public
interface
BannerService
{
CommonResult
<
List
<
BannerBO
>
>
getBannerListByStatus
(
Integer
status
);
List
<
BannerBO
>
getBannerListByStatus
(
Integer
status
);
CommonResult
<
BannerPageBO
>
getBannerPage
(
BannerPageDTO
bannerPageDTO
);
BannerPageBO
getBannerPage
(
BannerPageDTO
bannerPageDTO
);
CommonResult
<
BannerBO
>
addBanner
(
Integer
adminId
,
BannerAddDTO
bannerAddDTO
);
BannerBO
addBanner
(
Integer
adminId
,
BannerAddDTO
bannerAddDTO
);
CommonResult
<
Boolean
>
updateBanner
(
Integer
adminId
,
BannerUpdateDTO
bannerUpdateDTO
);
Boolean
updateBanner
(
Integer
adminId
,
BannerUpdateDTO
bannerUpdateDTO
);
CommonResult
<
Boolean
>
updateBannerStatus
(
Integer
adminId
,
Integer
bannerId
,
Integer
status
);
Boolean
updateBannerStatus
(
Integer
adminId
,
Integer
bannerId
,
@InEnum
(
value
=
CommonStatusEnum
.
class
,
message
=
"修改状态必须是 {value}"
)
Integer
status
);
CommonResult
<
Boolean
>
deleteBanner
(
Integer
adminId
,
Integer
bannerId
);
Boolean
deleteBanner
(
Integer
adminId
,
Integer
bannerId
);
}
\ No newline at end of file
}
promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/BannerServiceImpl.java
浏览文件 @
9a3b7087
...
...
@@ -2,9 +2,7 @@ package cn.iocoder.mall.promotion.biz.service;
import
cn.iocoder.common.framework.constant.CommonStatusEnum
;
import
cn.iocoder.common.framework.constant.DeletedStatusEnum
;
import
cn.iocoder.common.framework.constant.SysErrorCodeEnum
;
import
cn.iocoder.common.framework.util.ServiceExceptionUtil
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.promotion.api.BannerService
;
import
cn.iocoder.mall.promotion.api.bo.BannerBO
;
import
cn.iocoder.mall.promotion.api.bo.BannerPageBO
;
...
...
@@ -29,13 +27,13 @@ public class BannerServiceImpl implements BannerService {
private
BannerMapper
bannerMapper
;
@Override
public
CommonResult
<
List
<
BannerBO
>
>
getBannerListByStatus
(
Integer
status
)
{
public
List
<
BannerBO
>
getBannerListByStatus
(
Integer
status
)
{
List
<
BannerDO
>
banners
=
bannerMapper
.
selectListByStatus
(
status
);
return
CommonResult
.
success
(
BannerConvert
.
INSTANCE
.
convertToBO
(
banners
)
);
return
BannerConvert
.
INSTANCE
.
convertToBO
(
banners
);
}
@Override
public
CommonResult
<
BannerPageBO
>
getBannerPage
(
BannerPageDTO
bannerPageDTO
)
{
public
BannerPageBO
getBannerPage
(
BannerPageDTO
bannerPageDTO
)
{
BannerPageBO
bannerPageBO
=
new
BannerPageBO
();
// 查询分页数据
int
offset
=
(
bannerPageDTO
.
getPageNo
()
-
1
)
*
bannerPageDTO
.
getPageSize
();
...
...
@@ -43,61 +41,57 @@ public class BannerServiceImpl implements BannerService {
offset
,
bannerPageDTO
.
getPageSize
())));
// 查询分页总数
bannerPageBO
.
setTotal
(
bannerMapper
.
selectCountByTitleLike
(
bannerPageDTO
.
getTitle
()));
return
CommonResult
.
success
(
bannerPageBO
)
;
return
bannerPageBO
;
}
@Override
public
CommonResult
<
BannerBO
>
addBanner
(
Integer
adminId
,
BannerAddDTO
bannerAddDTO
)
{
public
BannerBO
addBanner
(
Integer
adminId
,
BannerAddDTO
bannerAddDTO
)
{
// 保存到数据库
BannerDO
banner
=
BannerConvert
.
INSTANCE
.
convert
(
bannerAddDTO
).
setStatus
(
CommonStatusEnum
.
ENABLE
.
getValue
());
banner
.
setDeleted
(
DeletedStatusEnum
.
DELETED_NO
.
getValue
()).
setCreateTime
(
new
Date
());
bannerMapper
.
insert
(
banner
);
// 返回成功
return
CommonResult
.
success
(
BannerConvert
.
INSTANCE
.
convertToBO
(
banner
)
);
return
BannerConvert
.
INSTANCE
.
convertToBO
(
banner
);
}
@Override
public
CommonResult
<
Boolean
>
updateBanner
(
Integer
adminId
,
BannerUpdateDTO
bannerUpdateDTO
)
{
public
Boolean
updateBanner
(
Integer
adminId
,
BannerUpdateDTO
bannerUpdateDTO
)
{
// 校验 Banner 存在
if
(
bannerMapper
.
selectById
(
bannerUpdateDTO
.
getId
())
==
null
)
{
return
ServiceExceptionUtil
.
error
(
PromotionErrorCodeEnum
.
BANNER_NOT_EXISTS
.
getCode
());
throw
ServiceExceptionUtil
.
exception
(
PromotionErrorCodeEnum
.
BANNER_NOT_EXISTS
.
getCode
());
}
// 更新到数据库
BannerDO
updateBanner
=
BannerConvert
.
INSTANCE
.
convert
(
bannerUpdateDTO
);
bannerMapper
.
update
(
updateBanner
);
// 返回成功
return
CommonResult
.
success
(
true
)
;
return
true
;
}
@Override
public
CommonResult
<
Boolean
>
updateBannerStatus
(
Integer
adminId
,
Integer
bannerId
,
Integer
status
)
{
// 校验参数
if
(!
CommonStatusEnum
.
isValid
(
status
))
{
return
CommonResult
.
error
(
SysErrorCodeEnum
.
VALIDATION_REQUEST_PARAM_ERROR
.
getCode
(),
"变更状态必须是开启(1)或关闭(2)"
);
// TODO 有点搓
}
public
Boolean
updateBannerStatus
(
Integer
adminId
,
Integer
bannerId
,
Integer
status
)
{
// 校验 Banner 存在
if
(
bannerMapper
.
selectById
(
bannerId
)
==
null
)
{
return
ServiceExceptionUtil
.
error
(
PromotionErrorCodeEnum
.
BANNER_NOT_EXISTS
.
getCode
());
throw
ServiceExceptionUtil
.
exception
(
PromotionErrorCodeEnum
.
BANNER_NOT_EXISTS
.
getCode
());
}
// 更新到数据库
BannerDO
updateBanner
=
new
BannerDO
().
setId
(
bannerId
).
setStatus
(
status
);
bannerMapper
.
update
(
updateBanner
);
// 返回成功
return
CommonResult
.
success
(
true
)
;
return
true
;
}
@Override
public
CommonResult
<
Boolean
>
deleteBanner
(
Integer
adminId
,
Integer
bannerId
)
{
public
Boolean
deleteBanner
(
Integer
adminId
,
Integer
bannerId
)
{
// 校验 Banner 存在
if
(
bannerMapper
.
selectById
(
bannerId
)
==
null
)
{
return
ServiceExceptionUtil
.
error
(
PromotionErrorCodeEnum
.
BANNER_NOT_EXISTS
.
getCode
());
throw
ServiceExceptionUtil
.
exception
(
PromotionErrorCodeEnum
.
BANNER_NOT_EXISTS
.
getCode
());
}
// 更新到数据库
BannerDO
updateBanner
=
new
BannerDO
().
setId
(
bannerId
);
updateBanner
.
setDeleted
(
DeletedStatusEnum
.
DELETED_YES
.
getValue
());
bannerMapper
.
update
(
updateBanner
);
// 返回成功
return
CommonResult
.
success
(
true
)
;
return
true
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论