Sfoglia il codice sorgente

fix 查询店铺信息

zwhui 1 anno fa
parent
commit
9eeaf8da77

+ 30 - 0
wholesale/src/main/java/com/yhlxj/dao/model/view/WebInfoView.java

@@ -0,0 +1,30 @@
+package com.yhlxj.dao.model.view;
+
+import lombok.Data;
+
+/**
+ * @author zwhui
+ * @date 2025/6/10 16:46
+ */
+@Data
+public class WebInfoView {
+    /**
+     * logo
+     */
+    private String logo;
+
+    /**
+     * 店铺名称
+     */
+    private String shopName;
+
+    /**
+     * 联系我二维码
+     */
+    private String contactMe;
+
+    /**
+     * true运营中||false停止运营
+     */
+    private Boolean status;
+}

+ 26 - 1
wholesale/src/main/java/com/yhlxj/web/controller/login/WholesaleUserController.java

@@ -1,8 +1,14 @@
 package com.yhlxj.web.controller.login;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
+import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
+import com.yhlxj.dao.model.entity.WebInfo;
 import com.yhlxj.dao.model.entity.WholesaleUser;
+import com.yhlxj.dao.model.view.WebInfoView;
+import com.yhlxj.service.wholesale.WebInfoService;
 import com.yhlxj.service.wholesale.WholesaleUserService;
 import com.yhlxj.web.util.StpUserUtil;
 import com.yhlxj.web.util.StpWholesaleUtil;
@@ -16,9 +22,9 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.NotNull;
 
 /**
+ * 用户登录
  * @author zwhui
  * @date 2025/6/9 15:42
- * 用户登录
  */
 @Slf4j
 @RequiredArgsConstructor
@@ -28,6 +34,8 @@ public class WholesaleUserController {
 
     private final WholesaleUserService wholesaleUserService;
 
+    private final WebInfoService webInfoService;
+
     private final HttpServletResponse response;
 
     /**
@@ -79,4 +87,21 @@ public class WholesaleUserController {
         response.addCookie(cookie);
         return login;
     }
+
+    /**
+     * 通过前缀查询店铺信息
+     */
+    @GetMapping("/getWebInfoByPrefix")
+    public WebInfoView getWebInfoByPrefix(@RequestParam String prefix) {
+        WebInfo webInfo = webInfoService.getOne(Wrappers.lambdaQuery(WebInfo.class).eq(WebInfo::getPrefix, prefix).last(" limit 1"));
+        if (webInfo == null) {
+            throw new BusinessRuntimeException("店铺不存在.");
+        }
+        if (!webInfo.getStatus()){
+            throw new BusinessRuntimeException("店铺已关闭.");
+        }
+        WebInfoView view = new WebInfoView();
+        BeanUtil.copyProperties(webInfo, view);
+        return view;
+    }
 }