plf il y a 4 ans
Parent
commit
477cb0bf95

+ 1 - 0
pom.xml

@@ -112,6 +112,7 @@
             <version>1.0</version>
         </dependency>
 
+        <!--knife4j接口文档-->
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
             <artifactId>knife4j-spring-boot-starter</artifactId>

+ 10 - 3
src/main/java/com/caimei/controller/LoginApi.java

@@ -1,5 +1,6 @@
 package com.caimei.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.BuyerUserDto;
 import com.caimei.model.vo.BuyerUserVo;
@@ -35,12 +36,14 @@ public class LoginApi {
     /**
      * 小程序授权登录
      *
-     * @param code 小程序登录唯一凭证
+     * @param params {"code":"" } code小程序登录唯一凭证
      */
     @ApiOperation("授权登录")
     @PostMapping("/authorization")
-    @ApiImplicitParam(name = "code", value = "登录凭证", required = true)
-    public ResponseJson<BuyerUserVo> authorizationLogin(@RequestBody String code) {
+   //@ApiImplicitParam(name = "params", value = "code登录凭证", required = true)
+    public ResponseJson<BuyerUserVo> authorizationLogin(@RequestBody String params) {
+        JSONObject parseObject = JSONObject.parseObject(params);
+        String code = parseObject.getString("code");
         if (StringUtils.isEmpty(code)) {
             return ResponseJson.error("参数异常", null);
         }
@@ -53,6 +56,10 @@ public class LoginApi {
     @ApiOperation("邀请码登录")
     @PostMapping("/invitation/code")
     public ResponseJson<BuyerUserVo> invitationCode(@RequestBody BuyerUserDto buyerUserDto) {
+        if (StringUtils.isEmpty(buyerUserDto.getInvitationCode()) || StringUtils.isEmpty(buyerUserDto.getOpenid())
+                || StringUtils.isEmpty(buyerUserDto.getNickName())) {
+            return ResponseJson.error("参数异常", null);
+        }
         return loginService.invitationCode(buyerUserDto);
     }
 }

+ 51 - 0
src/main/java/com/caimei/controller/ProductApi.java

@@ -0,0 +1,51 @@
+package com.caimei.controller;
+
+import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.ClubVo;
+import com.caimei.service.ProductService;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+@Api(tags = "商品")
+@RestController
+@RequestMapping("/product")
+public class ProductApi {
+
+    private ProductService productService;
+
+    @Autowired
+    public void setProductService(ProductService productService) {
+        this.productService = productService;
+    }
+
+    /**
+     * 组织机构列表
+     *
+     * @param name       机构名称/机构联系人
+     * @param organizeId 组织id
+     * @return
+     */
+    @ApiOperation("机构列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "organizeId", required = true, value = "组织id"),
+            @ApiImplicitParam(name = "name", required = false, value = "机构名称/机构联系人")
+    })
+    @GetMapping("/clubList")
+    public ResponseJson<PageInfo<ClubVo>> clubList(Integer organizeId, String name, Page<ClubVo> page) {
+        return null;
+    }
+}

+ 25 - 0
src/main/java/com/caimei/mapper/ProductMapper.java

@@ -0,0 +1,25 @@
+package com.caimei.mapper;
+
+import com.caimei.model.vo.ClubVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+@Mapper
+public interface ProductMapper {
+    /**
+     * 查询组织机构
+     *
+     * @param organizeId 组织id
+     * @param name
+     * @return
+     */
+    List<ClubVo> findClubList(@Param("organizeId") Integer organizeId,@Param("name") String name);
+}

+ 34 - 0
src/main/java/com/caimei/model/vo/ClubVo.java

@@ -0,0 +1,34 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+@Data
+public class ClubVo {
+
+    /**
+     * 用户id
+     */
+    private Integer userId;
+
+    /**
+     * 机构名称
+     */
+    private String clubName;
+
+    /**
+     * 机构联系人
+     */
+    private String userName;
+
+    /**
+     * 手机号
+     */
+    private String bindMobile;
+
+}

+ 23 - 0
src/main/java/com/caimei/service/ProductService.java

@@ -0,0 +1,23 @@
+package com.caimei.service;
+
+import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.ClubVo;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageInfo;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+public interface ProductService {
+    /**
+     * 机构列表
+     *
+     * @param name
+     * @param organizeId
+     * @return
+     */
+    ResponseJson<PageInfo<ClubVo>> clubList(Integer organizeId, String name, Page<ClubVo> page);
+}

+ 34 - 0
src/main/java/com/caimei/service/impl/ProductServiceImpl.java

@@ -0,0 +1,34 @@
+package com.caimei.service.impl;
+
+import com.caimei.mapper.ProductMapper;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.ClubVo;
+import com.caimei.service.ProductService;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+@Service
+public class ProductServiceImpl implements ProductService {
+    @Resource
+    private ProductMapper productMapper;
+
+    @Override
+    public ResponseJson<PageInfo<ClubVo>> clubList(Integer organizeId, String name, Page<ClubVo> page) {
+        PageHelper.startPage(page.getPageNum(),page.getPageSize());
+        List<ClubVo> clubList = productMapper.findClubList(organizeId, name);
+        PageInfo<ClubVo> pageInfo = new PageInfo<>(clubList);
+
+        return ResponseJson.success(pageInfo);
+    }
+}

+ 1 - 1
src/main/resources/config/dev/application-dev.yml

@@ -57,4 +57,4 @@ swagger:
 #自定义配置
 wx:
   AppId: wxca7172d7a20bdf7a
-  AppSecret: 7fa931d8eb126efc3aff935b879f595f
+  AppSecret: d7f853a64b73d01ef93f3829852a790e

+ 25 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei.mapper.ProductMapper">
+    <select id="findClubList" resultType="com.caimei.model.vo.ClubVo">
+        SELECT
+          u.userID AS userId,
+          u.name AS clubName,
+          u.userName,
+          u.bindMobile
+        FROM
+          USER u
+          LEFT JOIN club c ON u.userID = c.userID
+        WHERE
+          u.userOrganizeID = #{organizeId}
+          AND u.clubStatus = 90
+          AND u.validFlag = 1
+          AND (
+            u.name LIKE CONCAT("%",#{name}, "%")
+            OR u.userName LIKE CONCAT("%",#{name}, "%")
+          )
+    </select>
+
+</mapper>