Selaa lähdekoodia

微信/支付宝退款feign

LuTong 3 kuukautta sitten
vanhempi
commit
e640bcf4e4

+ 59 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/PlatformStoreDiscussionController.java

@@ -0,0 +1,59 @@
+package shop.alien.storeplatform.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.storeplatform.entity.StoreDiscussion;
+import shop.alien.storeplatform.service.StoreDiscussionService;
+
+import java.util.List;
+
+/**
+ * 商户平台-店铺讨论控制器
+ *
+ * @author alien
+ * @since 2025-12-30
+ */
+@Slf4j
+@Api(tags = {"商户平台-店铺讨论"})
+@RestController
+@RequestMapping("/platformStoreDiscussion")
+@RequiredArgsConstructor
+public class PlatformStoreDiscussionController {
+
+    private final StoreDiscussionService storeDiscussionService;
+
+    @ApiOperation("发表讨论或回复")
+    @PostMapping("/post")
+    public R<Boolean> post(@RequestBody StoreDiscussion discussion) {
+        log.info("PlatformStoreDiscussionController.post?discussion={}", discussion);
+        try {
+            boolean success = storeDiscussionService.postDiscussion(discussion);
+            return success ? R.success("发表成功") : R.fail("发表失败");
+        } catch (Exception e) {
+            log.error("发表讨论失败", e);
+            return R.fail(e.getMessage());
+        }
+    }
+
+    @ApiOperation("获取店铺讨论列表")
+    @GetMapping("/list")
+    public R<List<StoreDiscussion>> list(
+            @ApiParam(value = "店铺ID", required = true) @RequestParam Integer storeId) {
+        log.info("PlatformStoreDiscussionController.list?storeId={}", storeId);
+        return R.data(storeDiscussionService.listByStoreId(storeId));
+    }
+
+    @ApiOperation("删除讨论")
+    @DeleteMapping("/delete/{id}")
+    public R<Boolean> delete(@PathVariable Integer id) {
+        log.info("PlatformStoreDiscussionController.delete?id={}", id);
+        boolean success = storeDiscussionService.removeById(id);
+        return success ? R.success("删除成功") : R.fail("删除失败");
+    }
+}
+

+ 65 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/entity/StoreDiscussion.java

@@ -0,0 +1,65 @@
+package shop.alien.storeplatform.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 店铺讨论表
+ *
+ * @author alien
+ * @since 2025-12-30
+ */
+@Data
+@TableName("store_discussion")
+@ApiModel(value = "StoreDiscussion对象", description = "店铺讨论表")
+public class StoreDiscussion {
+
+    @ApiModelProperty(value = "主键")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "店铺ID")
+    @TableField("store_id")
+    private Integer storeId;
+
+    @ApiModelProperty(value = "用户ID")
+    @TableField("user_id")
+    private Integer userId;
+
+    @ApiModelProperty(value = "讨论内容")
+    @TableField("content")
+    private String content;
+
+    @ApiModelProperty(value = "父级讨论ID (用于回复)")
+    @TableField("parent_id")
+    private Integer parentId;
+
+    @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;
+}
+

+ 17 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/mapper/StoreDiscussionMapper.java

@@ -0,0 +1,17 @@
+package shop.alien.storeplatform.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import shop.alien.storeplatform.entity.StoreDiscussion;
+
+/**
+ * 店铺讨论表 Mapper 接口
+ *
+ * @author alien
+ * @since 2025-12-30
+ */
+@Mapper
+public interface StoreDiscussionMapper extends BaseMapper<StoreDiscussion> {
+
+}
+

+ 30 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/StoreDiscussionService.java

@@ -0,0 +1,30 @@
+package shop.alien.storeplatform.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.storeplatform.entity.StoreDiscussion;
+
+import java.util.List;
+
+/**
+ * 店铺讨论表 服务类
+ *
+ * @author alien
+ * @since 2025-12-30
+ */
+public interface StoreDiscussionService extends IService<StoreDiscussion> {
+
+    /**
+     * 根据店铺ID查询讨论列表
+     * @param storeId 店铺ID
+     * @return 讨论列表
+     */
+    List<StoreDiscussion> listByStoreId(Integer storeId);
+
+    /**
+     * 发表讨论/回复
+     * @param discussion 讨论信息
+     * @return 是否成功
+     */
+    boolean postDiscussion(StoreDiscussion discussion);
+}
+

+ 36 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StoreDiscussionServiceImpl.java

@@ -0,0 +1,36 @@
+package shop.alien.storeplatform.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import shop.alien.storeplatform.entity.StoreDiscussion;
+import shop.alien.storeplatform.mapper.StoreDiscussionMapper;
+import shop.alien.storeplatform.service.StoreDiscussionService;
+
+import java.util.List;
+
+/**
+ * 店铺讨论表 服务实现类
+ *
+ * @author alien
+ * @since 2025-12-30
+ */
+@Service
+public class StoreDiscussionServiceImpl extends ServiceImpl<StoreDiscussionMapper, StoreDiscussion> implements StoreDiscussionService {
+
+    @Override
+    public List<StoreDiscussion> listByStoreId(Integer storeId) {
+        return this.list(new LambdaQueryWrapper<StoreDiscussion>()
+                .eq(StoreDiscussion::getStoreId, storeId)
+                .orderByDesc(StoreDiscussion::getCreatedTime));
+    }
+
+    @Override
+    public boolean postDiscussion(StoreDiscussion discussion) {
+        if (discussion.getParentId() == null) {
+            discussion.setParentId(0);
+        }
+        return this.save(discussion);
+    }
+}
+

+ 170 - 0
alien-store-platform/接口文档/36-店铺问答讨论模块接口.md

@@ -0,0 +1,170 @@
+# 商户平台-店铺讨论模块接口文档
+
+## 模块概述
+
+本模块提供店铺讨论功能,允许用户在商户平台上针对特定店铺发表讨论、回复他人讨论,并支持讨论的列表查询和删除。类似于论坛功能,旨在增强用户与店铺之间的互动。
+
+---
+
+## 接口列表
+
+1. [发表讨论/回复](#接口一发表讨论回复) - 用户发表新讨论或回复已有讨论
+2. [获取店铺讨论列表](#接口二获取店铺讨论列表) - 查询指定店铺的所有讨论记录
+3. [删除讨论](#接口三删除讨论) - 根据ID逻辑删除讨论记录
+
+---
+
+## 接口一:发表讨论/回复
+
+### 接口信息
+
+- **接口名称**: 发表讨论/回复
+- **接口路径**: `POST /platformStoreDiscussion/post`
+- **请求方式**: POST
+- **接口描述**: 用户对店铺发表主贴讨论,或对已有讨论进行回复。
+
+### 请求参数
+
+| 参数名 | 类型 | 必填 | 说明 |
+|--------|------|------|------|
+| storeId | Integer | 是 | 店铺ID |
+| userId | Integer | 是 | 用户ID |
+| content | String | 是 | 讨论内容 |
+| parentId | Integer | 否 | 父级讨论ID (发表主贴填0或不传,回复填被回复ID) |
+
+### 请求示例
+
+```json
+{
+    "storeId": 1,
+    "userId": 1001,
+    "content": "这家店的服务非常到位,强烈推荐!",
+    "parentId": 0
+}
+```
+
+### 响应参数
+
+```json
+{
+    "code": 200,
+    "success": true,
+    "data": true,
+    "msg": "发表成功"
+}
+```
+
+---
+
+## 接口二:获取店铺讨论列表
+
+### 接口信息
+
+- **接口名称**: 获取店铺讨论列表
+- **接口路径**: `GET /platformStoreDiscussion/list`
+- **请求方式**: GET
+- **接口描述**: 获取指定店铺下的所有讨论记录,按创建时间倒序排列。
+
+### 请求参数
+
+| 参数名 | 类型 | 必填 | 说明 |
+|--------|------|------|------|
+| storeId | Integer | 是 | 店铺ID |
+
+### 请求示例
+
+```http
+GET /platformStoreDiscussion/list?storeId=1
+```
+
+### 响应参数
+
+```json
+{
+    "code": 200,
+    "success": true,
+    "data": [
+        {
+            "id": 1,
+            "storeId": 1,
+            "userId": 1001,
+            "content": "这家店的服务非常到位,强烈推荐!",
+            "parentId": 0,
+            "deleteFlag": 0,
+            "createdTime": "2025-12-30 14:00:00",
+            "createdUserId": 1001,
+            "updatedTime": "2025-12-30 14:00:00",
+            "updatedUserId": null
+        }
+    ],
+    "msg": "操作成功"
+}
+```
+
+---
+
+## 接口三:删除讨论
+
+### 接口信息
+
+- **接口名称**: 删除讨论
+- **接口路径**: `DELETE /platformStoreDiscussion/delete/{id}`
+- **请求方式**: DELETE
+- **接口描述**: 根据讨论ID逻辑删除该条记录。
+
+### 请求参数
+
+| 参数名 | 类型 | 必填 | 说明 |
+|--------|------|------|------|
+| id | Integer | 是 | 讨论记录ID (路径参数) |
+
+### 请求示例
+
+```http
+DELETE /platformStoreDiscussion/delete/1
+```
+
+### 响应参数
+
+```json
+{
+    "code": 200,
+    "success": true,
+    "data": true,
+    "msg": "删除成功"
+}
+```
+
+---
+
+## 业务规则说明
+
+1. **父子关系**: 
+   - `parentId` 为 `0` 或 `null` 表示该记录是一条独立的讨论(主贴)。
+   - `parentId` 大于 `0` 表示该记录是对另一条讨论的回复。
+2. **删除逻辑**: 采用逻辑删除,更新 `delete_flag` 字段为 `1`。
+3. **排序规则**: 列表接口默认按 `created_time` 倒序排列,确保最新的讨论显示在最前面。
+
+---
+
+## 数据库设计 (`store_discussion`)
+
+| 字段名 | 类型 | 说明 |
+|--------|------|------|
+| id | int | 主键,自增 |
+| store_id | int | 店铺ID |
+| user_id | int | 用户ID |
+| content | text | 讨论内容 |
+| parent_id | int | 父级讨论ID,默认为0 |
+| delete_flag | tinyint | 删除标记 (0:未删除, 1:已删除) |
+| created_time | datetime | 创建时间 |
+| created_user_id | int | 创建人ID |
+| updated_time | datetime | 修改时间 |
+| updated_user_id | int | 修改人ID |
+
+---
+
+**文档版本**: v1.0  
+**最后更新**: 2025-12-30  
+**维护人员**: alien
+