Browse Source

接口api

liulingchao 4 years ago
parent
commit
267d007547

+ 61 - 6
dgtly-member/dgtly-member-api/src/main/java/com/dgtly/member/controller/DemandInfoController.java

@@ -1,5 +1,6 @@
 package com.dgtly.member.controller;
 
+import com.dgtly.apiframework.util.TokenUtil;
 import com.dgtly.common.annotation.ApiNoCheckSign;
 import com.dgtly.common.annotation.ApiPassToken;
 import com.dgtly.common.core.controller.ApiBaseController;
@@ -7,6 +8,7 @@ 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.common.utils.StringUtils;
 import com.dgtly.notice.domain.NoticeDemand;
 import com.dgtly.notice.service.INoticeDemandService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -81,18 +83,71 @@ public class DemandInfoController extends ApiBaseController {
         return AjaxResult.success(getDataTable(noticeDemandList));
     }
 
+    /**
+     * @descption: 发布需求信息
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 16:03
+     */
     @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);
+        String userId = TokenUtil.getTokenUserId();
+        if(StringUtils.isNotEmpty(userId)){
+            ParameterObject obj =  getParameterObject();
+            NoticeDemand noticeDemand = obj.parseBean(NoticeDemand.class);
+            noticeDemand.setMemberId(Long.parseLong(userId));
+            noticeDemand.setCreateTime(DateUtils.getNowDate());
+            noticeDemand.setReleaseTime(DateUtils.getNowDate());
+            int flag = noticeDemandService.insertNoticeDemand(noticeDemand);
+            return toAjax(flag);
+        }else{
+            return AjaxResult.error(301,"获取token信息出错");
+        }
+
     }
 
 
 
+    /**
+     * @descption: 获取网站用户发布的需求
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 16:08
+     */
+    @PostMapping("/getMemberDemandList")
+    public Object getMemberDemandList(){
+        String userId = TokenUtil.getTokenUserId();
+        if(StringUtils.isNotEmpty(userId)){
+            ParameterObject obj =  getParameterObject();
+            startPage(obj);
+            NoticeDemand noticeDemand = new NoticeDemand();
+
+            noticeDemand.setMemberId(Long.parseLong(userId));
+            List<NoticeDemand> noticeDemandList = noticeDemandService.selectNoticeDemandList(noticeDemand);
+            return AjaxResult.success(getDataTable(noticeDemandList));
+
+        }else{
+            return AjaxResult.error(301,"获取token信息出错");
+        }
+    }
+
+
+    /**
+     * @descption: 撤销需求
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 16:17
+     */
+    @PostMapping("/cancleMemberDemandInfo")
+    public Object cancleMemberDemandInfo(){
+        ParameterObject obj =  getParameterObject();
+        NoticeDemand noticeDemand = obj.parseBean(NoticeDemand.class);
+        int flag = noticeDemandService.deleteNoticeDemandById(noticeDemand.getId());
+        return toAjax(flag);
+    }
 
 
 }

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

@@ -0,0 +1,98 @@
+package com.dgtly.member.controller;
+
+import com.dgtly.apiframework.util.TokenUtil;
+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.utils.DateUtils;
+import com.dgtly.common.utils.StringUtils;
+import com.dgtly.member.domain.MemberFollow;
+import com.dgtly.member.service.IMemberFollowService;
+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-27 15:10
+  * @since JDK1.8
+  */
+@RestController
+@RequestMapping("/member/follow")
+@ApiPassToken/* 不用验证token  方法上可用*/
+@ApiNoCheckSign/* 不用验证 签名 方法上可用*/
+public class MemberFollowApi extends ApiBaseController {
+
+    @Autowired
+    private IMemberFollowService iMemberFollowService;
+    /**
+     * @descption: 网站会员关注添加
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 15:11
+     */
+    @PostMapping("/addMemberFollow")
+    public Object addMemberFollow(){
+        //获取token中用户id
+        String userId = TokenUtil.getTokenUserId();
+        if(StringUtils.isNotEmpty(userId)){
+            ParameterObject obj =  getParameterObject();
+            MemberFollow memberFollow = obj.parseBean(MemberFollow.class);
+            memberFollow.setMemberId(Long.parseLong(userId));
+            memberFollow.setFollowDate(DateUtils.getNowDate());
+            int flag = iMemberFollowService.insertMemberFollow(memberFollow);
+            return toAjax(flag);
+        }else{
+            return AjaxResult.error(301,"获取token出错");
+        }
+    }
+
+    /**
+     * @descption: 网站用户取消关注
+     * @param: 关注id
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 15:35
+     */
+    @PostMapping("/cancleMemberFollow")
+    public Object cancleMemberFollow(){
+        ParameterObject obj =  getParameterObject();
+        MemberFollow memberFollow = obj.parseBean(MemberFollow.class);
+        int flag = iMemberFollowService.deleteMemberFollowById(memberFollow.getId());
+        return toAjax(flag);
+    }
+
+    /**
+     * @descption: 获取网站会员关注的商户列表
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 15:57
+     */
+    @PostMapping("/getMemberFollowList")
+    public Object getMemberFollowList(){
+        String userId = TokenUtil.getTokenUserId();
+        if(StringUtils.isNotEmpty(userId)){
+            ParameterObject obj =  getParameterObject();
+            startPage(obj);
+            MemberFollow memberFollow = new MemberFollow();
+            memberFollow.setMemberId(Long.parseLong(userId));
+
+            List<MemberFollow> memberFollowList = iMemberFollowService.getMemberFollowList(memberFollow);
+            return AjaxResult.success(getDataTable(memberFollowList));
+        }else{
+            return AjaxResult.error(301,"获取token出错");
+        }
+
+    }
+}

+ 22 - 1
dgtly-member/dgtly-member-common/src/main/java/com/dgtly/member/domain/MemberFollow.java

@@ -31,7 +31,28 @@ public class MemberFollow extends BaseEntity
     @Excel(name = "关注日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date followDate;
 
-    public void setId(Long id) 
+    //商户主营商品
+    private String primaryBusiness;
+    //商户名称
+    private String companyName;
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getPrimaryBusiness() {
+        return primaryBusiness;
+    }
+
+    public void setPrimaryBusiness(String primaryBusiness) {
+        this.primaryBusiness = primaryBusiness;
+    }
+
+    public void setId(Long id)
     {
         this.id = id;
     }

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

@@ -58,4 +58,14 @@ public interface MemberFollowMapper
      * @return 结果
      */
     public int deleteMemberFollowByIds(String[] ids);
+
+
+    /**
+     * @descption: 获取网站用户关注商户列表
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 15:55
+     */
+    public List<MemberFollow> getMemberFollowList(MemberFollow memberFollow);
 }

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

@@ -58,4 +58,13 @@ public interface IMemberFollowService
      * @return 结果
      */
     public int deleteMemberFollowById(Long id);
+
+    /**
+     * @descption: 获取网站用户关注的商户列表
+     * @param:
+     * @return:
+     * @auther: LiuLingChao
+     * @date: 2020-2-27 15:53
+     */
+    public List<MemberFollow> getMemberFollowList(MemberFollow memberFollow);
 }

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

@@ -96,4 +96,9 @@ public class MemberFollowServiceImpl implements IMemberFollowService
     {
         return memberFollowMapper.deleteMemberFollowById(id);
     }
+
+    @Override
+    public List<MemberFollow> getMemberFollowList(MemberFollow memberFollow) {
+        return memberFollowMapper.getMemberFollowList(memberFollow);
+    }
 }

+ 12 - 0
dgtly-member/dgtly-member-common/src/main/resources/mapper/member/MemberFollowMapper.xml

@@ -14,10 +14,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="remark"    column="remark"    />
+        <result property="primaryBusiness"    column="primary_business"    />
+        <result property="companyName"    column="company_name"    />
+
     </resultMap>
 
     <sql id="selectMemberFollowVo">
         select id, member_id, company_id, follow_date, create_by, create_time, update_by, update_time, remark from member_follow
+
     </sql>
 
     <select id="selectMemberFollowList" parameterType="MemberFollow" resultMap="MemberFollowResult">
@@ -85,5 +89,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+
+    <select id="getMemberFollowList" parameterType="MemberFollow" resultMap="MemberFollowResult">
+        select m.id, m.member_id, m.company_id, m.follow_date,s.primary_business,s.company_name from member_follow m
+        left join sys_company s on m.company_id = s.id
+        where  m.member_id = #{memberId}
+
+    </select>
     
 </mapper>

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

@@ -119,5 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by release_time desc limit 0,10
 
     </select>
+
+
     
 </mapper>