Parcourir la source

生成store_video实体类以及接口

ldz il y a 3 mois
Parent
commit
ac3489dafd

+ 74 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreVideo.java

@@ -0,0 +1,74 @@
+package shop.alien.entity.store;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 门店视频
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@JsonInclude
+@TableName("store_video")
+@ApiModel(value = "StoreVideo对象", description = "门店视频")
+public class StoreVideo extends Model<StoreVideo> {
+
+    @ApiModelProperty(value = "主键")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "门店id")
+    @TableField("store_id")
+    private Integer storeId;
+
+    @ApiModelProperty(value = "视频描述")
+    @TableField("img_description")
+    private String imgDescription;
+
+    @ApiModelProperty(value = "视频排序")
+    @TableField("img_sort")
+    private Integer imgSort;
+
+    @ApiModelProperty(value = "视频链接")
+    @TableField("img_url")
+    private String imgUrl;
+
+    @ApiModelProperty(value = "删除标记, 0:未删除, 1:已删除")
+    @TableField("delete_flag")
+    @TableLogic
+    private Integer deleteFlag;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createdTime;
+
+    @ApiModelProperty(value = "创建人ID")
+    @TableField("created_user_id")
+    private Integer createdUserId;
+
+    @ApiModelProperty(value = "修改时间")
+    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updatedTime;
+
+    @ApiModelProperty(value = "修改人ID")
+    @TableField("updated_user_id")
+    private Integer updatedUserId;
+
+    @ApiModelProperty(value = "业务ID|相册(store_official_album)ID")
+    @TableField("business_id")
+    private Integer businessId;
+}
+

+ 16 - 0
alien-entity/src/main/java/shop/alien/mapper/StoreVideoMapper.java

@@ -0,0 +1,16 @@
+package shop.alien.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import shop.alien.entity.store.StoreVideo;
+
+/**
+ * 门店视频 Mapper 接口
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Mapper
+public interface StoreVideoMapper extends BaseMapper<StoreVideo> {
+}
+

+ 176 - 0
alien-store/src/main/java/shop/alien/store/controller/StoreVideoController.java

@@ -0,0 +1,176 @@
+package shop.alien.store.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.StoreVideo;
+import shop.alien.store.service.StoreVideoService;
+
+import java.util.List;
+
+/**
+ * 门店视频Controller
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Slf4j
+@Api(tags = {"门店视频"})
+@ApiSort(6)
+@CrossOrigin
+@RestController
+@RequestMapping("/video")
+@RequiredArgsConstructor
+public class StoreVideoController {
+    private final StoreVideoService storeVideoService;
+
+    @ApiOperation("新增视频")
+    @ApiOperationSupport(order = 1)
+    @PostMapping("/save")
+    public R<String> save(@RequestBody StoreVideo storeVideo) {
+        log.info("StoreVideoController.save?storeVideo={}", storeVideo);
+        if (storeVideoService.save(storeVideo)) {
+            return R.success("新增成功");
+        }
+        return R.fail("新增失败");
+    }
+
+    @ApiOperation("批量新增视频")
+    @ApiOperationSupport(order = 2)
+    @PostMapping("/saveBatch")
+    public R<String> saveBatch(@RequestBody List<StoreVideo> storeVideoList) {
+        log.info("StoreVideoController.saveBatch?storeVideoList={}", storeVideoList);
+        if (storeVideoService.saveBatch(storeVideoList)) {
+            return R.success("批量新增成功");
+        }
+        return R.fail("批量新增失败");
+    }
+
+    @ApiOperation("修改视频")
+    @ApiOperationSupport(order = 3)
+    @PostMapping("/update")
+    public R<String> update(@RequestBody StoreVideo storeVideo) {
+        log.info("StoreVideoController.update?storeVideo={}", storeVideo);
+        if (storeVideoService.updateById(storeVideo)) {
+            return R.success("修改成功");
+        }
+        return R.fail("修改失败");
+    }
+
+    @ApiOperation("新增或修改视频")
+    @ApiOperationSupport(order = 4)
+    @PostMapping("/saveOrUpdate")
+    public R<String> saveOrUpdate(@RequestBody StoreVideo storeVideo) {
+        log.info("StoreVideoController.saveOrUpdate?storeVideo={}", storeVideo);
+        if (storeVideoService.saveOrUpdate(storeVideo)) {
+            if (storeVideo.getId() != null) {
+                return R.success("修改成功");
+            }
+            return R.success("新增成功");
+        }
+        return R.fail("操作失败");
+    }
+
+    @ApiOperation("批量新增或修改视频")
+    @ApiOperationSupport(order = 5)
+    @PostMapping("/saveOrUpdateBatch")
+    public R<String> saveOrUpdateBatch(@RequestBody List<StoreVideo> storeVideoList) {
+        log.info("StoreVideoController.saveOrUpdateBatch?storeVideoList={}", storeVideoList);
+        if (storeVideoService.saveOrUpdateBatch(storeVideoList)) {
+            return R.success("批量操作成功");
+        }
+        return R.fail("批量操作失败");
+    }
+
+    @ApiOperation("根据ID删除视频")
+    @ApiOperationSupport(order = 6)
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "视频ID", dataType = "Integer", paramType = "query", required = true)})
+    @PostMapping("/deleteById")
+    public R<String> deleteById(Integer id) {
+        log.info("StoreVideoController.deleteById?id={}", id);
+        if (storeVideoService.removeById(id)) {
+            return R.success("删除成功");
+        }
+        return R.fail("删除失败");
+    }
+
+    @ApiOperation("批量删除视频")
+    @ApiOperationSupport(order = 7)
+    @PostMapping("/deleteBatch")
+    public R<String> deleteBatch(@RequestBody List<Integer> ids) {
+        log.info("StoreVideoController.deleteBatch?ids={}", ids);
+        if (storeVideoService.removeByIds(ids)) {
+            return R.success("批量删除成功");
+        }
+        return R.fail("批量删除失败");
+    }
+
+    @ApiOperation("根据ID查询视频")
+    @ApiOperationSupport(order = 8)
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "视频ID", dataType = "Integer", paramType = "query", required = true)})
+    @GetMapping("/getById")
+    public R<StoreVideo> getById(Integer id) {
+        log.info("StoreVideoController.getById?id={}", id);
+        StoreVideo storeVideo = storeVideoService.getById(id);
+        if (storeVideo != null) {
+            return R.data(storeVideo);
+        }
+        return R.fail("未找到数据");
+    }
+
+    @ApiOperation("根据门店ID查询视频列表")
+    @ApiOperationSupport(order = 9)
+    @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "Integer", paramType = "query", required = true)})
+    @GetMapping("/getByStoreId")
+    public R<List<StoreVideo>> getByStoreId(Integer storeId) {
+        log.info("StoreVideoController.getByStoreId?storeId={}", storeId);
+        return R.data(storeVideoService.getByStoreId(storeId));
+    }
+
+    @ApiOperation("根据门店ID和业务ID查询视频列表")
+    @ApiOperationSupport(order = 10)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "businessId", value = "业务ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/getByStoreIdAndBusinessId")
+    public R<List<StoreVideo>> getByStoreIdAndBusinessId(Integer storeId, Integer businessId) {
+        log.info("StoreVideoController.getByStoreIdAndBusinessId?storeId={}&businessId={}", storeId, businessId);
+        return R.data(storeVideoService.getByStoreIdAndBusinessId(storeId, businessId));
+    }
+
+    @ApiOperation("分页查询视频列表")
+    @ApiOperationSupport(order = 11)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "current", value = "当前页", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "size", value = "每页数量", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "Integer", paramType = "query", required = false),
+            @ApiImplicitParam(name = "businessId", value = "业务ID", dataType = "Integer", paramType = "query", required = false)
+    })
+    @GetMapping("/page")
+    public R<IPage<StoreVideo>> page(Integer current, Integer size, Integer storeId, Integer businessId) {
+        log.info("StoreVideoController.page?current={}&size={}&storeId={}&businessId={}", current, size, storeId, businessId);
+        Page<StoreVideo> page = new Page<>(current, size);
+        LambdaQueryWrapper<StoreVideo> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(storeId != null, StoreVideo::getStoreId, storeId)
+                .eq(businessId != null, StoreVideo::getBusinessId, businessId)
+                .orderByAsc(StoreVideo::getImgSort)
+                .orderByDesc(StoreVideo::getCreatedTime);
+        IPage<StoreVideo> result = storeVideoService.page(page, queryWrapper);
+        return R.data(result);
+    }
+
+    @ApiOperation("查询所有视频列表")
+    @ApiOperationSupport(order = 12)
+    @GetMapping("/list")
+    public R<List<StoreVideo>> list() {
+        log.info("StoreVideoController.list");
+        return R.data(storeVideoService.list());
+    }
+}
+

+ 33 - 0
alien-store/src/main/java/shop/alien/store/service/StoreVideoService.java

@@ -0,0 +1,33 @@
+package shop.alien.store.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.store.StoreVideo;
+
+import java.util.List;
+
+/**
+ * 门店视频 服务类
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+public interface StoreVideoService extends IService<StoreVideo> {
+
+    /**
+     * 根据门店ID获取视频列表
+     *
+     * @param storeId 门店id
+     * @return 视频列表
+     */
+    List<StoreVideo> getByStoreId(Integer storeId);
+
+    /**
+     * 根据门店ID和业务ID获取视频列表
+     *
+     * @param storeId 门店id
+     * @param businessId 业务ID
+     * @return 视频列表
+     */
+    List<StoreVideo> getByStoreIdAndBusinessId(Integer storeId, Integer businessId);
+}
+

+ 57 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreVideoServiceImpl.java

@@ -0,0 +1,57 @@
+package shop.alien.store.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import shop.alien.entity.store.StoreVideo;
+import shop.alien.mapper.StoreVideoMapper;
+import shop.alien.store.service.StoreVideoService;
+
+import java.util.List;
+
+/**
+ * 门店视频 服务实现类
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Slf4j
+@Transactional
+@Service
+@RequiredArgsConstructor
+public class StoreVideoServiceImpl extends ServiceImpl<StoreVideoMapper, StoreVideo> implements StoreVideoService {
+
+    /**
+     * 根据门店ID获取视频列表
+     *
+     * @param storeId 门店id
+     * @return 视频列表
+     */
+    @Override
+    public List<StoreVideo> getByStoreId(Integer storeId) {
+        LambdaQueryWrapper<StoreVideo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(StoreVideo::getStoreId, storeId)
+                .orderByAsc(StoreVideo::getImgSort);
+        return this.list(lambdaQueryWrapper);
+    }
+
+    /**
+     * 根据门店ID和业务ID获取视频列表
+     *
+     * @param storeId 门店id
+     * @param businessId 业务ID
+     * @return 视频列表
+     */
+    @Override
+    public List<StoreVideo> getByStoreIdAndBusinessId(Integer storeId, Integer businessId) {
+        LambdaQueryWrapper<StoreVideo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(StoreVideo::getStoreId, storeId)
+                .eq(StoreVideo::getBusinessId, businessId)
+                .orderByAsc(StoreVideo::getImgSort);
+        return this.list(lambdaQueryWrapper);
+    }
+}
+