From f0b7c9e0c68616ae33cbc147fb409658ec6cdb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Tue, 16 Sep 2025 23:26:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(shop):=20=E9=87=8D=E6=9E=84=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E7=9B=B8=E5=85=B3=E5=AE=9E=E4=BD=93=E5=92=8C=E6=98=A0?= =?UTF-8?q?=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -移除了 UserServiceImpl 中的系统配置信息代码 - 更新了 ShopChatConversationController 中的注释 - 在 ShopChatMessage 中添加了发送人和接收人的相关信息字段 - 在 ShopDealerApply 中添加了用户昵称和备注字段 - 更新了相关映射文件以支持新的字段 - 调整了应用配置文件,增加了测试环境配置 --- .../system/service/impl/UserServiceImpl.java | 12 ---- .../ShopChatConversationController.java | 24 ++++--- .../controller/ShopChatMessageController.java | 18 +++-- .../shop/entity/ShopChatMessage.java | 33 ++++++++++ .../shop/entity/ShopDealerApply.java | 12 ++++ .../shop/entity/ShopDealerReferee.java | 4 ++ .../shop/mapper/xml/ShopChatMessageMapper.xml | 5 +- .../shop/mapper/xml/ShopDealerApplyMapper.xml | 4 +- .../mapper/xml/ShopDealerRefereeMapper.xml | 1 + src/main/resources/application-dev.yml | 9 +-- src/main/resources/application-prod.yml | 2 +- src/main/resources/application-test.yml | 65 +++++++++++++++++++ src/main/resources/application.yml | 2 +- 13 files changed, 151 insertions(+), 40 deletions(-) create mode 100644 src/main/resources/application-test.yml diff --git a/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java b/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java index 7a04c19..b321832 100644 --- a/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java +++ b/src/main/java/com/gxwebsoft/common/system/service/impl/UserServiceImpl.java @@ -87,18 +87,6 @@ public class UserServiceImpl extends ServiceImpl implements Us if (user != null) { user.setRoles(userRoleService.listByUserId(user.getUserId())); user.setAuthorities(roleMenuService.listMenuByUserId(user.getUserId(), null)); - // 系统配置信息 -// Map map = new HashMap<>(); - // 1)云存储 -// String key = "setting:upload:" + user.getTenantId(); -// final String upload = redisUtil.get(key); -// if(upload != null){ -// final JSONObject object = JSONObject.parseObject(upload); -// map.put("uploadMethod",object.getString("uploadMethod")); -// map.put("bucketDomain",object.getString("bucketDomain")); -// map.put("fileUrl",object.getString("fileUrl") + "/"); -// user.setSystem(map); -// } } return user; } diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopChatConversationController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopChatConversationController.java index 9ef5377..7e84a9d 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/ShopChatConversationController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopChatConversationController.java @@ -6,9 +6,7 @@ import com.gxwebsoft.shop.entity.ShopChatConversation; import com.gxwebsoft.shop.param.ShopChatConversationParam; import com.gxwebsoft.common.core.web.ApiResult; import com.gxwebsoft.common.core.web.PageResult; -import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.BatchParam; -import com.gxwebsoft.common.core.annotation.OperationLog; import com.gxwebsoft.common.system.entity.User; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; @@ -19,26 +17,26 @@ import javax.annotation.Resource; import java.util.List; /** - * 聊天消息表控制器 + * 聊天会话表控制器 * * @author 科技小王子 * @since 2025-01-11 10:45:12 */ -@Tag(name = "聊天消息表管理") +@Tag(name = "聊天会话表管理") @RestController @RequestMapping("/api/shop/shop-chat-conversation") public class ShopChatConversationController extends BaseController { @Resource private ShopChatConversationService shopChatConversationService; - @Operation(summary = "分页查询聊天消息表") + @Operation(summary = "分页查询聊天会话表") @GetMapping("/page") public ApiResult> page(ShopChatConversationParam param) { // 使用关联查询 return success(shopChatConversationService.pageRel(param)); } - @Operation(summary = "查询全部聊天消息表") + @Operation(summary = "查询全部聊天会话表") @GetMapping() public ApiResult> list(ShopChatConversationParam param) { // 使用关联查询 @@ -46,14 +44,14 @@ public class ShopChatConversationController extends BaseController { } @PreAuthorize("hasAuthority('shop:shopChatConversation:list')") - @Operation(summary = "根据id查询聊天消息表") + @Operation(summary = "根据id查询聊天会话表") @GetMapping("/{id}") public ApiResult get(@PathVariable("id") Integer id) { // 使用关联查询 return success(shopChatConversationService.getByIdRel(id)); } - @Operation(summary = "添加聊天消息表") + @Operation(summary = "添加聊天会话表") @PostMapping() public ApiResult save(@RequestBody ShopChatConversation shopChatConversation) { // 记录当前登录用户id @@ -67,7 +65,7 @@ public class ShopChatConversationController extends BaseController { return fail("添加失败"); } - @Operation(summary = "修改聊天消息表") + @Operation(summary = "修改聊天会话表") @PutMapping() public ApiResult update(@RequestBody ShopChatConversation shopChatConversation) { if (shopChatConversationService.updateById(shopChatConversation)) { @@ -76,7 +74,7 @@ public class ShopChatConversationController extends BaseController { return fail("修改失败"); } - @Operation(summary = "删除聊天消息表") + @Operation(summary = "删除聊天会话表") @DeleteMapping("/{id}") public ApiResult remove(@PathVariable("id") Integer id) { if (shopChatConversationService.removeById(id)) { @@ -85,7 +83,7 @@ public class ShopChatConversationController extends BaseController { return fail("删除失败"); } - @Operation(summary = "批量添加聊天消息表") + @Operation(summary = "批量添加聊天会话表") @PostMapping("/batch") public ApiResult saveBatch(@RequestBody List list) { if (shopChatConversationService.saveBatch(list)) { @@ -94,7 +92,7 @@ public class ShopChatConversationController extends BaseController { return fail("添加失败"); } - @Operation(summary = "批量修改聊天消息表") + @Operation(summary = "批量修改聊天会话表") @PutMapping("/batch") public ApiResult removeBatch(@RequestBody BatchParam batchParam) { if (batchParam.update(shopChatConversationService, "id")) { @@ -103,7 +101,7 @@ public class ShopChatConversationController extends BaseController { return fail("修改失败"); } - @Operation(summary = "批量删除聊天消息表") + @Operation(summary = "批量删除聊天会话表") @DeleteMapping("/batch") public ApiResult removeBatch(@RequestBody List ids) { if (shopChatConversationService.removeByIds(ids)) { diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopChatMessageController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopChatMessageController.java index f68bae2..5e7109f 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/ShopChatMessageController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopChatMessageController.java @@ -31,6 +31,7 @@ public class ShopChatMessageController extends BaseController { @Resource private ShopChatMessageService shopChatMessageService; + @PreAuthorize("hasAuthority('shop:shopChatMessage:list')") @Operation(summary = "分页查询聊天消息表") @GetMapping("/page") public ApiResult> page(ShopChatMessageParam param) { @@ -38,6 +39,7 @@ public class ShopChatMessageController extends BaseController { return success(shopChatMessageService.pageRel(param)); } + @PreAuthorize("hasAuthority('shop:shopChatMessage:list')") @Operation(summary = "查询全部聊天消息表") @GetMapping() public ApiResult> list(ShopChatMessageParam param) { @@ -53,20 +55,22 @@ public class ShopChatMessageController extends BaseController { return success(shopChatMessageService.getByIdRel(id)); } + @PreAuthorize("hasAuthority('shop:shopChatMessage:save')") @Operation(summary = "添加聊天消息表") @PostMapping() public ApiResult save(@RequestBody ShopChatMessage shopChatMessage) { - // 记录当前登录用户id -// User loginUser = getLoginUser(); -// if (loginUser != null) { -// shopChatMessage.setUserId(loginUser.getUserId()); -// } + // 获取当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + shopChatMessage.setFormUserId(loginUser.getUserId()); + } if (shopChatMessageService.save(shopChatMessage)) { return success("添加成功"); } return fail("添加失败"); } + @PreAuthorize("hasAuthority('shop:shopChatMessage:update')") @Operation(summary = "修改聊天消息表") @PutMapping() public ApiResult update(@RequestBody ShopChatMessage shopChatMessage) { @@ -76,6 +80,7 @@ public class ShopChatMessageController extends BaseController { return fail("修改失败"); } + @PreAuthorize("hasAuthority('shop:shopChatMessage:remove')") @Operation(summary = "删除聊天消息表") @DeleteMapping("/{id}") public ApiResult remove(@PathVariable("id") Integer id) { @@ -85,6 +90,7 @@ public class ShopChatMessageController extends BaseController { return fail("删除失败"); } + @PreAuthorize("hasAuthority('shop:shopChatMessage:save')") @Operation(summary = "批量添加聊天消息表") @PostMapping("/batch") public ApiResult saveBatch(@RequestBody List list) { @@ -94,6 +100,7 @@ public class ShopChatMessageController extends BaseController { return fail("添加失败"); } + @PreAuthorize("hasAuthority('shop:shopChatMessage:update')") @Operation(summary = "批量修改聊天消息表") @PutMapping("/batch") public ApiResult removeBatch(@RequestBody BatchParam batchParam) { @@ -103,6 +110,7 @@ public class ShopChatMessageController extends BaseController { return fail("修改失败"); } + @PreAuthorize("hasAuthority('shop:shopChatMessage:remove')") @Operation(summary = "批量删除聊天消息表") @DeleteMapping("/batch") public ApiResult removeBatch(@RequestBody List ids) { diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopChatMessage.java b/src/main/java/com/gxwebsoft/shop/entity/ShopChatMessage.java index 1a8b939..7808cd9 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/ShopChatMessage.java +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopChatMessage.java @@ -1,6 +1,7 @@ package com.gxwebsoft.shop.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import java.time.LocalDateTime; import com.fasterxml.jackson.annotation.JsonFormat; @@ -30,9 +31,41 @@ public class ShopChatMessage implements Serializable { @Schema(description = "发送人ID") private Integer formUserId; + @Schema(description = "发送人名称") + @TableField(exist = false) + private String formUserName; + + @Schema(description = "发送人头像") + @TableField(exist = false) + private String formUserAvatar; + + @Schema(description = "发送人手机号码") + @TableField(exist = false) + private String formUserPhone; + + @Schema(description = "发送人别名") + @TableField(exist = false) + private String formUserAlias; + @Schema(description = "接收人ID") private Integer toUserId; + @Schema(description = "接收人名称") + @TableField(exist = false) + private String toUserName; + + @Schema(description = "接收人头像") + @TableField(exist = false) + private String toUserAvatar; + + @Schema(description = "接收人手机号码") + @TableField(exist = false) + private String toUserPhone; + + @Schema(description = "接收人别名") + @TableField(exist = false) + private String toUserAlias; + @Schema(description = "消息类型") private String type; diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopDealerApply.java b/src/main/java/com/gxwebsoft/shop/entity/ShopDealerApply.java index fb622cd..8a1401b 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/ShopDealerApply.java +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopDealerApply.java @@ -1,6 +1,7 @@ package com.gxwebsoft.shop.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import java.math.BigDecimal; @@ -33,6 +34,10 @@ public class ShopDealerApply implements Serializable { @Schema(description = "用户ID") private Integer userId; + @Schema(description = "昵称") + @TableField(exist = false) + private String nickName; + @Schema(description = "姓名") private String realName; @@ -79,6 +84,9 @@ public class ShopDealerApply implements Serializable { @Schema(description = "驳回原因") private String rejectReason; + @Schema(description = "备注") + private String comments; + @Schema(description = "商城ID") private Integer tenantId; @@ -90,4 +98,8 @@ public class ShopDealerApply implements Serializable { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; + @Schema(description = "推荐人名称") + @TableField(exist = false) + private String refereeName; + } diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopDealerReferee.java b/src/main/java/com/gxwebsoft/shop/entity/ShopDealerReferee.java index 4771fdf..7ad8e63 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/ShopDealerReferee.java +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopDealerReferee.java @@ -52,6 +52,10 @@ public class ShopDealerReferee implements Serializable { @TableField(exist = false) private String avatar; + @Schema(description = "别名") + @TableField(exist = false) + private String alias; + @Schema(description = "手机号") @TableField(exist = false) private String phone; diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopChatMessageMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopChatMessageMapper.xml index 8210d37..b3c356f 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopChatMessageMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopChatMessageMapper.xml @@ -4,8 +4,11 @@ - SELECT a.* + SELECT a.*, b.nickname as formUserName, b.avatar as formUserAvatar, b.phone as formUserPhone, b.alias as formUserAlias, + c.nickname as toUserName, c.avatar as toUserAvatar, c.phone as toUserPhone, c.alias as toUserAlias FROM shop_chat_message a + LEFT JOIN gxwebsoft_core.sys_user b ON a.form_user_id = b.user_id + LEFT JOIN gxwebsoft_core.sys_user c ON a.to_user_id = c.user_id AND a.id = #{param.id} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerApplyMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerApplyMapper.xml index eb5bb84..c687187 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerApplyMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerApplyMapper.xml @@ -4,8 +4,10 @@ - SELECT a.* + SELECT a.*, b.nickname as nickName, c.nickname as refereeName FROM shop_dealer_apply a + LEFT JOIN gxwebsoft_core.sys_user b ON a.user_id = b.user_id + LEFT JOIN gxwebsoft_core.sys_user c ON a.referee_id = c.user_id AND a.apply_id = #{param.applyId} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerRefereeMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerRefereeMapper.xml index 33d17fb..881e662 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerRefereeMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerRefereeMapper.xml @@ -10,6 +10,7 @@ d.phone AS dealerPhone, u.nickname, u.avatar, + u.alias, u.phone FROM shop_dealer_referee a INNER JOIN gxwebsoft_core.sys_user d ON a.dealer_id = d.user_id AND d.deleted = 0 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 411b110..ebd0412 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -7,12 +7,9 @@ server: # 数据源配置 spring: datasource: -# url: jdbc:mysql://8.134.169.209:13306/cms_demo?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai -# username: cms_demo -# password: EtzJFr4A3c4THZjY - url: jdbc:mysql://8.134.169.209:13306/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai - username: modules - password: 8YdLnk7KsPAyDXGA + url: jdbc:mysql://8.134.169.209:13306/cms_demo?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai + username: cms_demo + password: EtzJFr4A3c4THZjY driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 4ad0fb1..51d1877 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -5,7 +5,7 @@ spring: datasource: url: jdbc:mysql://1Panel-mysql-Bqdt:3306/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai username: modules - password: 8YdLnk7KsPAyDXGA + password: P7KsAyDXG8YdLnkA driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource druid: diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 0000000..b2b6a2e --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,65 @@ +# 开发环境配置 + +# 服务器配置 +server: + port: 9200 + +# 数据源配置 +spring: + datasource: + url: jdbc:mysql://8.134.169.209:13306/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai + username: modules + password: P7KsAyDXG8YdLnkA + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + + # redis + redis: + database: 0 + host: 8.134.169.209 + port: 16379 + password: redis_WSDb88 + +# 日志配置 +logging: + level: + com.gxwebsoft: DEBUG + com.baomidou.mybatisplus: DEBUG + com.gxwebsoft.shop.mapper: DEBUG + org.apache.ibatis: DEBUG + +socketio: + host: localhost #IP地址 + +# MQTT配置 +mqtt: + enabled: false # 添加开关来禁用MQTT服务 + host: tcp://1.14.159.185:1883 + username: swdev + password: Sw20250523 + client-id-prefix: hjm_car_ + topic: /SW_GPS/# + qos: 2 + connection-timeout: 10 + keep-alive-interval: 20 + auto-reconnect: true + +# 框架配置 +config: + # 开发环境接口 + server-url: https://server.websoft.top/api + upload-path: /Users/gxwebsoft/JAVA/mp-java/src/main/resources # window(D:\Temp) + + # JWT配置 + jwt: + secret: websoft-jwt-secret-key-2025-dev-environment + expire: 86400 # token过期时间(秒) 24小时 + +# 开发环境证书配置 +certificate: + load-mode: CLASSPATH # 开发环境从classpath加载 + wechat-pay: + dev: + private-key-file: "apiclient_key.pem" + apiclient-cert-file: "apiclient_cert.pem" + wechatpay-cert-file: "wechatpay_cert.pem" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 29a58d2..cd5962a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -4,7 +4,7 @@ server: # 多环境配置 spring: profiles: - active: dev + active: test application: name: server