dcs 1 rok temu
rodzic
commit
df7154a303

+ 24 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/dao/MgrAgentDao.java

@@ -0,0 +1,24 @@
+package com.bosshand.virgo.core.dao;
+
+import com.bosshand.virgo.core.model.MgrAgent;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface MgrAgentDao {
+
+    int insert(MgrAgent mgrAgent);
+
+    int update(MgrAgent mgrAgent);
+
+    MgrAgent get(long id);
+
+    int delete(long id);
+
+    int getTotalCount(MgrAgent mgrAgent);
+
+    List<MgrAgent> getLimit(@Param("p") MgrAgent p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
+}

+ 108 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/model/MgrAgent.java

@@ -0,0 +1,108 @@
+package com.bosshand.virgo.core.model;
+
+/**
+ * 经纪人、中介
+ */
+public class MgrAgent {
+
+    private long id;
+
+    /**
+     * 组织id
+     */
+    private long organizationId;
+
+    /**
+     * 创建者id
+     */
+    private long userId;
+
+    /**
+     * 姓名
+     */
+    private String name;
+
+    /**
+     * 联系电话
+     */
+    private String phone;
+
+    /**
+     * 主营商圈
+     */
+    private String primaryArea;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 名片
+     */
+    private String businessCard;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getOrganizationId() {
+        return organizationId;
+    }
+
+    public void setOrganizationId(long organizationId) {
+        this.organizationId = organizationId;
+    }
+
+    public long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(long userId) {
+        this.userId = userId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getPrimaryArea() {
+        return primaryArea;
+    }
+
+    public void setPrimaryArea(String primaryArea) {
+        this.primaryArea = primaryArea;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getBusinessCard() {
+        return businessCard;
+    }
+
+    public void setBusinessCard(String businessCard) {
+        this.businessCard = businessCard;
+    }
+}

+ 13 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/model/MgrOrganizationProject.java

@@ -27,6 +27,11 @@ public class MgrOrganizationProject {
      */
     private long clientId;
 
+    /**
+     * 经纪人、中介id
+     */
+    private long agentId;
+
     /**
      * 身份id
      */
@@ -72,6 +77,14 @@ public class MgrOrganizationProject {
         this.clientId = clientId;
     }
 
+    public long getAgentId() {
+        return agentId;
+    }
+
+    public void setAgentId(long agentId) {
+        this.agentId = agentId;
+    }
+
     public long getIdentityId() {
         return identityId;
     }

+ 70 - 0
virgo.core/src/main/resources/mapper/MgrAgentMapper.xml

@@ -0,0 +1,70 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.core.dao.MgrAgentDao">
+
+    <resultMap type="com.bosshand.virgo.core.model.MgrAgent" id="agentResult">
+        <id column="id" property="id"/>
+        <result column="organizationId" property="organizationId"/>
+        <result column="userId" property="userId"/>
+        <result column="name" property="name"/>
+        <result column="phone" property="phone"/>
+        <result column="primaryArea" property="primaryArea"/>
+        <result column="remark" property="remark"/>
+        <result column="businessCard" property="businessCard"/>
+    </resultMap>
+
+    <insert id="insert" parameterType="com.bosshand.virgo.core.model.MgrAgent" useGeneratedKeys="true" keyProperty="id">
+        INSERT INTO mgr_agent(`organizationId`, `userId`, `name`, `phone`, `primaryArea`, `remark`, `businessCard`)
+        VALUES (#{organizationId}, #{userId}, #{name}, #{phone}, #{primaryArea}, #{remark}, #{businessCard})
+    </insert>
+
+    <delete id="delete">
+        DELETE from mgr_agent where id=#{id}
+    </delete>
+
+    <update id="update" parameterType="com.bosshand.virgo.core.model.MgrAgent">
+        UPDATE mgr_agent
+        <trim prefix="set" suffixOverrides=",">
+            <if test="name!=null">name=#{name},</if>
+            <if test="phone!=null">phone=#{phone},</if>
+            <if test="primaryArea!=null">primaryArea=#{primaryArea},</if>
+            <if test="remark!=null">remark=#{remark},</if>
+            <if test="businessCard!=null">businessCard=#{businessCard},</if>
+        </trim>
+        WHERE id=#{id}
+    </update>
+
+    <select id="get" resultMap="clientResult">
+        SELECT * FROM mgr_agent where id = #{id}
+    </select>
+
+    <select id="getTotalCount" parameterType="com.bosshand.virgo.core.model.MgrAgent" resultType="Integer">
+        SELECT count(*) FROM mgr_agent
+        <where>
+            <if test="organizationId!=0">and organizationId=#{organizationId}</if>
+            <if test="userId!=0">and userId=#{userId}</if>
+            <if test="name!=null">and name=#{name}</if>
+            <if test="phone!=null">and phone=#{phone}</if>
+            <if test="primaryArea!=null">and primaryArea=#{primaryArea}</if>
+            <if test="remark!=null">and remark=#{remark}</if>
+            <if test="businessCard!=null">and businessCard=#{businessCard}</if>
+        </where>
+    </select>
+
+    <select id="getLimit" resultMap="agentResult">
+        SELECT * FROM mgr_agent
+        <where>
+            <if test="p.organizationId!=0">and organizationId=#{p.organizationId}</if>
+            <if test="p.userId!=0">and userId=#{p.userId}</if>
+            <if test="p.name!=null">and name=#{p.name}</if>
+            <if test="p.phone!=null">and phone=#{p.phone}</if>
+            <if test="p.primaryArea!=null">and primaryArea=#{p.primaryArea}</if>
+            <if test="p.remark!=null">and remark=#{p.remark}</if>
+            <if test="p.businessCard!=null">and businessCard=#{p.businessCard}</if>
+        </where>
+        limit #{currIndex} , #{pageSize}
+    </select>
+
+</mapper>

+ 2 - 1
virgo.core/src/main/resources/mapper/MgrClientMapper.xml

@@ -44,6 +44,7 @@
             <if test="name!=null">name=#{name},</if>
             <if test="type!=0">type=#{type},</if>
             <if test="person!=null">person=#{person},</if>
+            <if test="phone!=null">phone=#{phone},</if>
             <if test="weChatAccount!=null">weChatAccount=#{weChatAccount},</if>
             <if test="followUpState!=0">followUpState=#{followUpState},</if>
             <if test="job!=null">job=#{job},</if>
@@ -55,7 +56,7 @@
             <if test="visitingChannels!=null">visitingChannels=#{visitingChannels},</if>
             <if test="visitingTime!=null">visitingTime=#{visitingTime},</if>
             <if test="remark!=null">remark=#{remark},</if>
-            <if test="status!=0">status=#{status},</if>
+            <if test="status!=null">status=#{status},</if>
             <if test="highSeas!=0">highSeas=#{highSeas},</if>
         </trim>
         WHERE id=#{id}

+ 2 - 1
virgo.core/src/main/resources/mapper/MgrOrganizationProjectMapper.xml

@@ -10,6 +10,7 @@
         <result column="projectId" property="projectId"/>
         <result column="userId" property="userId"/>
         <result column="clientId" property="clientId"/>
+        <result column="agentId" property="agentId"/>
         <result column="identityId" property="identityId"/>
     </resultMap>
 
@@ -26,7 +27,7 @@
     </select>
 
     <insert id="insert">
-        insert into mgr_organization_project (organizationId, projectId, userId, clientId, identityId) value (#{organizationId}, #{projectId}, #{userId}, #{clientId}, #{identityId})
+        insert into mgr_organization_project (organizationId, projectId, userId, clientId, agentId, identityId) value (#{organizationId}, #{projectId}, #{userId}, #{clientId}, #{agentId}, #{identityId})
     </insert>
 
     <delete id="delete">

+ 64 - 0
virgo.manager/src/main/java/com/bosshand/virgo/controller/AgentController.java

@@ -0,0 +1,64 @@
+package com.bosshand.virgo.controller;
+
+import com.bosshand.virgo.core.model.MgrAgent;
+import com.bosshand.virgo.core.response.Response;
+import com.bosshand.virgo.core.utils.ContextUtils;
+import com.bosshand.virgo.service.AgentService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("agent")
+public class AgentController {
+
+    @Autowired
+    AgentService agentService;
+
+    @ApiOperation("获取")
+    @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
+    public Response list(@RequestBody MgrAgent mgrAgent, @PathVariable int currPage, @PathVariable int pageSize) {
+        long id = ContextUtils.getCurrentUser().getId();
+        mgrAgent.setUserId(id);
+        int totalCount = agentService.getTotalCount(mgrAgent);
+        List<MgrAgent> dataList = agentService.getLimit(mgrAgent, currPage, pageSize);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
+    @ApiOperation("保存")
+    @RequestMapping(value = "", method = RequestMethod.POST)
+    public Response insert(@RequestBody MgrAgent mgrAgent) {
+        long id = ContextUtils.getCurrentUser().getId();
+        mgrAgent.setUserId(id);
+        agentService.insert(mgrAgent);
+        return Response.ok();
+    }
+
+    @ApiOperation("更新")
+    @RequestMapping(value = "/update", method = RequestMethod.PUT)
+    public Response update(@RequestBody MgrAgent mgrAgent) {
+        agentService.update(mgrAgent);
+        return Response.ok();
+    }
+
+    @ApiOperation("删除")
+    @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
+    public Response delete(@PathVariable long id) {
+        agentService.delete(id);
+        return Response.ok();
+    }
+
+    @ApiOperation("详情")
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public Response get(@PathVariable long id) {
+        return Response.ok(agentService.get(id));
+    }
+
+}

+ 40 - 0
virgo.manager/src/main/java/com/bosshand/virgo/service/AgentService.java

@@ -0,0 +1,40 @@
+package com.bosshand.virgo.service;
+
+import com.bosshand.virgo.core.dao.MgrAgentDao;
+import com.bosshand.virgo.core.model.MgrAgent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class AgentService {
+
+    @Autowired
+    MgrAgentDao agentDao;
+
+    public int insert(MgrAgent mgrAgent) {
+        return agentDao.insert(mgrAgent);
+    }
+
+    public int update(MgrAgent mgrAgent) {
+        return agentDao.update(mgrAgent);
+    }
+
+    public MgrAgent get(long id) {
+        return agentDao.get(id);
+    }
+
+    public int delete(long id) {
+        return agentDao.delete(id);
+    }
+
+    public int getTotalCount(MgrAgent mgrAgent) {
+        return agentDao.getTotalCount(mgrAgent);
+    }
+
+    public List<MgrAgent> getLimit(MgrAgent mgrAgent, int currPage, int pageSize) {
+        int currIndex = (currPage - 1) * pageSize;
+        return agentDao.getLimit(mgrAgent, currIndex, pageSize);
+    }
+}