mybatis踩过的坑
<?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踩过的坑的更多相关文章
- 项目中踩过的坑之-sessionStorage
总想写点什么,却不知道从何写起,那就从项目中踩过的坑开始吧,希望能给可能碰到相同问题的小伙伴一点帮助. 项目情景: 有一个id,要求通过当前网页打开一个新页面(不是当前页面),并把id传给打开的新页面 ...
- web开发实战--弹出式富文本编辑器的实现思路和踩过的坑
前言: 和弟弟合作, 一起整了个智慧屋的小web站点, 里面包含了很多经典的智力和推理题. 其实该站点从技术层面来分析的话, 也算一个信息发布站点. 因此在该网站的后台运营中, 富文本的编辑器显得尤为 ...
- "开发路上踩过的坑要一个个填起来————持续更新······(7月30日)"
欢迎转载,请注明出处! https://gii16.github.io/learnmore/2016/07/29/problem.html 踩过的坑及解决方案记录在此篇博文中! 个人理解,如有偏颇,欢 ...
- 【转载】Fragment 全解析(1):那些年踩过的坑
http://www.jianshu.com/p/d9143a92ad94 Fragment系列文章:1.Fragment全解析系列(一):那些年踩过的坑2.Fragment全解析系列(二):正确的使 ...
- Redis Cluster踩过的坑
Redis Cluster踩过的坑请参考如下链接:http://www.iteye.com/blogs/subjects/Redis_Cluster_Devops
- 第八篇:web之前端踩的一些坑
前端踩的一些坑 前端踩的一些坑 本节内容 事件代理 清除标签的所有事件 bootstrap的模态框自定义方法 ajax在django里面实现post提交 ajax提交数据嵌套 1.事件代理 之前写 ...
- 使用ffmpeg视频编码过程中踩的一个坑
今天说说使用ffmpeg在写视频编码程序中踩的一个坑,这个坑让我花了好多时间,回头想想,非常多时候一旦思维定势真的挺难突破的.以下是不对的编码结果: ...
- 那些年踩过的坑之:first-child伪类选择器
原文:那些年踩过的坑之:first-child伪类选择器 :first-child 选择器用于选取属于其父元素的首个子元素的指定选择器.——w3school 嗯,乍一看好像说的不是很明白,因此这个选择 ...
- 《C++之那些年踩过的坑(二)》
C++之那些年踩过的坑(二) 作者:刘俊延(Alinshans) 本系列文章针对我在写C++代码的过程中,尤其是做自己的项目时,踩过的各种坑.以此作为给自己的警惕. 今天讲一个小点,虽然小,但如果没有 ...
随机推荐
- Mybatis注解开发(一对一)
其他代码访问:Mybatis注解开发基础操作 1.添加OrderMapper接口 public interface OrderMapper { // @Select("select *,o. ...
- oracle执行sql查询语句出现错误ORA-00942:表或视图不存在
情况是这样,A库的用户名和表空间分别为SH , SH 把业务表SH所有数据从A库,导入到B库, 表空间为SH,用户名为SP 在B库里面执行sql查询语句出现错误ORA-00942:表或视图不存在 语句 ...
- Mysql集群搭建-实操
集群安装--准备工作 官网地址 https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-install-linux-binary.html 一.环境 ...
- HTML/CSS+JS制作一个高考倒计时页面
2020-07-09更新 修复倒计时归零后出现负数的bug 自动切换至下一年日期 ##效果展示 前言 在B站上找视频学习的,勉强搞出来了,写下此篇文章作为笔记,也希望有更多感兴趣的人能够有所收获. ( ...
- JavaScript学习④
* BOM 1. 事件 ## DOM简单学习:为了满足案例要求 * 功能:控制html文档的内容 * 获取页面标签(元素)对象:Element * document.getElementById(&q ...
- 2021.08.05 P1340 兽径管理(最小生成树)
2021.08.05 P1340 兽径管理(最小生成树) P1340 兽径管理 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 重点: 1.离线化. 题意: 有n个点,m条边,每次加 ...
- go语言编译过程概述
go语言编译过程概述 总结自<go语言设计与实现> 名词解释: 中间代码 中间代码是编译器或者虚拟机使用的语言,它可以来帮助我们分析计算机程序.在编译过程中,编译器会在将源代码转换到机器码 ...
- UnrealEngine创建自定义资产类型
导语 这篇文章记录了将UObject实例保存在Asset文件的方法,用这个方法可以将自定义的UObject数据序列化保存到文件,可以用于自定义UE资源类型. 创建UObject类 这一步比较简单,按照 ...
- 深入理解vue 修饰符sync【 vue sync修饰符示例】
在说vue 修饰符sync前,我们先看下官方文档:vue .sync 修饰符,里面说vue .sync 修饰符以前存在于vue1.0版本里,但是在在 2.0 中移除了 .sync .但是在 2.0 发 ...
- 【GPLT】 集合相似度(c++)
题目如下: 这题主要用来练习stl的使用,是一道比较简单的题目 AC代码如下 #include<iostream> #include<cmath> #include<ma ...