dcs 11 bulan lalu
induk
melakukan
b7a8458e2f

+ 19 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/dao/IdentityResourceDao.java

@@ -0,0 +1,19 @@
+package com.bosshand.virgo.core.dao;
+
+import com.bosshand.virgo.core.model.IdentityResource;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface IdentityResourceDao {
+
+    int insert(IdentityResource identityResource);
+
+    int update(IdentityResource identityResource);
+
+    int delete(long id);
+
+    List<IdentityResource> getList(IdentityResource identityResource);
+
+}

+ 12 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/model/Identity.java

@@ -1,5 +1,7 @@
 package com.bosshand.virgo.core.model;
 
+import java.util.List;
+
 /**
  * 身份
  */
@@ -17,6 +19,8 @@ public class Identity {
      */
     private String remark;
 
+    private List<IdentityResource> resourceList;
+
     public long getId() {
         return id;
     }
@@ -40,4 +44,12 @@ public class Identity {
     public void setRemark(String remark) {
         this.remark = remark;
     }
+
+    public List<IdentityResource> getResourceList() {
+        return resourceList;
+    }
+
+    public void setResourceList(List<IdentityResource> resourceList) {
+        this.resourceList = resourceList;
+    }
 }

+ 82 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/model/IdentityResource.java

@@ -0,0 +1,82 @@
+package com.bosshand.virgo.core.model;
+
+/**
+ * 身份资源
+ */
+public class IdentityResource {
+
+    private long id;
+
+    /**
+     * 身份Id
+     */
+    private long identityId;
+
+    /**
+     * 项目类型
+     */
+    private Integer type;
+
+    /**
+     * 菜单
+     */
+    private String menus;
+
+    /**
+     * 资源
+     */
+    private String resource;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getIdentityId() {
+        return identityId;
+    }
+
+    public void setIdentityId(long identityId) {
+        this.identityId = identityId;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getMenus() {
+        return menus;
+    }
+
+    public void setMenus(String menus) {
+        this.menus = menus;
+    }
+
+    public String getResource() {
+        return resource;
+    }
+
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 19 - 2
virgo.core/src/main/resources/mapper/IdentityMapper.xml

@@ -2,18 +2,35 @@
 <!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.IdentityDao">
 
+    <resultMap type="com.bosshand.virgo.core.model.Identity" id="result">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="remark" property="remark"/>
+    </resultMap>
+
     <resultMap type="com.bosshand.virgo.core.model.Identity" id="identityResult">
         <id column="id" property="id"/>
         <result column="name" property="name"/>
         <result column="remark" property="remark"/>
+        <collection property="resourceList" ofType="com.bosshand.virgo.core.model.IdentityResource" resultMap="com.bosshand.virgo.core.dao.IdentityResourceDao.result" columnPrefix="identityResult_"/>
     </resultMap>
 
+    <sql id="query">
+        select a.*,
+               b.identityId as identityResult_identityId,
+               b.type as identityResult_type,
+               b.menus as identityResult_menus,
+               b.resource as identityResult_resource,
+               b.remark as identityResult_remark
+        from identity a LEFT JOIN identity_resource b ON a.id = b.identityId
+    </sql>
+
     <select id="getList" resultMap="identityResult">
-        select * from identity
+        <include refid="query"/>
     </select>
 
     <select id="getIds" resultMap="identityResult">
-        select * from identity id in
+        <include refid="query"/> where a.id in
         <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
             #{item}
         </foreach>

+ 38 - 0
virgo.core/src/main/resources/mapper/IdentityResourceMapper.xml

@@ -0,0 +1,38 @@
+<?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.bosshand.virgo.core.dao.IdentityResourceDao">
+
+    <resultMap type="com.bosshand.virgo.core.model.IdentityResource" id="result">
+        <id column="id" property="id"/>
+        <result column="identityId" property="identityId"/>
+        <result column="type" property="type"/>
+        <result column="menus" property="menus"/>
+        <result column="resource" property="resource"/>
+        <result column="remark" property="remark"/>
+    </resultMap>
+
+    <select id="getList" resultMap="result">
+        select * from identity_resource
+    </select>
+
+    <insert id="insert" parameterType="com.bosshand.virgo.core.model.IdentityResource" useGeneratedKeys="true" keyProperty="id">
+        INSERT INTO identity_resource(identityId, type, menus, resource, remark) VALUES (#{identityId}, #{type}, #{menus}, #{resource}, #{remark})
+    </insert>
+
+    <delete id="delete">
+        DELETE FROM identity_resource WHERE id = #{id}
+    </delete>
+
+    <update id="update" parameterType="com.bosshand.virgo.core.model.IdentityResource">
+        UPDATE identity_resource
+        <trim prefix="set" suffixOverrides=",">
+            <if test="identityId!=0">identityId=#{identityId},</if>
+            <if test="type!=null">type=#{type},</if>
+            <if test="menus!=null">menus=#{menus},</if>
+            <if test="resource!=null">resource=#{resource},</if>
+            <if test="remark!=null">remark=#{remark},</if>
+        </trim>
+        WHERE id = #{id}
+    </update>
+
+</mapper>

+ 31 - 0
virgo.manager/src/main/java/com/bosshand/virgo/controller/IdentityController.java

@@ -1,6 +1,7 @@
 package com.bosshand.virgo.controller;
 
 import com.bosshand.virgo.core.model.Identity;
+import com.bosshand.virgo.core.model.IdentityResource;
 import com.bosshand.virgo.core.response.Response;
 import com.bosshand.virgo.service.IdentityService;
 import io.swagger.annotations.ApiOperation;
@@ -41,5 +42,35 @@ public class IdentityController {
         return Response.ok();
     }
 
+    /**
+     * 身份资源
+     */
+    @ApiOperation("身份资源获取")
+    @RequestMapping(value = "/resource/query", method = RequestMethod.POST)
+    public Response listResource(@RequestBody IdentityResource identityResource) {
+        return Response.ok(identityService.getResourceList(identityResource));
+    }
+
+    @ApiOperation("身份资源保存")
+    @RequestMapping(value = "/resource", method = RequestMethod.POST)
+    public Response insertResource(@RequestBody IdentityResource identityResource) {
+        identityService.insertResource(identityResource);
+        return Response.ok();
+    }
+
+    @ApiOperation("身份资源更新")
+    @RequestMapping(value = "/resource/update", method = RequestMethod.PUT)
+    public Response updateResource(@RequestBody IdentityResource identityResource) {
+        identityService.updateResource(identityResource);
+        return Response.ok();
+    }
+
+    @ApiOperation("身份资源删除")
+    @RequestMapping(value = "/resource/delete/{id}", method = RequestMethod.DELETE)
+    public Response deleteResource(@PathVariable long id) {
+        identityService.deleteResource(id);
+        return Response.ok();
+    }
+
 
 }

+ 24 - 0
virgo.manager/src/main/java/com/bosshand/virgo/service/IdentityService.java

@@ -1,7 +1,9 @@
 package com.bosshand.virgo.service;
 
 import com.bosshand.virgo.core.dao.IdentityDao;
+import com.bosshand.virgo.core.dao.IdentityResourceDao;
 import com.bosshand.virgo.core.model.Identity;
+import com.bosshand.virgo.core.model.IdentityResource;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -13,6 +15,9 @@ public class IdentityService {
     @Autowired
     IdentityDao identityDao;
 
+    @Autowired
+    IdentityResourceDao identityResourceDao;
+
     public int insert(Identity identity) {
         return identityDao.insert(identity);
     }
@@ -29,4 +34,23 @@ public class IdentityService {
         return identityDao.delete(id);
     }
 
+    /**
+     * 身份资源
+     */
+    public int insertResource(IdentityResource identityResource) {
+        return identityResourceDao.insert(identityResource);
+    }
+
+    public int updateResource(IdentityResource identityResource) {
+        return identityResourceDao.update(identityResource);
+    }
+
+    public List<IdentityResource> getResourceList(IdentityResource identityResource) {
+        return identityResourceDao.getList(identityResource);
+    }
+
+    public int deleteResource(long id) {
+        return identityResourceDao.delete(id);
+    }
+
 }