<?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.koukay.mapper.AppPackageMapper" > <select id="getAllApps" resultType="com.koukay.entity.AppPackModel" >
SELECT
<include refid="base_app_sql"/>,
3 AS authLevel
FROM
h_app_package h
</select>
<select id="getAppsAuth" resultType="com.koukay.entity.PermissionAppRoleUserDepartmentModel" >
SELECT
<include refid="base_app_sql"/>,
authLevel
FROM
h_app_dept_role_user h
</select>
<sql id="base_app_sql">
h.agentId,
h.appKey,
h.appSecret,
h.CODE,
h.creater,
h.createdTime,
h.deleted,
h.enabled,
h.id,
h.logoUrl,
h.logoUrlId,
h.modifier,
h.modifiedTime,
h.NAME,
h.name_i18n,
h.remarks,
h.sortKey
</sql>
<!--入参为多个集合参数-->
<select id="getApps" resultType="com.koukay.entity.AppPackModel" >
SELECT
<include refid="base_app_sql"/>,
h1.authLevel
FROM
h_app_dept_role_user h1
INNER JOIN h_app_package h ON h1.appCode = h.`code`
WHERE
h1.userId = #{userId}
<if test="rolesIds !=null and rolesIds.size()>0">
OR h1.roleId IN
<foreach collection="rolesIds" item="params" index="index" open="(" close=")" separator=",">
#{params.roleId}
</foreach>
</if>
<if test="deptsIds !=null and deptsIds.size()>0">
OR h1.deptId IN
<foreach collection="deptsIds" item="params" index="index" open="(" close=")" separator=",">
#{params.deptId}
</foreach>
</if>

UNION ALL
SELECT
<include refid="base_app_sql"/>,
3 AS authLevel
FROM
h_app_package h
WHERE
h.creater = #{userId}
</select>
<!-- 应用授权 1:给组织授权,2:给角色授权,3:给用户授权-->
<insert id="grantApp" parameterType="com.koukay.entity.PermissionAppRoleUserDepartmentModel">
INSERT INTO h_app_dept_role_user
( id, creater, createdTime, appCode,authLevel,authType,
        <!--插入时对字段做动态选择-->
<if test="authType=='1'.toString() ">
deptId
</if>
<if test="authType=='2'.toString() ">
roleId
</if>
<if test="authType=='3'.toString() ">
userId
</if>

)
VALUES
<foreach collection ="authList" item="param" index= "index" separator ="," >
(
(SELECT REPLACE(UUID(), '-', '') AS id),<!--生成UUID-->
#{createdBy,jdbcType=VARCHAR},
#{createdTime,jdbcType=TIMESTAMP},
#{appCode,jdbcType=VARCHAR},
#{param.authLevel,jdbcType=VARCHAR},
#{authType,jdbcType=VARCHAR},
#{param.id,jdbcType=VARCHAR}
)
</foreach>
</insert>
<delete id="deleteAuth">
delete from h_app_dept_role_user
<where>
<if test="id != null and id != ''">
id = #{id,jdbcType=VARCHAR}
</if>
<if test="appCode != null and appCode != ''">
and appCode = #{appCode,jdbcType=VARCHAR}
</if>
<if test="authType != null and authType != ''">
and authType = #{authType,jdbcType=VARCHAR}
</if>
</where>
</delete>
</mapper>
@Mapper
public interface AppPackageMapper { void grantApp(PermissionAppRoleUserDepartmentModel permissionAppRoleUserDepartmentModel); List<AppPackModel> getApps(Map params); List<AppPackModel> getAllApps(); void deleteAuth(Map<String, Object> param); List<PermissionAppRoleUserDepartmentModel> getAppsAuth();
}
@ApiModel(
description = "应用角色,应用组织,应用用户 关联对象"
)
@Data
public class PermissionAppRoleUserDepartmentModel extends BaseModel {
@ApiModelProperty("权限组名称")
private String name; @ApiModelProperty("关联的应用编码")
private String appCode; @ApiModelProperty(value = "授权集合")
private List<KeyValueModel> authList; @ApiModelProperty("权限级别,1:查看权限,2:操作权限,3:授权权限")
private String authLevel; @ApiModelProperty("权限类型,1:给组织授权,2:给角色授权,3:给用户授权")
private String authType; }

mybatis踩过的坑的更多相关文章

  1. 项目中踩过的坑之-sessionStorage

    总想写点什么,却不知道从何写起,那就从项目中踩过的坑开始吧,希望能给可能碰到相同问题的小伙伴一点帮助. 项目情景: 有一个id,要求通过当前网页打开一个新页面(不是当前页面),并把id传给打开的新页面 ...

  2. web开发实战--弹出式富文本编辑器的实现思路和踩过的坑

    前言: 和弟弟合作, 一起整了个智慧屋的小web站点, 里面包含了很多经典的智力和推理题. 其实该站点从技术层面来分析的话, 也算一个信息发布站点. 因此在该网站的后台运营中, 富文本的编辑器显得尤为 ...

  3. "开发路上踩过的坑要一个个填起来————持续更新······(7月30日)"

    欢迎转载,请注明出处! https://gii16.github.io/learnmore/2016/07/29/problem.html 踩过的坑及解决方案记录在此篇博文中! 个人理解,如有偏颇,欢 ...

  4. 【转载】Fragment 全解析(1):那些年踩过的坑

    http://www.jianshu.com/p/d9143a92ad94 Fragment系列文章:1.Fragment全解析系列(一):那些年踩过的坑2.Fragment全解析系列(二):正确的使 ...

  5. Redis Cluster踩过的坑

    Redis Cluster踩过的坑请参考如下链接:http://www.iteye.com/blogs/subjects/Redis_Cluster_Devops

  6. 第八篇:web之前端踩的一些坑

    前端踩的一些坑   前端踩的一些坑 本节内容 事件代理 清除标签的所有事件 bootstrap的模态框自定义方法 ajax在django里面实现post提交 ajax提交数据嵌套 1.事件代理 之前写 ...

  7. 使用ffmpeg视频编码过程中踩的一个坑

           今天说说使用ffmpeg在写视频编码程序中踩的一个坑,这个坑让我花了好多时间,回头想想,非常多时候一旦思维定势真的挺难突破的.以下是不对的编码结果:                   ...

  8. 那些年踩过的坑之:first-child伪类选择器

    原文:那些年踩过的坑之:first-child伪类选择器 :first-child 选择器用于选取属于其父元素的首个子元素的指定选择器.——w3school 嗯,乍一看好像说的不是很明白,因此这个选择 ...

  9. 《C++之那些年踩过的坑(二)》

    C++之那些年踩过的坑(二) 作者:刘俊延(Alinshans) 本系列文章针对我在写C++代码的过程中,尤其是做自己的项目时,踩过的各种坑.以此作为给自己的警惕. 今天讲一个小点,虽然小,但如果没有 ...

随机推荐

  1. Delphi 类库(DLL)动态调用与静态调用示例讲解

    在Delphi或者其它程序中我们经常需要调用别人写好的DLL类库,下面直接上示例代码演示如何进行动态和静态的调用方法: { ************************************** ...

  2. PHP入门-Window 下利用Nginx+PHP 搭建环境

    前言 最近公司有个PHP项目需要开发维护,之前一直都是跟着巨硬混的,现在要接触PHP项目.学习一门新语言之前,先搭建好环境吧,鉴于公司项目是基于php 7.1.33 版本的,所以以下我使用的都是基于这 ...

  3. [AcWing 756] 蛇形矩阵

    点击查看代码 #include<iostream> using namespace std; const int N = 110; int n, m; int dx[] = {-1, 0, ...

  4. 测试必会 Docker 实战(一):掌握高频命令,夯实内功基础

    在 Dokcer 横空出世之前,应用打包一直是大部分研发团队的痛点.在工作中,面对多种服务,多个服务器,以及多种环境,如果还继续用传统的方式打包部署,会浪费大量时间精力. 在 Docker 出现后,它 ...

  5. 从零开始搭建高可用的k8s集群

    一.环境准备 使用Hyper-V虚拟机功能搭建三台Centos虚拟机系统,配置好静态IP,分别为k8s-node1(192.168.0.8),k8s-node2(192.168.0.9),k8s-no ...

  6. Flask01 第一个flask项目

    参考地址:https://github.com/miguelgrinberg/microblog/tree/v0.1 flask环境[苹果M1] 添加虚拟环境 python3 -m venv venv ...

  7. Linux下使用ssh测试端口是否开启

    当服务器上不允许使用telnet时,可以使用ssh测试远程服务器端口是否开启 具体命令如下 -v 显示连接debug信息 -p port 指定端口 ssh -v -p 80 root@192.168. ...

  8. VMware服务关闭后一定要重启

    重要的事情说三遍:服务暂时关闭记得重启,服务暂时关闭记得重启,服务暂时关闭记得重启!!! VMware服务由于安装补丁的需要我暂时把服务关闭了,于是我遇到了尴尬的一幕,于是乎发现上不了网了,于是各种操 ...

  9. 从NSSRound#1学到了什么

    sql_by_sql 二次注入: 更改密码的功能形如: update user set password='%s' where username='%s'; 的语句就可以存在二次注入,即假设有个adm ...

  10. CI/CD介绍以及jenkins安装 1.1

    一 .CI/CD介绍    互联网软件开发和发布,形成了一套流程标准,分为几个阶段:编码,构建,集成,测试,交付,部署  持续集成(continuous integration).持续交付(conti ...