Aslee 4 лет назад
Родитель
Сommit
ffbdf1aa65

+ 6 - 1
pom.xml

@@ -101,7 +101,12 @@
             <artifactId>fastjson</artifactId>
             <version>1.2.75</version>
         </dependency>
-
+        <!-- swagger -->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
+        </dependency>
 
 
 		<dependency>

+ 1 - 1
src/main/java/com/caimei365/user/components/WeChatService.java

@@ -39,7 +39,7 @@ public class WeChatService {
     private String crmAppId;
     private String crmAppSecret;
 
-    @Value("${wx.redirect_uri}")
+    @Value("${wx.redirect-uri}")
     public void setRedirectUri(String redirectUri) {
         redirectUri = redirectUri;
     }

+ 53 - 0
src/main/java/com/caimei365/user/configuration/SwaggerConfig.java

@@ -0,0 +1,53 @@
+package com.caimei365.user.configuration;
+
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.*;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+import static com.google.common.collect.Lists.newArrayList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Aslee
+ *
+ * @date 2021/3/10
+ */
+@Configuration
+public class SwaggerConfig {
+    @Value(value = "${swagger.enabled}")
+    Boolean swaggerEnabled;
+
+    @Bean
+    public Docket createRestApi(){
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .enable(swaggerEnabled)
+                .select()
+                // 扫描api
+                .apis(RequestHandlerSelectors.basePackage("com.caimei365.user.controller"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo(){
+        return new ApiInfoBuilder().
+                // 标题
+                title("caimei-cloud-user")
+                // 描述
+                .description("caimei-cloud-user")
+                // 服务地址
+                .termsOfServiceUrl("https://www.caimei365.com")
+                // 版本号
+                .version("1.0.0")
+                .build();
+    }
+}

+ 0 - 0
src/main/java/com/caimei365/user/controller/AllApi.java → src/main/java/com/caimei365/user/controller/AllApi.txt


+ 32 - 24
src/main/java/com/caimei365/user/controller/ShopApi.java

@@ -4,10 +4,10 @@ import com.caimei365.user.idempotent.Idempotent;
 import com.caimei365.user.model.BaseUser;
 import com.caimei365.user.model.JsonModel;
 import com.caimei365.user.service.ShopService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.server.ServerWebExchange;
 
 /**
@@ -76,29 +76,32 @@ public class ShopApi {
 
     /**
      * 小程序端分步供应商注册
-     *  @param source                注册来源: 0网站 1小程序
-     * @param name                  组织名称
-     * @param sName                 供应商公司简称(旧:sname)
-     * @param bindMobile            企业绑定手机号
-     * @param email                 邮箱
-     * @param smsCode               手机验证码(旧:mobileCode)
-     * @param password              密码
-     * @param passWordConfirm       用户确认密码
-     * @param linkMan               联系人
-     * @param provinceId            省(旧:provinceID)
-     * @param cityId                市(旧:cityID)
-     * @param townId                所在县区Id(旧:townID)
-     * @param address               地址
-     * @param socialCreditCode      统一社会信用代码
-     * @param businessLicenseImage  营业执照
-     * @param firstShopType         医疗=1和非医疗=2
-     * @param secondShopType        医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
-     * @param mainPro               主打项目(旧:mainpro)
-     * @param isAgreed              是否同意勾选同意协议,1是,其他否
-     * @param serverWebExchange     ServerWebExchange(新参数)
-     * @param whichStep             注册步数
+     *
+     * @param source               注册来源: 0网站 1小程序
+     * @param name                 组织名称
+     * @param sName                供应商公司简称(旧:sname)
+     * @param bindMobile           企业绑定手机号
+     * @param email                邮箱
+     * @param smsCode              手机验证码(旧:mobileCode)
+     * @param password             密码
+     * @param passWordConfirm      用户确认密码
+     * @param linkMan              联系人
+     * @param provinceId           省(旧:provinceID)
+     * @param cityId               市(旧:cityID)
+     * @param townId               所在县区Id(旧:townID)
+     * @param address              地址
+     * @param socialCreditCode     统一社会信用代码
+     * @param businessLicenseImage 营业执照
+     * @param firstShopType        医疗=1和非医疗=2
+     * @param secondShopType       医疗的二级分类 一类器械=1、二类器械 =2、三类器械=3、其他=4 /// 1和非医疗没有二级分类
+     * @param mainPro              主打项目(旧:mainpro)
+     * @param isAgreed             是否同意勾选同意协议,1是,其他否
+     * @param serverWebExchange    ServerWebExchange(新参数)
+     * @param whichStep            注册步数
      * @return
      */
+    @ApiOperation("小程序端分步供应商注册")
+    @ApiImplicitParam(name = "name", value = "供应商名称", required = true, dataType = "String")
     @PostMapping("/applets/register")
     public JsonModel appletsRegister(Integer source,
                                      String name,
@@ -124,4 +127,9 @@ public class ShopApi {
         return shopService.appletsRegister(source, name, sName, bindMobile, email, smsCode, password, passWordConfirm, linkMan, provinceId, cityId, townId, address, socialCreditCode, businessLicenseImage, firstShopType, secondShopType, mainPro, isAgreed, serverWebExchange, whichStep);
     }
 
+    @GetMapping("/hello")
+    @ResponseBody
+    public String hello(){
+        return "hello";
+    }
 }

+ 1 - 1
src/main/java/com/caimei365/user/idempotent/IdempotentAspect.java

@@ -44,7 +44,7 @@ public class IdempotentAspect {
     /**
      * 切入点,根据自定义Idempotent实际路径进行调整
      */
-    @Pointcut("@annotation(com.caimei.idempotent.Idempotent)")
+    @Pointcut("@annotation(com.caimei365.user.idempotent.Idempotent)")
     public void executeIdempotent() {
     }
 

+ 1 - 0
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -253,6 +253,7 @@ public class ShopServiceImpl implements ShopService {
                 return JsonModel.error("参数异常");
             }
             if (StringUtils.isNotBlank(email)) {
+                // 查找用户表是否存在相同邮箱
                 Integer dbUserId = baseUserDao.getUserIdByEmail(email);
                 if (dbUserId > 0) {
                     return JsonModel.error("该邮箱已被使用", null);

+ 5 - 0
src/main/resources/application.yml

@@ -56,3 +56,8 @@ wx:
   #crm公众号信息
   crm-app-id: wxea43a0f9ebce9e66
   crm-app-secret: 1c3cd60908e72dd280840bee9e15f7f6
+
+# swagger配置
+swagger:
+  # swagger开启状态,true开启,false关闭
+  enabled: true