dcs 11 månader sedan
förälder
incheckning
1f934ab44a

+ 6 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/controller/TagController.java

@@ -40,6 +40,12 @@ public class TagController {
         return Response.ok(tagService.getType(type));
     }
 
+    @ApiOperation("根据code获取")
+    @RequestMapping(value = "/code/{code}", method = RequestMethod.POST)
+    public Response getList(@PathVariable String code) {
+        return Response.ok(tagService.getCode(code));
+    }
+
     @ApiOperation("根据organizationId和type获取,type 1:项目,2:单位工程,3:房源")
     @RequestMapping(value = "/{organizationId}/{type}", method = RequestMethod.GET)
     public Response getOrganizationId(@PathVariable long organizationId, @PathVariable int type) {

+ 2 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/TagDao.java

@@ -18,6 +18,8 @@ public interface TagDao {
 
     List<Tag> getType(int type);
 
+    List<Tag> getCode(String code);
+
     List<Tag> getOrganizationId(long organizationId, int type);
 
     int delete(long id);

+ 13 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/Tag.java

@@ -8,6 +8,11 @@ public class Tag {
 
     private long id;
 
+    /**
+     * 地区code
+     */
+    private String  code;
+
     /**
      * 名称
      */
@@ -31,6 +36,14 @@ public class Tag {
         this.id = id;
     }
 
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
     public String getName() {
         return name;
     }

+ 4 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/service/TagService.java

@@ -29,6 +29,10 @@ public class TagService {
         return tagDao.getType(type);
     }
 
+    public List<Tag> getCode(String code) {
+        return tagDao.getCode(code);
+    }
+
     public List<Tag> getOrganizationId(long organizationId, int type) {
         return tagDao.getOrganizationId(organizationId, type);
     }
@@ -37,5 +41,4 @@ public class TagService {
         return tagDao.delete(id);
     }
 
-
 }

+ 12 - 4
virgo.api/src/main/resources/mapper/TagMapper.xml

@@ -6,6 +6,7 @@
 
     <resultMap type="com.bosshand.virgo.api.model.Tag" id="tagResult">
         <id column="id" property="id"/>
+        <result column="code" property="code"/>
         <result column="name" property="name"/>
         <result column="type" property="type"/>
         <result column="organizationId" property="organizationId"/>
@@ -16,11 +17,15 @@
     </select>
 
     <select id="getType" resultMap="tagResult">
-        select * from tag where type = #{type}
+        select * from tag where type = #{type} or type = 0
+    </select>
+
+    <select id="getCode" resultMap="tagResult">
+        select * from tag where code = #{code} or type = 0
     </select>
 
     <select id="getOrganizationId" resultMap="tagResult">
-        select * from tag where organizationId = #{organizationId} and type = #{type}
+        select * from tag where organizationId = #{organizationId} and type = #{type} or type = 0
     </select>
 
     <select id="getList" resultMap="tagResult">
@@ -29,10 +34,13 @@
             <if test="id != 0">
                 and id = #{id}
             </if>
+            <if test="code != null">
+                and code = #{code}
+            </if>
             <if test="name != null">
                 and name = #{name}
             </if>
-            <if test="type != 0">
+            <if test="type != -1">
                 and type = #{type}
             </if>
             <if test="organizationId != 0">
@@ -53,7 +61,7 @@
         UPDATE tag
         <trim prefix="set" suffixOverrides=",">
             <if test="name!=null">name=#{name},</if>
-            <if test="type!=0">type=#{type},</if>
+            <if test="type!=-1">type=#{type},</if>
             <if test="organizationId!=0">organizationId=#{organizationId},</if>
         </trim>
         WHERE id=#{id}