Quellcode durchsuchen

feat(backend): 活动工作流缺失端点 + 电商供应商管理CRUD; feat(schema): 同步ecom_supplier表

Xiaogang Liao vor 2 Monaten
Ursprung
Commit
b3738c7a7f

+ 17 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -5720,6 +5720,23 @@ try {
         } catch (Exception e) {
             // 表已存在,忽略错误
         }
+
+        // 迁移94: 创建ecom_supplier表(电商供应商管理)
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS ecom_supplier (" +
+                    "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
+                    "name VARCHAR(100) NOT NULL COMMENT '供应商名称', " +
+                    "contact_name VARCHAR(50) COMMENT '联系人', " +
+                    "contact_phone VARCHAR(20) COMMENT '联系电话', " +
+                    "status TINYINT DEFAULT 1 COMMENT '启用状态 1启用 0禁用', " +
+                    "remark VARCHAR(500) COMMENT '备注', " +
+                    "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
+                    "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" +
+                    ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商供应商'");
+            log.info("已创建ecom_supplier表");
+        } catch (Exception e) {
+            // 表已存在,忽略错误
+        }
     }
 
     private void runMigration89() {

+ 35 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminActivityController.java

@@ -49,4 +49,39 @@ public class AdminActivityController {
         if (activity == null) return Result.error("活动不存在");
         return Result.success(activity);
     }
+
+    @PostMapping("/submit-review")
+    public Result<String> submitReview(@RequestBody Map<String, Object> params) {
+        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        if (id == null) return Result.error("id不能为空");
+        activityAdminService.submitForReview(id);
+        return Result.success("已提交审核");
+    }
+
+    @PostMapping("/audit")
+    public Result<String> audit(@RequestBody Map<String, Object> params,
+                                @RequestAttribute("userId") Long adminId) {
+        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        String action = (String) params.get("action");
+        String rejectReason = (String) params.get("rejectReason");
+        if (id == null || action == null) return Result.error("id和action不能为空");
+        activityAdminService.auditActivity(id, action, rejectReason, adminId);
+        return Result.success("已审核");
+    }
+
+    @PostMapping("/withdraw")
+    public Result<String> withdraw(@RequestBody Map<String, Object> params) {
+        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        if (id == null) return Result.error("id不能为空");
+        activityAdminService.withdraw(id);
+        return Result.success("已撤回");
+    }
+
+    @PostMapping("/re-draft")
+    public Result<String> reDraft(@RequestBody Map<String, Object> params) {
+        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        if (id == null) return Result.error("id不能为空");
+        activityAdminService.reDraft(id);
+        return Result.success("已转为草稿");
+    }
 }

+ 74 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminSupplierController.java

@@ -0,0 +1,74 @@
+package com.etotem.cfc.controller.admin;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.EcomSupplier;
+import com.etotem.cfc.mapper.EcomSupplierMapper;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@Tag(name = "管理端-电商供应商管理")
+@RestController
+@RequestMapping("/api/admin/supplier")
+public class AdminSupplierController {
+
+    @Resource
+    private EcomSupplierMapper ecomSupplierMapper;
+
+    @Operation(summary = "供应商列表")
+    @PostMapping("/list")
+    public Result<Map<String, Object>> list(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        String keyword = (String) params.get("keyword");
+
+        Page<EcomSupplier> pageParam = new Page<>(page, size);
+        LambdaQueryWrapper<EcomSupplier> wrapper = new LambdaQueryWrapper<>();
+        if (keyword != null && !keyword.isEmpty()) {
+            wrapper.like(EcomSupplier::getName, keyword);
+        }
+        wrapper.orderByDesc(EcomSupplier::getCreatedAt);
+        Page<EcomSupplier> result = ecomSupplierMapper.selectPage(pageParam, wrapper);
+
+        Map<String, Object> data = new HashMap<>();
+        data.put("records", result.getRecords());
+        data.put("total", result.getTotal());
+        data.put("page", page);
+        data.put("size", size);
+        return Result.success(data);
+    }
+
+    @Operation(summary = "新增供应商")
+    @PostMapping("/save")
+    public Result<EcomSupplier> save(@RequestBody EcomSupplier supplier) {
+        supplier.setCreatedAt(new Date());
+        supplier.setUpdatedAt(new Date());
+        ecomSupplierMapper.insert(supplier);
+        return Result.success(supplier);
+    }
+
+    @Operation(summary = "更新供应商")
+    @PostMapping("/update")
+    public Result<String> update(@RequestBody EcomSupplier supplier) {
+        if (supplier.getId() == null) return Result.error("id不能为空");
+        supplier.setUpdatedAt(new Date());
+        ecomSupplierMapper.updateById(supplier);
+        return Result.success("ok");
+    }
+
+    @Operation(summary = "删除供应商")
+    @PostMapping("/delete")
+    public Result<String> delete(@RequestBody Map<String, Object> params) {
+        Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
+        if (id == null) return Result.error("id不能为空");
+        ecomSupplierMapper.deleteById(id);
+        return Result.success("ok");
+    }
+}

+ 30 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/EcomSupplier.java

@@ -0,0 +1,30 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName("ecom_supplier")
+public class EcomSupplier {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    private String name;
+
+    private String contactName;
+
+    private String contactPhone;
+
+    private Integer status;
+
+    private String remark;
+
+    private Date createdAt;
+
+    private Date updatedAt;
+}

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/EcomSupplierMapper.java

@@ -0,0 +1,9 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.EcomSupplier;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface EcomSupplierMapper extends BaseMapper<EcomSupplier> {
+}

+ 12 - 0
cfc-backend/src/main/resources/schema.sql

@@ -3874,3 +3874,15 @@ CREATE TABLE IF NOT EXISTS health_meditation_record (
     created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
     INDEX idx_member_id (member_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='冥想打卡记录';
+
+-- 电商供应商
+CREATE TABLE IF NOT EXISTS ecom_supplier (
+    id BIGINT AUTO_INCREMENT PRIMARY KEY,
+    name VARCHAR(100) NOT NULL COMMENT '供应商名称',
+    contact_name VARCHAR(50) COMMENT '联系人',
+    contact_phone VARCHAR(20) COMMENT '联系电话',
+    status TINYINT DEFAULT 1 COMMENT '启用状态 1启用 0禁用',
+    remark VARCHAR(500) COMMENT '备注',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商供应商';