From 58a27586a38636bf0e108b5680cc33ae1a7dc88e Mon Sep 17 00:00:00 2001 From: sonjinyon <2476687577@qq.com> Date: Thu, 14 Nov 2024 19:41:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=B1=8F=E5=B9=BF?= =?UTF-8?q?=E5=91=8A=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/mall/promotion/advertising/index.ts | 50 ++++ yudao-admin-vue3/src/assets/imgs/quxiao.png | Bin 0 -> 4132 bytes .../promotion/advertising/AdvertisingForm.vue | 118 +++++++++ .../mall/promotion/advertising/index.vue | 225 +++++++++++++++++ .../template/dataAllocation/advertising.vue | 228 ++++++++++++++++++ .../advertising/AdvertisingController.java | 102 ++++++++ .../advertising/vo/AdvertisingPageReqVO.java | 32 +++ .../advertising/vo/AdvertisingRespVO.java | 42 ++++ .../advertising/vo/AdvertisingSaveReqVO.java | 32 +++ .../dataobject/advertising/AdvertisingDO.java | 59 +++++ .../mysql/advertising/AdvertisingMapper.java | 29 +++ .../advertising/AdvertisingService.java | 58 +++++ .../advertising/AdvertisingServiceImpl.java | 108 +++++++++ 13 files changed, 1083 insertions(+) create mode 100644 yudao-admin-vue3/src/api/mall/promotion/advertising/index.ts create mode 100644 yudao-admin-vue3/src/assets/imgs/quxiao.png create mode 100644 yudao-admin-vue3/src/views/mall/promotion/advertising/AdvertisingForm.vue create mode 100644 yudao-admin-vue3/src/views/mall/promotion/advertising/index.vue create mode 100644 yudao-admin-vue3/src/views/mall/promotion/diy/template/dataAllocation/advertising.vue create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/AdvertisingController.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingPageReqVO.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingRespVO.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingSaveReqVO.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/advertising/AdvertisingDO.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/advertising/AdvertisingMapper.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingService.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingServiceImpl.java diff --git a/yudao-admin-vue3/src/api/mall/promotion/advertising/index.ts b/yudao-admin-vue3/src/api/mall/promotion/advertising/index.ts new file mode 100644 index 0000000..2756c6e --- /dev/null +++ b/yudao-admin-vue3/src/api/mall/promotion/advertising/index.ts @@ -0,0 +1,50 @@ +import request from '@/config/axios' + +// 开屏广告 VO +export interface AdvertisingVO { + id: number // id + status: number // 广告状态 + time: number // 广告时间(秒) + property: string // 广告属性 + picData: [] + stat: boolean, +} + +// 开屏广告 API +export const AdvertisingApi = { + // 查询开屏广告分页 + getAdvertisingPage: async (params: any) => { + return await request.get({ url: `/promotion/advertising/page`, params }) + }, + + // 查询开屏广告详情 + getAdvertising: async () => { + return await request.get({ url: `/promotion/advertising/getAdvertising`}) + }, + + // 新增开屏广告 + createAdvertising: async (data: AdvertisingVO) => { + return await request.post({ url: `/promotion/advertising/create`, data }) + }, + + // 修改开屏广告 + updateAdvertising: async (data: AdvertisingVO) => { + return await request.put({ url: `/promotion/advertising/update`, data }) + }, + + // 删除开屏广告 + deleteAdvertising: async (id: number) => { + return await request.delete({ url: `/promotion/advertising/delete?id=` + id }) + }, + + // 导出开屏广告 Excel + exportAdvertising: async (params) => { + return await request.download({ url: `/promotion/advertising/export-excel`, params }) + }, + + // 新增修稿开屏广告 + saveAdvertising: async (data: AdvertisingVO) => { + return await request.post({ url: `/promotion/advertising/saveAdvertising`, data }) + }, + +} \ No newline at end of file diff --git a/yudao-admin-vue3/src/assets/imgs/quxiao.png b/yudao-admin-vue3/src/assets/imgs/quxiao.png new file mode 100644 index 0000000000000000000000000000000000000000..b6b0babbb90a3d8c6bce1a4f4c90aefc1d174018 GIT binary patch literal 4132 zcmcgv`8U*W^ncG-8iR;r2@TmvV(etdGGoa)wq&P4N@U5_#E_9?#-2jPkj650$-Yzw z$&#gvrJ;}|AC&#;`$v4gKRoxI^SqwdIrlmD-1|B&yv0o;cBlXp004FrQs3${_x|sJ zFrUT>`^x;&1PZb;(gP}o1eXDTgND-AwFz@x%X?N&Z(xt7%095dryIYtsX>Y3Wl>J3 z1>>~$;dA5tBM<f1Z*+q3k$=q>Gk8;9v9N9|9aZf+d@ z_cJw>WB+J2H)YPT6%6Q8rO{Lq+9t&Z6x80?pwH7&QzBW~g+Vh>KD{urcAl8}O zrCI{*KOYk~`<4>vyGQKzp~q3Y991EZAoDp78*|jnBey4}JGmpb-DLqfc%h zrvANg-2UWtLCM;ZRHYca^el{m``qY&KFS8%FG^TZ`#`SFnVMs&&C`zg~>MjzqD@8@67E zU|naunW%K_fAeLATEPxT3fMib{E7*&yX0znC$bmKm6nLL=MKc#1ai`Dt8)cr#*zhK zU#;#n;h%eaGTCtdv#?0Hl?haL=`P-ilUvzCcU>L zcu()f7wV1bK~G0U&d4{)xia=$I+MRVQU``zP(7>WH1PAqQ+pW7MXm2_g7^j?cpR|F zeP!NuMev#uEQ?3Fe)2)c>b_^iNAtW?PiFlWp|3Jl`#Zlqb%3Fsr+PB!%PI(6EF6YX zwV;@v3X9!NS<5n+eVN`CpFbNi6JFY9WaSU@29wJZ?s?n()t!zM8(hd{;`A?19Ht1%%a04mLB4mdo$lg|~cMTvBI+omiU+`AgLwTk*!({xtF7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otion/advertising/AdvertisingForm.vue new file mode 100644 index 0000000..2cfc310 --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/promotion/advertising/AdvertisingForm.vue @@ -0,0 +1,118 @@ + + \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/mall/promotion/advertising/index.vue b/yudao-admin-vue3/src/views/mall/promotion/advertising/index.vue new file mode 100644 index 0000000..f74e33e --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/promotion/advertising/index.vue @@ -0,0 +1,225 @@ + + + + \ No newline at end of file diff --git a/yudao-admin-vue3/src/views/mall/promotion/diy/template/dataAllocation/advertising.vue b/yudao-admin-vue3/src/views/mall/promotion/diy/template/dataAllocation/advertising.vue new file mode 100644 index 0000000..d1c050c --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/promotion/diy/template/dataAllocation/advertising.vue @@ -0,0 +1,228 @@ + + + + + diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/AdvertisingController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/AdvertisingController.java new file mode 100644 index 0000000..71fa427 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/AdvertisingController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.advertising; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.promotion.controller.admin.advertising.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.advertising.AdvertisingDO; +import cn.iocoder.yudao.module.promotion.service.advertising.AdvertisingService; + +@Tag(name = "管理后台 - 开屏广告") +@RestController +@RequestMapping("/promotion/advertising") +@Validated +public class AdvertisingController { + + @Resource + private AdvertisingService advertisingService; + + @PostMapping("/create") + @Operation(summary = "创建开屏广告") + @PreAuthorize("@ss.hasPermission('promotion:advertising:create')") + public CommonResult createAdvertising(@Valid @RequestBody AdvertisingSaveReqVO createReqVO) { + return success(advertisingService.createAdvertising(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新开屏广告") + @PreAuthorize("@ss.hasPermission('promotion:advertising:update')") + public CommonResult updateAdvertising(@Valid @RequestBody AdvertisingSaveReqVO updateReqVO) { + advertisingService.updateAdvertising(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除开屏广告") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('promotion:advertising:delete')") + public CommonResult deleteAdvertising(@RequestParam("id") Long id) { + advertisingService.deleteAdvertising(id); + return success(true); + } + + + @GetMapping("/page") + @Operation(summary = "获得开屏广告分页") + @PreAuthorize("@ss.hasPermission('promotion:advertising:query')") + public CommonResult> getAdvertisingPage(@Valid AdvertisingPageReqVO pageReqVO) { + PageResult pageResult = advertisingService.getAdvertisingPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, AdvertisingRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出开屏广告 Excel") + @PreAuthorize("@ss.hasPermission('promotion:advertising:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportAdvertisingExcel(@Valid AdvertisingPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = advertisingService.getAdvertisingPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "开屏广告.xls", "数据", AdvertisingRespVO.class, + BeanUtils.toBean(list, AdvertisingRespVO.class)); + } + + + //添加修改开屏广告 + @PostMapping("/saveAdvertising") + public CommonResult saveAdvertising(@Valid @RequestBody AdvertisingSaveReqVO createReqVO) { + return success(advertisingService.saveAdvertising(createReqVO)); + } + + @GetMapping("/getAdvertising") + public CommonResult getAdvertising() { + AdvertisingDO advertising = advertisingService.getAdvertising(); + return success(BeanUtils.toBean(advertising, AdvertisingRespVO.class)); + } + + + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingPageReqVO.java new file mode 100644 index 0000000..273f6a8 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingPageReqVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.advertising.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 开屏广告分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class AdvertisingPageReqVO extends PageParam { + + @Schema(description = "广告状态", example = "2") + private Integer status; + + @Schema(description = "广告时间(秒)") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private Integer[] time; + + @Schema(description = "广告属性") + private String property; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingRespVO.java new file mode 100644 index 0000000..032034d --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingRespVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.advertising.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 开屏广告 Response VO") +@Data +@ExcelIgnoreUnannotated +public class AdvertisingRespVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "684") + @ExcelProperty("id") + private Long id; + + @Schema(description = "广告状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty(value = "广告状态", converter = DictConvert.class) + @DictFormat("promotion_diy_advertising") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer status; + + @Schema(description = "广告时间(秒)", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("广告时间(秒)") + private Integer time; + + @Schema(description = "广告属性", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("广告属性") + private String property; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + private List picData; + + private Boolean stat; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingSaveReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingSaveReqVO.java new file mode 100644 index 0000000..99fd068 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/advertising/vo/AdvertisingSaveReqVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.promotion.controller.admin.advertising.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 开屏广告新增/修改 Request VO") +@Data +public class AdvertisingSaveReqVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "684") + private Long id; + + @Schema(description = "广告状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + private Integer status; + + @Schema(description = "广告时间(秒)", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "广告时间(秒)不能为空") + private Integer time; + + @Schema(description = "广告属性", requiredMode = Schema.RequiredMode.REQUIRED) + private String property; + + @Schema(description = "图片添加不能为空", requiredMode = Schema.RequiredMode.REQUIRED) + private List picData; + + private Boolean stat; + + + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/advertising/AdvertisingDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/advertising/AdvertisingDO.java new file mode 100644 index 0000000..4f31b6c --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/advertising/AdvertisingDO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.promotion.dal.dataobject.advertising; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 开屏广告 DO + * + * @author 管理员 + */ +@TableName("promotion_diy_template_advertising") +@KeySequence("promotion_diy_template_advertising_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AdvertisingDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 广告状态 + * + * 枚举 {@link TODO promotion_diy_advertising 对应的类} + */ + private Integer status; + /** + * 广告时间(秒) + */ + private Integer time; + /** + * 广告属性 + */ + private String property; + + + /** + * 图片数据 + */ + @TableField(exist = false) + private List picData; + + /** + * 开屏状态 + */ + @TableField(exist = false) + private Boolean stat; + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/advertising/AdvertisingMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/advertising/AdvertisingMapper.java new file mode 100644 index 0000000..bc0f1e4 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/advertising/AdvertisingMapper.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.promotion.dal.mysql.advertising; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.promotion.dal.dataobject.advertising.AdvertisingDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.promotion.controller.admin.advertising.vo.*; + +/** + * 开屏广告 Mapper + * + * @author 管理员 + */ +@Mapper +public interface AdvertisingMapper extends BaseMapperX { + + default PageResult selectPage(AdvertisingPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(AdvertisingDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(AdvertisingDO::getTime, reqVO.getTime()) + .eqIfPresent(AdvertisingDO::getProperty, reqVO.getProperty()) + .betweenIfPresent(AdvertisingDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(AdvertisingDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingService.java new file mode 100644 index 0000000..83124c4 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingService.java @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.promotion.service.advertising; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.promotion.controller.admin.advertising.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.advertising.AdvertisingDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 开屏广告 Service 接口 + * + * @author 管理员 + */ +public interface AdvertisingService { + + /** + * 创建开屏广告 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createAdvertising(@Valid AdvertisingSaveReqVO createReqVO); + + /** + * 更新开屏广告 + * + * @param updateReqVO 更新信息 + */ + void updateAdvertising(@Valid AdvertisingSaveReqVO updateReqVO); + + /** + * 删除开屏广告 + * + * @param id 编号 + */ + void deleteAdvertising(Long id); + + /** + * 获得开屏广告 + * + * @return 开屏广告 + */ + AdvertisingDO getAdvertising(); + + /** + * 获得开屏广告分页 + * + * @param pageReqVO 分页查询 + * @return 开屏广告分页 + */ + PageResult getAdvertisingPage(AdvertisingPageReqVO pageReqVO); + + + Long saveAdvertising(@Valid AdvertisingSaveReqVO createReqVO); + + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingServiceImpl.java new file mode 100644 index 0000000..a89010a --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/advertising/AdvertisingServiceImpl.java @@ -0,0 +1,108 @@ +package cn.iocoder.yudao.module.promotion.service.advertising; + +import com.alibaba.fastjson.JSON; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import javax.validation.Valid; + +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.promotion.controller.admin.advertising.vo.*; +import cn.iocoder.yudao.module.promotion.dal.dataobject.advertising.AdvertisingDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.promotion.dal.mysql.advertising.AdvertisingMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; + +/** + * 开屏广告 Service 实现类 + * + * @author 管理员 + */ +@Service +@Validated +public class AdvertisingServiceImpl implements AdvertisingService { + + @Resource + private AdvertisingMapper advertisingMapper; + + @Override + public Long createAdvertising(AdvertisingSaveReqVO createReqVO) { + // 插入 + AdvertisingDO advertising = BeanUtils.toBean(createReqVO, AdvertisingDO.class); + advertisingMapper.insert(advertising); + // 返回 + return advertising.getId(); + } + + @Override + public void updateAdvertising(AdvertisingSaveReqVO updateReqVO) { + // 校验存在 + validateAdvertisingExists(updateReqVO.getId()); + // 更新 + AdvertisingDO updateObj = BeanUtils.toBean(updateReqVO, AdvertisingDO.class); + advertisingMapper.updateById(updateObj); + } + + @Override + public void deleteAdvertising(Long id) { + // 校验存在 + validateAdvertisingExists(id); + // 删除 + advertisingMapper.deleteById(id); + } + + private void validateAdvertisingExists(Long id) { + if (advertisingMapper.selectById(id) == null) { + throw exception(ADVERTISING_NOT_EXISTS); + } + } + + @Override + public AdvertisingDO getAdvertising() { + List advertisingDOS = advertisingMapper.selectList(); + if (advertisingDOS.isEmpty()){ + return new AdvertisingDO(); + } + AdvertisingDO advertisingDO = advertisingDOS.get(0); + advertisingDO.setPicData(JSON.parseArray(advertisingDO.getProperty())); + if (advertisingDO.getStatus() == 1){ + advertisingDO.setStat(true); + } + if (advertisingDO.getStatus() == 2){ + advertisingDO.setStat(false); + } + + return advertisingDO; + } + + @Override + public PageResult getAdvertisingPage(AdvertisingPageReqVO pageReqVO) { + return advertisingMapper.selectPage(pageReqVO); + } + + @Override + public Long saveAdvertising(@Valid AdvertisingSaveReqVO createReqVO) { + if (createReqVO.getStat()){ + createReqVO.setStatus(1); + }else { + createReqVO.setStatus(2); + } + List advertisingDOS = advertisingMapper.selectList(); + if (advertisingDOS.isEmpty()){ + createReqVO.setProperty(JSON.toJSONString(createReqVO.getPicData())); + AdvertisingDO advertising = BeanUtils.toBean(createReqVO, AdvertisingDO.class); + return (long) advertisingMapper.insert(advertising); + } + AdvertisingDO advertisingDO = advertisingDOS.get(0); + advertisingDO.setProperty(JSON.toJSONString(createReqVO.getPicData())); + return (long)advertisingMapper.updateById(advertisingDO); + } + +} \ No newline at end of file