zwhui 1 vuosi sitten
vanhempi
sitoutus
419bdcfcf8
18 muutettua tiedostoa jossa 823 lisäystä ja 74 poistoa
  1. 11 0
      wholesale/src/main/java/com/yhlxj/dao/mapper/WholesaleNoticeMapper.java
  2. 11 0
      wholesale/src/main/java/com/yhlxj/dao/mapper/WholesaleUserMapper.java
  3. 6 0
      wholesale/src/main/java/com/yhlxj/dao/model/entity/WebInfo.java
  4. 32 0
      wholesale/src/main/java/com/yhlxj/dao/model/entity/WholesaleNotice.java
  5. 14 0
      wholesale/src/main/java/com/yhlxj/dao/model/entity/WholesaleUser.java
  6. 3 0
      wholesale/src/main/java/com/yhlxj/dao/model/view/WebWholesaleOrderView.java
  7. 6 3
      wholesale/src/main/java/com/yhlxj/service/wholesale/WebInfoService.java
  8. 11 0
      wholesale/src/main/java/com/yhlxj/service/wholesale/WholesaleNoticeService.java
  9. 14 0
      wholesale/src/main/java/com/yhlxj/service/wholesale/WholesaleUserService.java
  10. 29 4
      wholesale/src/main/java/com/yhlxj/service/wholesale/impl/WebInfoServiceImpl.java
  11. 15 0
      wholesale/src/main/java/com/yhlxj/service/wholesale/impl/WholesaleNoticeServiceImpl.java
  12. 50 0
      wholesale/src/main/java/com/yhlxj/service/wholesale/impl/WholesaleUserServiceImpl.java
  13. 0 67
      wholesale/src/main/java/com/yhlxj/web/WholesaleController.java
  14. 80 0
      wholesale/src/main/java/com/yhlxj/web/controller/login/WholesaleUserController.java
  15. 3 0
      wholesale/src/main/java/com/yhlxj/web/controller/manage/WholesaleCodeController.java
  16. 119 0
      wholesale/src/main/java/com/yhlxj/web/controller/manage/WholesaleController.java
  17. 85 0
      wholesale/src/main/java/com/yhlxj/web/controller/manage/WholesaleNoticeController.java
  18. 334 0
      wholesale/src/main/java/com/yhlxj/web/util/StpWholesaleUtil.java

+ 11 - 0
wholesale/src/main/java/com/yhlxj/dao/mapper/WholesaleNoticeMapper.java

@@ -0,0 +1,11 @@
+package com.yhlxj.dao.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yhlxj.dao.model.entity.WholesaleNotice;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 14:25
+ */
+public interface WholesaleNoticeMapper extends BaseMapper<WholesaleNotice> {
+}

+ 11 - 0
wholesale/src/main/java/com/yhlxj/dao/mapper/WholesaleUserMapper.java

@@ -0,0 +1,11 @@
+package com.yhlxj.dao.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yhlxj.dao.model.entity.WholesaleUser;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 15:44
+ */
+public interface WholesaleUserMapper extends BaseMapper<WholesaleUser> {
+}

+ 6 - 0
wholesale/src/main/java/com/yhlxj/dao/model/entity/WebInfo.java

@@ -10,6 +10,7 @@ import lombok.Data;
  */
 @Data
 public class WebInfo extends BaseEntity {
+    private Long userId;
     /**
      * 网站前缀
      */
@@ -40,4 +41,9 @@ public class WebInfo extends BaseEntity {
      */
     private String contactMe;
 
+    /**
+     * true运营中||false停止运营
+     */
+    private Boolean status;
+
 }

+ 32 - 0
wholesale/src/main/java/com/yhlxj/dao/model/entity/WholesaleNotice.java

@@ -0,0 +1,32 @@
+package com.yhlxj.dao.model.entity;
+
+import com.yhlxj.dao.model.BaseEntity;
+import lombok.Data;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 14:24
+ */
+@Data
+public class WholesaleNotice extends BaseEntity {
+    private Long wholesaleId;
+    /**
+     * 展示平台
+     */
+    private String platform;
+
+    /**
+     * 公告简介
+     */
+    private String description;
+
+    /**
+     * 公告详情
+     */
+    private String detail;
+
+    /**
+     * 上架状态
+     */
+    private Boolean status;
+}

+ 14 - 0
wholesale/src/main/java/com/yhlxj/dao/model/entity/WholesaleUser.java

@@ -0,0 +1,14 @@
+package com.yhlxj.dao.model.entity;
+
+import com.yhlxj.dao.model.BaseEntity;
+import lombok.Data;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 15:43
+ */
+@Data
+public class WholesaleUser extends BaseEntity {
+    private String username;
+    private String password;
+}

+ 3 - 0
wholesale/src/main/java/com/yhlxj/dao/model/view/WebWholesaleOrderView.java

@@ -19,6 +19,9 @@ import java.util.Date;
 @Setter
 @SearchBean(tables = "web_whole_sale_order_don wod")
 public class WebWholesaleOrderView {
+	@DbField("wod.wholesale_id")
+	private Long wholesaleId;
+
 	@DbField("wod.user_id")
 	private Long userId;
 

+ 6 - 3
wholesale/src/main/java/com/yhlxj/service/WebInfoService.java → wholesale/src/main/java/com/yhlxj/service/wholesale/WebInfoService.java

@@ -1,8 +1,9 @@
-package com.yhlxj.service;
+package com.yhlxj.service.wholesale;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.yhlxj.dao.model.entity.WebInfo;
 
-public interface WebInfoService {
+public interface WebInfoService extends IService<WebInfo> {
 
     /**
      * 检查前缀是否存在
@@ -23,7 +24,7 @@ public interface WebInfoService {
      * @param webInfo WebInfo对象
      * @return 保存后的WebInfo对象
      */
-    WebInfo saveWebInfo(WebInfo webInfo);
+    WebInfo saveWebInfo(WebInfo webInfo) throws Exception;
 
     /**
      * 更新WebInfo
@@ -38,4 +39,6 @@ public interface WebInfoService {
      * @return WebInfo对象
      */
     WebInfo getWebInfoById(Long id);
+
+    WebInfo login(String userName,String passWord) throws Exception;
 }

+ 11 - 0
wholesale/src/main/java/com/yhlxj/service/wholesale/WholesaleNoticeService.java

@@ -0,0 +1,11 @@
+package com.yhlxj.service.wholesale;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yhlxj.dao.model.entity.WholesaleNotice;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 14:33
+ */
+public interface WholesaleNoticeService extends IService<WholesaleNotice> {
+}

+ 14 - 0
wholesale/src/main/java/com/yhlxj/service/wholesale/WholesaleUserService.java

@@ -0,0 +1,14 @@
+package com.yhlxj.service.wholesale;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yhlxj.dao.model.entity.WholesaleUser;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 15:44
+ */
+public interface WholesaleUserService extends IService<WholesaleUser> {
+    WholesaleUser login(String username, String password) throws Exception;
+
+    WholesaleUser register(String username, String password) throws Exception;
+}

+ 29 - 4
wholesale/src/main/java/com/yhlxj/service/impl/WebInfoServiceImpl.java → wholesale/src/main/java/com/yhlxj/service/wholesale/impl/WebInfoServiceImpl.java

@@ -1,7 +1,10 @@
-package com.yhlxj.service.impl;
+package com.yhlxj.service.wholesale.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.common.util.Codec;
 import com.tencentcloudapi.common.AbstractModel;
 import com.tencentcloudapi.common.Credential;
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
@@ -12,9 +15,10 @@ import com.tencentcloudapi.dnspod.v20210323.models.CreateRecordRequest;
 import com.tencentcloudapi.dnspod.v20210323.models.CreateRecordResponse;
 import com.yhlxj.dao.mapper.WebInfoMapper;
 import com.yhlxj.dao.model.entity.WebInfo;
-import com.yhlxj.service.WebInfoService;
+import com.yhlxj.service.wholesale.WebInfoService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -23,7 +27,7 @@ import java.util.regex.Pattern;
 @Service
 @Slf4j
 @RequiredArgsConstructor
-public class WebInfoServiceImpl implements WebInfoService {
+public class WebInfoServiceImpl extends ServiceImpl<WebInfoMapper, WebInfo> implements WebInfoService {
     
     private final WebInfoMapper webInfoMapper;
     
@@ -88,7 +92,7 @@ public class WebInfoServiceImpl implements WebInfoService {
     
     @Override
     @Transactional
-    public WebInfo saveWebInfo(WebInfo webInfo) {
+    public WebInfo saveWebInfo(WebInfo webInfo) throws Exception {
         validateWebInfo(webInfo);
         
         // 检查前缀唯一性
@@ -101,6 +105,8 @@ public class WebInfoServiceImpl implements WebInfoService {
             throw new IllegalArgumentException("账号已存在");
         }
         createRecord(webInfo.getPrefix());
+        String encodePasscode = Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.SHA256).setStringData(webInfo.getPassword()).toBase64String();
+        webInfo.setPassword(encodePasscode);
         webInfoMapper.insert(webInfo);
         return webInfo;
     }
@@ -150,4 +156,23 @@ public class WebInfoServiceImpl implements WebInfoService {
             throw BusinessRuntimeException.getInstance(e.getMessage());
         }
     }
+
+    @Override
+    public WebInfo login(String userName,String passWord) throws Exception{
+        WebInfo webInfo = webInfoMapper.selectOne(Wrappers.lambdaQuery(WebInfo.class).eq(WebInfo::getAccount, userName));
+        if (null == webInfo) {
+            throw new BusinessRuntimeException("该店铺不存在.");
+        }
+        if (!webInfo.getStatus()) {
+            throw new BusinessRuntimeException("店铺已停止运营.");
+        }
+
+        String encodePasscode = Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.SHA256).setStringData(passWord).toBase64String();
+
+        if (!StringUtils.equals(webInfo.getPassword(), encodePasscode)) {
+            throw new BusinessRuntimeException("密码有误.");
+        }
+        webInfo.setPassword(null);
+        return webInfo;
+    }
 }

+ 15 - 0
wholesale/src/main/java/com/yhlxj/service/wholesale/impl/WholesaleNoticeServiceImpl.java

@@ -0,0 +1,15 @@
+package com.yhlxj.service.wholesale.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yhlxj.dao.mapper.WholesaleNoticeMapper;
+import com.yhlxj.dao.model.entity.WholesaleNotice;
+import com.yhlxj.service.wholesale.WholesaleNoticeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 14:34
+ */
+@Service
+public class WholesaleNoticeServiceImpl extends ServiceImpl<WholesaleNoticeMapper, WholesaleNotice> implements WholesaleNoticeService {
+}

+ 50 - 0
wholesale/src/main/java/com/yhlxj/service/wholesale/impl/WholesaleUserServiceImpl.java

@@ -0,0 +1,50 @@
+package com.yhlxj.service.wholesale.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.common.util.Codec;
+import com.yhlxj.dao.mapper.WholesaleUserMapper;
+import com.yhlxj.dao.model.entity.WebInfo;
+import com.yhlxj.dao.model.entity.WholesaleUser;
+import com.yhlxj.service.wholesale.WholesaleUserService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 15:45
+ */
+@Service
+public class WholesaleUserServiceImpl extends ServiceImpl<WholesaleUserMapper, WholesaleUser> implements WholesaleUserService {
+    @Override
+    public WholesaleUser login(String username, String password) throws Exception {
+        WholesaleUser wholesaleUser = baseMapper.selectOne(Wrappers.lambdaQuery(WholesaleUser.class).eq(WholesaleUser::getUsername, username));
+        if (null == wholesaleUser) {
+            throw new BusinessRuntimeException("用户不存在.");
+        }
+
+        String encodePasscode = Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.SHA256).setStringData(password).toBase64String();
+
+        if (!StringUtils.equals(wholesaleUser.getPassword(), encodePasscode)) {
+            throw new BusinessRuntimeException("密码有误.");
+        }
+        wholesaleUser.setPassword(null);
+        return wholesaleUser;
+    }
+
+
+    @Override
+    public WholesaleUser register(String username, String password) throws Exception {
+        WholesaleUser wholesaleUser = baseMapper.selectOne(Wrappers.lambdaQuery(WholesaleUser.class).eq(WholesaleUser::getUsername, username));
+        if (null != wholesaleUser) {
+            throw new BusinessRuntimeException("用户已存在.");
+        }
+        wholesaleUser = new WholesaleUser();
+        wholesaleUser.setUsername(username);
+        String encodePasscode = Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.SHA256).setStringData(password).toBase64String();
+        wholesaleUser.setPassword(encodePasscode);
+        baseMapper.insert(wholesaleUser);
+        return wholesaleUser;
+    }
+}

+ 0 - 67
wholesale/src/main/java/com/yhlxj/web/WholesaleController.java

@@ -1,67 +0,0 @@
-package com.yhlxj.web;
-
-import com.yhlxj.dao.model.dto.Result;
-import com.yhlxj.dao.model.entity.WebInfo;
-import com.yhlxj.dao.model.enums.GatewayResponse;
-import com.yhlxj.service.WebInfoService;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * @author zwhui
- * @date 2025/6/3 17:12
- */
-@Slf4j
-@RequiredArgsConstructor
-@RestController
-@RequestMapping("/applets/wholesale")
-public class WholesaleController {
-    private final WebInfoService webInfoService;
-
-
-    /**
-     * 检查前缀是否存在
-     * @param prefix 网站前缀
-     * @return 结果
-     */
-    @GetMapping("/check-prefix")
-    public Result<Boolean> checkPrefixExists(@RequestParam String prefix) {
-        boolean exists = webInfoService.checkPrefixExists(prefix);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(exists);
-    }
-
-    /**
-     * 检查账号是否存在
-     * @param account 账号
-     * @return 结果
-     */
-    @GetMapping("/check-account")
-    public Result<Boolean> checkAccountExists(@RequestParam String account) {
-        boolean exists = webInfoService.checkAccountExists(account);
-        return GatewayResponse.SUCCESS.newBuilder().toResult(exists);
-    }
-
-    /**
-     * 保存WebInfo
-     * @param webInfo WebInfo对象
-     * @return 结果
-     */
-    @PostMapping
-    public Result<WebInfo> saveWebInfo(@RequestBody WebInfo webInfo) {
-        return GatewayResponse.SUCCESS.newBuilder().toResult(webInfoService.saveWebInfo(webInfo));
-    }
-
-
-    /**
-     * 根据ID获取WebInfo
-     * @param id ID
-     * @return 结果
-     */
-    @GetMapping("/{id}")
-    public Result<WebInfo> getWebInfoById(@PathVariable Long id) {
-            WebInfo webInfo = webInfoService.getWebInfoById(id);
-            return GatewayResponse.SUCCESS.newBuilder().toResult(webInfo);
-    }
-
-}

+ 80 - 0
wholesale/src/main/java/com/yhlxj/web/controller/login/WholesaleUserController.java

@@ -0,0 +1,80 @@
+package com.yhlxj.web.controller.login;
+
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.yhlxj.dao.model.entity.WholesaleUser;
+import com.yhlxj.service.wholesale.WholesaleUserService;
+import com.yhlxj.web.util.StpUserUtil;
+import com.yhlxj.web.util.StpWholesaleUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 15:42
+ */
+@Slf4j
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/applets/wholesale")
+public class WholesaleUserController {
+
+    private final WholesaleUserService wholesaleUserService;
+
+    private final HttpServletResponse response;
+
+    /**
+     * 批发网站登录
+     */
+    @PostMapping("/login")
+    public WholesaleUser login(@RequestBody @NotNull WholesaleUser wholesaleUser) throws Exception {
+        String username = wholesaleUser.getUsername();
+        if (StringUtils.isBlank(username)) {
+            throw new BusinessRuntimeException("请填写帐号.");
+        }
+
+        String password = wholesaleUser.getPassword();
+        if (StringUtils.isBlank(password)) {
+            throw new BusinessRuntimeException("请填写密码.");
+        }
+
+        WholesaleUser login = wholesaleUserService.login(username, password);
+
+        //写回登陆信息
+        StpUserUtil.login(login.getId());
+        response.addHeader("satoken-user", StpUserUtil.getTokenValue());
+
+        Cookie cookie = new Cookie("satoken-user", StpUserUtil.getTokenValue());
+        cookie.setMaxAge(31536000);
+        cookie.setPath("/");
+        response.addCookie(cookie);
+        return login;
+    }
+
+
+    /**
+     * 注册
+     */
+    @PostMapping("/register")
+    public WholesaleUser register(@RequestBody @NotNull WholesaleUser wholesaleUser) throws Exception {
+         WholesaleUser login = wholesaleUserService.register(wholesaleUser.getUsername(), wholesaleUser.getPassword());
+
+        //写回登陆信息
+        StpUserUtil.login(login.getId());
+        response.addHeader("satoken-user", StpUserUtil.getTokenValue());
+
+        Cookie cookie = new Cookie("satoken-user", StpUserUtil.getTokenValue());
+        cookie.setMaxAge(31536000);
+        cookie.setPath("/");
+        response.addCookie(cookie);
+        return login;
+    }
+}

+ 3 - 0
wholesale/src/main/java/com/yhlxj/web/controller/manage/WholesaleCodeController.java

@@ -14,6 +14,7 @@ import com.yhlxj.dao.model.view.WebWholesaleCodeDetailView;
 import com.yhlxj.dao.model.view.WebWholesaleOrderView;
 import com.yhlxj.service.order.WebWholesaleOrderDonService;
 import com.yhlxj.web.util.StpUserUtil;
+import com.yhlxj.web.util.StpWholesaleUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
@@ -58,7 +59,9 @@ public class WholesaleCodeController {
 	 */
 	@GetMapping("/get/order")
 	public Result<SearchResult<WebWholesaleOrderView>> getOrders() {
+		long wholesaleId = StpWholesaleUtil.getLoginIdAsLong();
 		SearchResult<WebWholesaleOrderView> search = beanSearcher.search(WebWholesaleOrderView.class, MapUtils.flatBuilder(request.getParameterMap())
+				.field(WebWholesaleOrderView::getWholesaleId, wholesaleId)
 				.field(WebWholesaleOrderView::getStatus, WebWholesaleOrderDon.Status.complete.name())
 				.build());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(search);

+ 119 - 0
wholesale/src/main/java/com/yhlxj/web/controller/manage/WholesaleController.java

@@ -0,0 +1,119 @@
+package com.yhlxj.web.controller.manage;
+
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.yhlxj.dao.model.dto.Result;
+import com.yhlxj.dao.model.entity.WebInfo;
+import com.yhlxj.dao.model.enums.GatewayResponse;
+import com.yhlxj.service.wholesale.WebInfoService;
+import com.yhlxj.web.util.StpUserUtil;
+import com.yhlxj.web.util.StpWholesaleUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author zwhui
+ * @date 2025/6/3 17:12
+ */
+@Slf4j
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/manage/wholesale")
+public class WholesaleController {
+    private final WebInfoService webInfoService;
+
+    private final HttpServletResponse response;
+
+
+    /**
+     * 检查前缀是否存在
+     * @param prefix 网站前缀
+     * @return 结果
+     */
+    @GetMapping("/check-prefix")
+    public Result<Boolean> checkPrefixExists(@RequestParam String prefix) {
+        boolean exists = webInfoService.checkPrefixExists(prefix);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(exists);
+    }
+
+    /**
+     * 检查账号是否存在
+     * @param account 账号
+     * @return 结果
+     */
+    @GetMapping("/check-account")
+    public Result<Boolean> checkAccountExists(@RequestParam String account) {
+        boolean exists = webInfoService.checkAccountExists(account);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(exists);
+    }
+
+    /**
+     * 保存WebInfo
+     * @param webInfo WebInfo对象
+     * @return 结果
+     */
+    @PostMapping
+    public Result<WebInfo> saveWebInfo(@RequestBody WebInfo webInfo) throws Exception {
+        log.info("保存WebInfo:{}", webInfo);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(webInfoService.saveWebInfo(webInfo));
+    }
+
+    /**
+     * 修改WebInfo
+     * @param webInfo WebInfo对象
+     * @return 结果
+     */
+    @PutMapping
+    public Result<WebInfo> updateWebInfo(@RequestBody WebInfo webInfo) {
+        log.info("修改WebInfo:{}", webInfo);
+        webInfoService.updateById(webInfo);
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
+
+
+    /**
+     * 根据ID获取WebInfo
+     * @param id ID
+     * @return 结果
+     */
+    @GetMapping("/{id}")
+    public Result<WebInfo> getWebInfoById(@PathVariable Long id) {
+            WebInfo webInfo = webInfoService.getWebInfoById(id);
+            return GatewayResponse.SUCCESS.newBuilder().toResult(webInfo);
+    }
+
+
+    /**
+     * 批发网站管理员登录
+     */
+    @PostMapping("/login")
+    public Result<WebInfo> login(@RequestBody @NotNull WebInfo webInfo) throws Exception {
+        String username = webInfo.getAccount();
+        if (StringUtils.isBlank(username)) {
+            throw new BusinessRuntimeException("请填写帐号.");
+        }
+
+        String password = webInfo.getPassword();
+        if (StringUtils.isBlank(password)) {
+            throw new BusinessRuntimeException("请填写密码.");
+        }
+        WebInfo login = webInfoService.login(webInfo.getAccount(), webInfo.getPassword());
+
+        //写回登陆信息
+        StpWholesaleUtil.login(login.getId());
+        response.addHeader("satoken-wholesale", StpUserUtil.getTokenValue());
+
+        Cookie cookie = new Cookie("satoken-wholesale", StpUserUtil.getTokenValue());
+        cookie.setMaxAge(31536000);
+        cookie.setPath("/");
+        response.addCookie(cookie);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(login);
+    }
+
+
+}

+ 85 - 0
wholesale/src/main/java/com/yhlxj/web/controller/manage/WholesaleNoticeController.java

@@ -0,0 +1,85 @@
+package com.yhlxj.web.controller.manage;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.cyksj.common.util.StringUtil;
+import com.yhlxj.dao.model.dto.Result;
+import com.yhlxj.dao.model.entity.WholesaleNotice;
+import com.yhlxj.dao.model.enums.GatewayResponse;
+import com.yhlxj.service.wholesale.WholesaleNoticeService;
+import com.yhlxj.web.util.StpWholesaleUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author zwhui
+ * @date 2025/6/9 14:30
+ */
+@Slf4j
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/manage/wholesale/notice")
+public class WholesaleNoticeController {
+
+    private final WholesaleNoticeService wholesaleNoticeService;
+
+
+    /**
+     * 保存/更新公告
+     */
+    @PostMapping("/save")
+    public Result<WholesaleNotice> save(@RequestBody WholesaleNotice wholesaleNotice) {
+        log.info("保存公告:{}", wholesaleNotice);
+        long wholesaleId = StpWholesaleUtil.getLoginIdAsLong();
+        wholesaleNotice.setWholesaleId(wholesaleId);
+        wholesaleNoticeService.saveOrUpdate(wholesaleNotice);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(wholesaleNotice);
+    }
+
+    /**
+     * 上下架公告
+     */
+    @PutMapping("/put/status/{id}")
+    public Result<String> putStatus(@PathVariable Long id) {
+        log.info("上下架公告:{}", id);
+        long wholesaleId = StpWholesaleUtil.getLoginIdAsLong();
+        WholesaleNotice wholesaleNotice = wholesaleNoticeService.getById(id);
+        if (wholesaleNotice == null || !wholesaleNotice.getWholesaleId().equals(wholesaleId)) {
+            throw new RuntimeException("公告不存在");
+        }
+        wholesaleNotice.setStatus(!wholesaleNotice.getStatus());
+        wholesaleNoticeService.updateById(wholesaleNotice);
+        return GatewayResponse.SUCCESS.newBuilder().toResult("操作成功");
+    }
+
+    /**
+     * 删除公告
+     */
+    @DeleteMapping("/del/{id}")
+    public Result<String> del(@PathVariable Long id) {
+        log.info("删除公告:{}", id);
+        long wholesaleId = StpWholesaleUtil.getLoginIdAsLong();
+        WholesaleNotice wholesaleNotice = wholesaleNoticeService.getById(id);
+        if (wholesaleNotice == null || !wholesaleNotice.getWholesaleId().equals(wholesaleId)) {
+            throw new RuntimeException("公告不存在");
+        }
+        wholesaleNoticeService.removeById(id);
+        return GatewayResponse.SUCCESS.newBuilder().toResult("删除成功");
+    }
+
+    /**
+     * 查询公告列表
+     */
+    @GetMapping("/list")
+    public Result<Page<WholesaleNotice>> list(String platform,String description,Boolean status, @RequestParam(defaultValue = "1") Integer start, @RequestParam(defaultValue = "10") Integer limit) {
+        log.info("查询公告列表平台:{},描述:{},状态:{}", platform,description,status);
+        long wholesaleId = StpWholesaleUtil.getLoginIdAsLong();
+        Page<WholesaleNotice> page = wholesaleNoticeService.page(new Page<>(start, limit), Wrappers.lambdaQuery(WholesaleNotice.class)
+                .eq(WholesaleNotice::getWholesaleId, wholesaleId)
+                .like(StringUtil.isNotBlank(platform),WholesaleNotice::getPlatform, platform)
+                .like(StringUtil.isNotBlank(description),WholesaleNotice::getDescription, description)
+                .eq(status != null,WholesaleNotice::getStatus, status));
+        return GatewayResponse.SUCCESS.newBuilder().toResult(page);
+    }
+}

+ 334 - 0
wholesale/src/main/java/com/yhlxj/web/util/StpWholesaleUtil.java

@@ -0,0 +1,334 @@
+package com.yhlxj.web.util;
+
+import cn.dev33.satoken.fun.SaFunction;
+import cn.dev33.satoken.session.SaSession;
+import cn.dev33.satoken.stp.SaLoginModel;
+import cn.dev33.satoken.stp.SaTokenInfo;
+import cn.dev33.satoken.stp.StpLogic;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author chan
+ * @date 2021/10/12 下午5:59
+ */
+@Component
+public class StpWholesaleUtil {
+    public static final String TYPE = "wholesale";
+
+    // 使用匿名子类 重写`stpLogic对象`的一些方法
+    public static StpLogic stpLogic = new StpLogic("wholesale") {
+        // 重写 StpLogic 类下的 `splicingKeyTokenName` 函数,返回一个与 `StpUtil` 不同的token名称, 防止冲突
+        @Override
+        public String splicingKeyTokenName() {
+            return super.splicingKeyTokenName() + "-wholesale";
+        }
+        // 同理你可以按需重写一些其它方法 ...
+    };
+
+    public StpWholesaleUtil() {
+    }
+
+    public static String getLoginType() {
+        return stpLogic.getLoginType();
+    }
+
+    public static String getTokenName() {
+        return stpLogic.getTokenName();
+    }
+
+    public static void setTokenValue(String tokenValue, int cookieTimeout) {
+        stpLogic.setTokenValue(tokenValue, cookieTimeout);
+    }
+
+    public static String getTokenValue() {
+        return stpLogic.getTokenValue();
+    }
+
+    public static SaTokenInfo getTokenInfo() {
+        return stpLogic.getTokenInfo();
+    }
+
+    public static void login(Object id) {
+        stpLogic.login(id);
+    }
+
+    public static void login(Object id, String device) {
+        stpLogic.login(id, device);
+    }
+
+    public static void login(Object id, boolean isLastingCookie) {
+        stpLogic.login(id, isLastingCookie);
+    }
+
+    public static void login(Object id, SaLoginModel loginModel) {
+        stpLogic.login(id, loginModel);
+    }
+
+    public static void logout() {
+        stpLogic.logout();
+    }
+
+    public static void logoutByTokenValue(String tokenValue) {
+        stpLogic.logoutByTokenValue(tokenValue);
+    }
+
+    public static void logoutByLoginId(Object loginId) {
+        stpLogic.logoutByLoginId(loginId);
+    }
+
+    public static void logoutByLoginId(Object loginId, String device) {
+        stpLogic.logoutByLoginId(loginId, device);
+    }
+
+    public static boolean isLogin() {
+        return stpLogic.isLogin();
+    }
+
+    public static Long getUserIdAfterLogin() {
+        if (isLogin()) {
+            return StpWholesaleUtil.getLoginIdAsLong();
+        }
+        return null;
+    }
+
+    public static void checkLogin() {
+        stpLogic.checkLogin();
+    }
+
+    public static Object getLoginId() {
+        return stpLogic.getLoginId();
+    }
+
+    public static <T> T getLoginId(T defaultValue) {
+        return stpLogic.getLoginId(defaultValue);
+    }
+
+    public static Object getLoginIdDefaultNull() {
+        return stpLogic.getLoginIdDefaultNull();
+    }
+
+    public static String getLoginIdAsString() {
+        return stpLogic.getLoginIdAsString();
+    }
+
+    public static int getLoginIdAsInt() {
+        return stpLogic.getLoginIdAsInt();
+    }
+
+    public static long getLoginIdAsLong() {
+        return stpLogic.getLoginIdAsLong();
+    }
+
+    public static Object getLoginIdByToken(String tokenValue) {
+        return stpLogic.getLoginIdByToken(tokenValue);
+    }
+
+    public static SaSession getSessionByLoginId(Object loginId, boolean isCreate) {
+        return stpLogic.getSessionByLoginId(loginId, isCreate);
+    }
+
+    public static SaSession getSessionBySessionId(String sessionId) {
+        return stpLogic.getSessionBySessionId(sessionId);
+    }
+
+    public static SaSession getSessionByLoginId(Object loginId) {
+        return stpLogic.getSessionByLoginId(loginId);
+    }
+
+    public static SaSession getSession(boolean isCreate) {
+        return stpLogic.getSession(isCreate);
+    }
+
+    public static SaSession getSession() {
+        return stpLogic.getSession();
+    }
+
+    public static SaSession getTokenSessionByToken(String tokenValue) {
+        return stpLogic.getTokenSessionByToken(tokenValue);
+    }
+
+    public static SaSession getTokenSession() {
+        return stpLogic.getTokenSession();
+    }
+
+    public static void checkActivityTimeout() {
+        stpLogic.checkActivityTimeout();
+    }
+
+    public static void updateLastActivityToNow() {
+        stpLogic.updateLastActivityToNow();
+    }
+
+    public static long getTokenTimeout() {
+        return stpLogic.getTokenTimeout();
+    }
+
+    public static long getSessionTimeout() {
+        return stpLogic.getSessionTimeout();
+    }
+
+    public static long getTokenSessionTimeout() {
+        return stpLogic.getTokenSessionTimeout();
+    }
+
+    public static long getTokenActivityTimeout() {
+        return stpLogic.getTokenActivityTimeout();
+    }
+
+    public static boolean hasRole(Object loginId, String role) {
+        return stpLogic.hasRole(loginId, role);
+    }
+
+    public static boolean hasRole(String role) {
+        return stpLogic.hasRole(role);
+    }
+
+    public static void checkRole(String role) {
+        stpLogic.checkRole(role);
+    }
+
+    public static void checkRoleAnd(String... roleArray) {
+        stpLogic.checkRoleAnd(roleArray);
+    }
+
+    public static void checkRoleOr(String... roleArray) {
+        stpLogic.checkRoleOr(roleArray);
+    }
+
+    public static boolean hasPermission(Object loginId, String permission) {
+        return stpLogic.hasPermission(loginId, permission);
+    }
+
+    public static boolean hasPermission(String permission) {
+        return stpLogic.hasPermission(permission);
+    }
+
+    public static void checkPermission(String permission) {
+        stpLogic.checkPermission(permission);
+    }
+
+    public static void checkPermissionAnd(String... permissionArray) {
+        stpLogic.checkPermissionAnd(permissionArray);
+    }
+
+    public static void checkPermissionOr(String... permissionArray) {
+        stpLogic.checkPermissionOr(permissionArray);
+    }
+
+    public static String getTokenValueByLoginId(Object loginId) {
+        return stpLogic.getTokenValueByLoginId(loginId);
+    }
+
+    public static String getTokenValueByLoginId(Object loginId, String device) {
+        return stpLogic.getTokenValueByLoginId(loginId, device);
+    }
+
+    public static List<String> getTokenValueListByLoginId(Object loginId) {
+        return stpLogic.getTokenValueListByLoginId(loginId);
+    }
+
+    public static List<String> getTokenValueListByLoginId(Object loginId, String device) {
+        return stpLogic.getTokenValueListByLoginId(loginId, device);
+    }
+
+    public static String getLoginDevice() {
+        return stpLogic.getLoginDevice();
+    }
+
+    public static List<String> searchTokenValue(String keyword, int start, int size) {
+        return stpLogic.searchTokenValue(keyword, start, size);
+    }
+
+    public static List<String> searchSessionId(String keyword, int start, int size) {
+        return stpLogic.searchSessionId(keyword, start, size);
+    }
+
+    public static List<String> searchTokenSessionId(String keyword, int start, int size) {
+        return stpLogic.searchTokenSessionId(keyword, start, size);
+    }
+
+    public static void disable(Object loginId, long disableTime) {
+        stpLogic.disable(loginId, disableTime);
+    }
+
+    public static boolean isDisable(Object loginId) {
+        return stpLogic.isDisable(loginId);
+    }
+
+    public static long getDisableTime(Object loginId) {
+        return stpLogic.getDisableTime(loginId);
+    }
+
+    public static void untieDisable(Object loginId) {
+        stpLogic.untieDisable(loginId);
+    }
+
+    public static void switchTo(Object loginId) {
+        stpLogic.switchTo(loginId);
+    }
+
+    public static void endSwitch() {
+        stpLogic.endSwitch();
+    }
+
+    public static boolean isSwitch() {
+        return stpLogic.isSwitch();
+    }
+
+    public static void switchTo(Object loginId, SaFunction function) {
+        stpLogic.switchTo(loginId, function);
+    }
+
+    public static void openSafe(long safeTime) {
+        stpLogic.openSafe(safeTime);
+    }
+
+    public static boolean isSafe() {
+        return stpLogic.isSafe();
+    }
+
+    public static void checkSafe() {
+        stpLogic.checkSafe();
+    }
+
+    public static long getSafeTime() {
+        return stpLogic.getSafeTime();
+    }
+
+    public static void closeSafe() {
+        stpLogic.closeSafe();
+    }
+
+    /** @deprecated */
+    @Deprecated
+    public static String getLoginKey() {
+        return stpLogic.getLoginType();
+    }
+
+    /** @deprecated */
+    @Deprecated
+    public static void setLoginId(Object loginId) {
+        stpLogic.login(loginId);
+    }
+
+    /** @deprecated */
+    @Deprecated
+    public static void setLoginId(Object loginId, String device) {
+        stpLogic.login(loginId, device);
+    }
+
+    /** @deprecated */
+    @Deprecated
+    public static void setLoginId(Object loginId, boolean isLastingCookie) {
+        stpLogic.login(loginId, isLastingCookie);
+    }
+
+    /** @deprecated */
+    @Deprecated
+    public static void setLoginId(Object loginId, SaLoginModel loginModel) {
+        stpLogic.login(loginId, loginModel);
+    }
+
+}