Browse Source

接口api

liulingchao 4 years ago
parent
commit
2318bb2382
19 changed files with 439 additions and 6 deletions
  1. 5 0
      dgtly-api/pom.xml
  2. 98 0
      dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/DemandInfoController.java
  3. 84 0
      dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/MemberInfoController.java
  4. 80 0
      dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/SupplyInfoController.java
  5. 0 4
      dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/TestController.java
  6. 10 0
      dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/UserInfoController.java
  7. 28 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/member/mapper/MemberInfoMapper.java
  8. 27 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/member/service/IMemberInfoService.java
  9. 17 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/member/service/impl/MemberInfoServiceImpl.java
  10. 10 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/mapper/NoticeDemandMapper.java
  11. 9 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/mapper/NoticeSupplyMapper.java
  12. 10 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/INoticeDemandService.java
  13. 9 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/INoticeSupplyService.java
  14. 12 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/impl/NoticeDemandServiceImpl.java
  15. 5 0
      dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/impl/NoticeSupplyServiceImpl.java
  16. 16 1
      dgtly-member/dgtly-member-common/src/main/resources/mapper/member/MemberInfoMapper.xml
  17. 7 0
      dgtly-member/dgtly-member-common/src/main/resources/mapper/notice/NoticeDemandMapper.xml
  18. 11 0
      dgtly-member/dgtly-member-common/src/main/resources/mapper/notice/NoticeSupplyMapper.xml
  19. 1 1
      dgtly-system/src/main/resources/mapper/system/SysNoticeMapper.xml

+ 5 - 0
dgtly-api/pom.xml

@@ -32,6 +32,11 @@
             <artifactId>dgtly-goods-api</artifactId>
             <version>4.0.0</version>
         </dependency>
+        <dependency>
+            <groupId>com.dgtly</groupId>
+            <artifactId>dgtly-member-api</artifactId>
+            <version>4.0.0</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 98 - 0
dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/DemandInfoController.java

@@ -0,0 +1,98 @@
+package com.dgtly.member.controller;
+
+import com.dgtly.common.annotation.ApiNoCheckSign;
+import com.dgtly.common.annotation.ApiPassToken;
+import com.dgtly.common.core.controller.ApiBaseController;
+import com.dgtly.common.core.domain.AjaxResult;
+import com.dgtly.common.core.domain.ParameterObject;
+import com.dgtly.common.core.domain.ResultType;
+import com.dgtly.common.utils.DateUtils;
+import com.dgtly.notice.domain.NoticeDemand;
+import com.dgtly.notice.service.INoticeDemandService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+  * @descption: 需求、供应相关接口API
+  * @author LiuLingChao
+  * @version 1.0
+  * @company 神州数码通用软件(洛阳)有限公司
+  * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
+  * @date 2020-2-25 10:12
+  * @since JDK1.8
+  */
+
+@RestController
+@RequestMapping("/demand/info")
+@ApiPassToken/* 不用验证token  方法上可用*/
+@ApiNoCheckSign/* 不用验证 签名 方法上可用*/
+public class DemandInfoController extends ApiBaseController {
+
+     @Autowired
+     private INoticeDemandService noticeDemandService;
+
+
+     /**
+     * @descption: 首页获取需求列表前10条
+     * @param:
+     * @return: 最新的需求信息前10条
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 10:11
+     */
+    @PostMapping("/getDemandInfoTenList")
+    public Object getDemandInfoTenList(){
+        List<NoticeDemand> noticeDemandList = noticeDemandService.getDemandInfoTenList();
+        return AjaxResult.success().putKV("demandList",noticeDemandList);
+
+    }
+
+    /**
+     * @descption: 获取需求信息详情
+     * @param: 需求id
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 10:54
+     */
+    @PostMapping("/getDemandInfo")
+    public Object getDemandInfo(){
+        ParameterObject obj =  getParameterObject();
+        NoticeDemand noticeDemand = obj.parseBean(NoticeDemand.class);
+        NoticeDemand noticeDemand1 = noticeDemandService.selectNoticeDemandById(noticeDemand.getId());
+        return AjaxResult.success().putKV("demandInfo",noticeDemand1);
+    }
+
+    /**
+     * @descption: 获取全部需求信息分页列表
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 11:02
+     */
+    @PostMapping("/getDemandInfoAllList")
+    public Object getDemandInfoAllList(){
+        ParameterObject obj =  getParameterObject();
+        NoticeDemand noticeDemand = obj.parseBean(NoticeDemand.class);
+        startPage(obj);/*向分页传递 分页参数*/
+        List<NoticeDemand> noticeDemandList = noticeDemandService.selectNoticeDemandList(noticeDemand);
+        return AjaxResult.success(getDataTable(noticeDemandList));
+    }
+
+    @PostMapping("/insertDemandInfo")
+    public Object insertDemandInfo(){
+        ParameterObject obj =  getParameterObject();
+        NoticeDemand noticeDemand = obj.parseBean(NoticeDemand.class);
+        noticeDemand.setCreateTime(DateUtils.getNowDate());
+        noticeDemand.setReleaseTime(DateUtils.getNowDate());
+        int flag = noticeDemandService.insertNoticeDemand(noticeDemand);
+        return toAjax(flag);
+    }
+
+
+
+
+
+}

+ 84 - 0
dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/MemberInfoController.java

@@ -0,0 +1,84 @@
+package com.dgtly.member.controller;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.dgtly.common.core.controller.ApiBaseController;
+import com.dgtly.common.core.domain.AjaxResult;
+import com.dgtly.common.core.domain.ParameterObject;
+import com.dgtly.common.utils.DateUtils;
+import com.dgtly.member.domain.MemberInfo;
+import com.dgtly.member.service.IMemberInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import java.util.Date;
+
+/**
+ * @descption: 网站前端用户信息相关接口API
+ * @author LiuLingChao
+ * @version 1.0
+ * @company 神州数码通用软件(洛阳)有限公司
+ * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
+ * @date 2020-2-25 14:41
+ * @since JDK1.8
+ */
+public class MemberInfoController extends ApiBaseController {
+
+    @Autowired
+    private IMemberInfoService iMemberInfoService;
+
+    /**
+     * @descption: 网站用户注册
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 14:43
+     */
+    @PostMapping("/userRegister")
+    public Object userRegister(){
+        ParameterObject obj =  getParameterObject();
+        MemberInfo memberInfo = obj.parseBean(MemberInfo.class);
+        //校验用户名唯一性
+        MemberInfo memberInfo1 = iMemberInfoService.checkMemberUnique(memberInfo.getLoginAccount());
+        if(memberInfo1 != null){
+            return AjaxResult.error(301,"登录账号已存在");
+        }
+        //校验手机号码唯一性
+        MemberInfo memberInfo2 = iMemberInfoService.checkMemberPhoneUnique(memberInfo.getPhone());
+        if(memberInfo1 != null){
+            return AjaxResult.error(302,"手机号码已存在");
+        }
+
+        memberInfo.setCreateTime(DateUtils.getNowDate());
+        int flag = iMemberInfoService.insertMemberInfo(memberInfo);
+        return toAjax(flag);
+
+    }
+
+    /**
+     * @descption: 网站会员登录
+     * @param:登录账号/手机号、密码
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 15:35
+     */
+    @PostMapping("/memberLogin")
+    public Object memberLogin(){
+        ParameterObject obj =  getParameterObject();
+        MemberInfo memberInfo = obj.parseBean(MemberInfo.class);
+        MemberInfo memberInfo1 = iMemberInfoService.memberLogin(memberInfo);
+        if(memberInfo1 == null){
+            return AjaxResult.error(303,"登录账号或密码错误");
+        }
+        Date start = new Date();
+        long currentTime = System.currentTimeMillis() + 12*60* 60 * 1000;//12小时有效时间
+        Date end = new Date(currentTime);
+        String token = JWT.create().withAudience(memberInfo1.getId()+"")
+                .withIssuedAt(start)
+                .withExpiresAt(end)
+                .sign(Algorithm.HMAC256(memberInfo1.getLoginPassword()));
+
+        return AjaxResult.success("登录成功",token);
+
+    }
+}

+ 80 - 0
dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/SupplyInfoController.java

@@ -0,0 +1,80 @@
+package com.dgtly.member.controller;
+
+import com.dgtly.common.annotation.ApiNoCheckSign;
+import com.dgtly.common.annotation.ApiPassToken;
+import com.dgtly.common.core.controller.ApiBaseController;
+import com.dgtly.common.core.domain.AjaxResult;
+import com.dgtly.common.core.domain.ParameterObject;
+import com.dgtly.notice.domain.NoticeSupply;
+import com.dgtly.notice.service.INoticeSupplyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+ /**
+  * @descption: 供应管理相关API接口
+  * @author LiuLingChao
+  * @version 1.0
+  * @company 神州数码通用软件(洛阳)有限公司
+  * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
+  * @date 2020-2-25 11:08
+  * @since JDK1.8
+  */
+@RestController
+@RequestMapping("/supply/info")
+@ApiPassToken/* 不用验证token  方法上可用*/
+@ApiNoCheckSign/* 不用验证 签名 方法上可用*/
+public class SupplyInfoController extends ApiBaseController {
+
+    @Autowired
+    private INoticeSupplyService iNoticeSupplyService;
+
+    /**
+     * @descption: 获取全部供应信息分页列表
+     * @param:
+     * @return: List集合
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 11:09
+     */
+    @PostMapping("/getSupplyInfoAllList")
+    public Object getSupplyInfoAllList(){
+        ParameterObject obj =  getParameterObject();
+        NoticeSupply noticeSupply = obj.parseBean(NoticeSupply.class);
+        List<NoticeSupply> noticeSupplyList = iNoticeSupplyService.selectNoticeSupplyList(noticeSupply);
+        return AjaxResult.success(getDataTable(noticeSupplyList));
+    }
+
+    /**
+     * @descption: 根据供应id获取供应详细信息
+     * @param: 供应id
+     * @return: 供应信息实体
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 11:11
+     */
+    @PostMapping("/getSupplyInfo")
+    public Object getSupplyInfo(){
+        ParameterObject obj =  getParameterObject();
+        NoticeSupply noticeSupply = obj.parseBean(NoticeSupply.class);
+        NoticeSupply noticeSupply1 = iNoticeSupplyService.selectNoticeSupplyById(noticeSupply.getId());
+        return AjaxResult.success().putKV("noticeSupply",noticeSupply1);
+    }
+
+    /**
+     * @descption: 获取最新的供应信息前10条
+     * @param:
+     * @return: List集合
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 11:12
+     */
+    @PostMapping("/getSupplyInfoTenLsit")
+    public Object getSupplyInfoTenLsit(){
+
+        List<NoticeSupply> noticeSupplyList = iNoticeSupplyService.getSupplyInfoTenList();
+        return AjaxResult.success().putKV("supplyList",noticeSupplyList);
+    }
+}
+
+

+ 0 - 4
dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/TestController.java

@@ -1,4 +0,0 @@
-package com.dgtly.member.controller;
-
-public class TestController {
-}

+ 10 - 0
dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/UserInfoController.java

@@ -0,0 +1,10 @@
+package com.dgtly.member.controller;
+
+import com.dgtly.common.core.controller.ApiBaseController;
+
+
+public class UserInfoController extends ApiBaseController {
+
+
+
+}

+ 28 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/member/mapper/MemberInfoMapper.java

@@ -58,4 +58,32 @@ public interface MemberInfoMapper
      * @return 结果
      */
     public int deleteMemberInfoByIds(String[] ids);
+
+
+    /**
+     * @descption: 检测登录账号的唯一性
+     * @param: 登录账号
+     * @return: 会员实体
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 15:12
+     */
+    public MemberInfo checkMemberUnique(String loginAccount);
+    /**
+     * @descption: 检测手机号的唯一性
+     * @param: 手机号
+     * @return: 会员实体
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 15:12
+     */
+    public MemberInfo checkMemberPhoneUnique(String phone);
+
+
+    /**
+     * @descption: 用户登录
+     * @param: 登录账号/手机号、密码
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 15:39
+     */
+    public MemberInfo memberLogin(MemberInfo memberInfo);
 }

+ 27 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/member/service/IMemberInfoService.java

@@ -58,4 +58,31 @@ public interface IMemberInfoService
      * @return 结果
      */
     public int deleteMemberInfoById(Long id);
+
+    /**
+     * @descption: 检测登录账号的唯一性
+     * @param: 登录账号
+     * @return: 会员实体
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 15:12
+     */
+     public MemberInfo checkMemberUnique(String loginAccount );
+    /**
+     * @descption: 检测手机号唯一性
+     * @param: 手机号
+     * @return: 会员实体
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 15:12
+     */
+     public MemberInfo checkMemberPhoneUnique(String phone );
+
+
+     /**
+      * @descption: 用户登录
+      * @param: 登录账号/手机号、密码
+      * @return:
+      * @auther: LiuLingChao
+      * @date: 2020-2-25 15:39
+      */
+    public MemberInfo memberLogin(MemberInfo info);
 }

+ 17 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/member/service/impl/MemberInfoServiceImpl.java

@@ -95,4 +95,21 @@ public class MemberInfoServiceImpl implements IMemberInfoService
     {
         return memberInfoMapper.deleteMemberInfoById(id);
     }
+
+
+    @Override
+    public MemberInfo checkMemberUnique(String loginAccount) {
+        return memberInfoMapper.checkMemberUnique(loginAccount);
+    }
+
+    @Override
+    public MemberInfo checkMemberPhoneUnique(String phone) {
+        return memberInfoMapper.checkMemberPhoneUnique(phone);
+    }
+
+
+    @Override
+    public MemberInfo memberLogin(MemberInfo info) {
+        return memberInfoMapper.memberLogin(info);
+    }
 }

+ 10 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/mapper/NoticeDemandMapper.java

@@ -58,4 +58,14 @@ public interface NoticeDemandMapper
      * @return 结果
      */
     public int deleteNoticeDemandByIds(String[] ids);
+
+
+    /**
+     * @descption: 获取最新的需求信息前10条
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 10:27
+     */
+    public List<NoticeDemand> getDemandInfoTenList();
 }

+ 9 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/mapper/NoticeSupplyMapper.java

@@ -58,4 +58,13 @@ public interface NoticeSupplyMapper
      * @return 结果
      */
     public int deleteNoticeSupplyByIds(String[] ids);
+
+    /**
+     * @descption: 获取最新的供应信息前10条
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 11:15
+     */
+    public List<NoticeSupply> getSupplyInfoTenList();
 }

+ 10 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/INoticeDemandService.java

@@ -58,4 +58,14 @@ public interface INoticeDemandService
      * @return 结果
      */
     public int deleteNoticeDemandById(Long id);
+
+
+    /**
+     * @descption: 获取最新的需求信息前10条
+     * @param: 无
+     * @return: 返回最新的需求信息前10条
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 10:17
+     */
+    public List<NoticeDemand> getDemandInfoTenList();
 }

+ 9 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/INoticeSupplyService.java

@@ -58,4 +58,13 @@ public interface INoticeSupplyService
      * @return 结果
      */
     public int deleteNoticeSupplyById(Long id);
+
+    /**
+     * @descption: 获取最新的供应信息前10条
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 11:13
+     */
+    public List<NoticeSupply> getSupplyInfoTenList();
 }

+ 12 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/impl/NoticeDemandServiceImpl.java

@@ -94,4 +94,16 @@ public class NoticeDemandServiceImpl implements INoticeDemandService
     {
         return noticeDemandMapper.deleteNoticeDemandById(id);
     }
+
+    /**
+     * @descption: 获取最新的需求信息前10条
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-25 10:19
+     */
+    @Override
+    public List<NoticeDemand> getDemandInfoTenList() {
+        return noticeDemandMapper.getDemandInfoTenList();
+    }
 }

+ 5 - 0
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/notice/service/impl/NoticeSupplyServiceImpl.java

@@ -94,4 +94,9 @@ public class NoticeSupplyServiceImpl implements INoticeSupplyService
     {
         return noticeSupplyMapper.deleteNoticeSupplyById(id);
     }
+
+    @Override
+    public List<NoticeSupply> getSupplyInfoTenList() {
+        return noticeSupplyMapper.getSupplyInfoTenList();
+    }
 }

+ 16 - 1
dgtly-member/dgtly-member-common/src/main/resources/mapper/member/MemberInfoMapper.xml

@@ -90,5 +90,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
-    
+
+    <select id="checkMemberUnique" parameterType="java.lang.String" resultMap="MemberInfoResult">
+          select id, login_account, login_password
+          from member_info where login_account = #{loginAccount}
+    </select>
+
+    <select id="checkMemberPhoneUnique" parameterType="java.lang.String" resultMap="MemberInfoResult">
+        select id, login_account, login_password
+        from member_info where phone = #{phone}
+    </select>
+
+
+    <select id="memberLogin" parameterType="MemberInfo" resultMap="MemberInfoResult">
+          select id, login_account, login_password
+          from member_info where (login_account = #{loginAccount} or phone = #{phone}) and login_password = #{loginPassword}
+    </select>
 </mapper>

+ 7 - 0
dgtly-member/dgtly-member-common/src/main/resources/mapper/notice/NoticeDemandMapper.xml

@@ -113,4 +113,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
     
+    
+    <select id="getDemandInfoTenList" resultMap="NoticeDemandResult">
+        select id, member_id, purchase_title,release_time from notice_demand
+        order by release_time desc limit 0,10
+
+    </select>
+    
 </mapper>

+ 11 - 0
dgtly-member/dgtly-member-common/src/main/resources/mapper/notice/NoticeSupplyMapper.xml

@@ -143,5 +143,16 @@ FROM
             #{id}
         </foreach>
     </delete>
+
+
+    <select id="getSupplyInfoTenList" resultMap="NoticeSupplyResult">
+        select id,
+        type_id,
+        supply_title,
+        release_time
+        from notice_supply
+        order by release_time desc limit 0,10
+
+    </select>
     
 </mapper>

+ 1 - 1
dgtly-system/src/main/resources/mapper/system/SysNoticeMapper.xml

@@ -104,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
             ORDER BY create_time desc
             <if test="limitFlag != null and limitFlag != ''">
-                LIMIT 0,3
+                LIMIT 0,5
             </if>
 
         </where>