| | |
| | | |
| | | select fn_rec_array(10, 'dir'); |
| | | ----------------------------------------------------------------------------------------------------- g.索引 |
| | | -- 创建联合唯一索引 |
| | | alter table lf.sys_role_user add constraint idx_unique_role_user unique (roleid, userid); |
| | | -- 测试唯一约束 |
| | | insert into lf.sys_role_user (roleid,userid) values (1,1); |
| | | alter table lf.sys_role_user add constraint idx_unique_role_user unique (roleid, userid); -- 联合唯一索引 |
| | | insert into lf.sys_role_user (roleid,userid) values (1,1); -- 测试 |
| | | select * from lf.sys_role_user; |
| | | |
| | | alter table lf.sys_menu_auth add constraint idx_unique_menu_auth unique (menuid, authid); -- 联合唯一索引 |
| | | insert into lf.sys_menu_auth (menuid, authid) values (1,1); -- 测试 |
| | | select * from lf.sys_menu_auth; |
| | | |
| | | alter table lf.sys_role_res add constraint idx_unique_role_res unique (roleid,resid); -- 联合唯一索引 |
| | | insert into lf.sys_role_res (roleid,resid) values (1,1); |
| | | select * from lf.sys_role_res; |
| | | ----------------------------------------------------------------------------------------------------- |
| | | select a.*,fn_uname(a.create_user) createUserName,fn_uname(a.update_user) updateUserName from lf.sys_blacklist a order by a.id; |
| | | select * from lf.sys_user a where uname like '%' and a.depid=ANY(fn_rec_array(1,'dep')); |
| | |
| | | select * from lf.sys_menu_auth; |
| | | |
| | | select * from lf.sys_auth a left join lf.sys_menu; |
| | | select a.* from lf.sys_auth a where not exists (select b.id from lf.sys_menu_auth b where b.authid=a.id and b.menuid=1); |
| | | select a.* from lf.sys_auth a where not exists (select b.id from lf.sys_menu_auth b where b.authid = a.id and b.menuid = 1); |
| | | ------------------------------------------------------------ |
| | | select * from lf.sys_res; |
| | | select * from lf.sys_role; |
| | | select * from lf.sys_role_res; |
| | | |
| | | select a.* from lf.sys_res a where not exists (select b.id from lf.sys_role_res b where b.resid = a.id and b.roleid = 1); |
| | | ----------------------------------------------------------------------------------------------------- |
| | | |
| | | |
| | |
| | | comment on column lf.sys_res.update_time is '更新时间'; |
| | | comment on column lf.sys_res.bak is '备注'; |
| | | --insert into lf.sys_res (name) values ('天地图影像'); |
| | | --insert into lf.sys_res (name) values ('天地图矢量'); |
| | | |
| | | select * from lf.sys_res; |
| | | ----------------------------------------------------------------------------------------------------- 9.资源操作表 |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据角色分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "roleid", value = "角色ID", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectCountForRole") |
| | | public ResponseMsg<List<ResEntity>> selectCountForRole(Integer roleid, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = resService.selectCountForRole(roleid); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<ResEntity> rs = resService.selectByPageForRole(roleid, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "com.lf.server.entity.sys.ResEntity", paramType = "body", example = "") |
| | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 表名 |
| | | * @param name 表名 |
| | | * @param limit 记录表 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<ResEntity> selectByPage(String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 根据角色查询记录数 |
| | | * |
| | | * @param roleid |
| | | * @return |
| | | */ |
| | | public Integer selectCountForRole(Integer roleid); |
| | | |
| | | /** |
| | | * 根据角色分页查询 |
| | | * |
| | | * @param roleid |
| | | * @param limit |
| | | * @param offset |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectByPageForRole(Integer roleid, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 插入一条 |
| | | * |
| | | * @param resEntity |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 插入多条 |
| | | * |
| | | * @param resEntity |
| | | * @return |
| | | */ |
| | | public Integer insertRess(List<ResEntity> resEntity); |
| | | |
| | | /** |
| | | * 删除一条 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除多条 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 更新一条 |
| | | * |
| | | * @param resEntity |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询单条数据 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<ResEntity> selectResAll(); |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectCountForRole(Integer roleid) { |
| | | return resMapper.selectCountForRole(roleid); |
| | | } |
| | | |
| | | @Override |
| | | public List<ResEntity> selectByPageForRole(Integer roleid, Integer limit, Integer offset) { |
| | | return resMapper.selectByPageForRole(roleid, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | | public Integer insertRes(ResEntity resEntity) { |
| | | return resMapper.insertRes(resEntity); |
| | | } |
| | |
| | | select * from lf.sys_auth where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertAuth" parameterType="com.lf.server.entity.sys.AuthEntity"> |
| | | <insert id="insertAuth" parameterType="com.lf.server.entity.sys.AuthEntity"> |
| | | insert into lf.sys_auth |
| | | (name,tag,create_user,create_time,bak) |
| | | values |
| | | (#{name},#{tag},#{createUser},now(),#{bak}); |
| | | </insert> |
| | | |
| | | <insert id="insertAuths" > |
| | | <insert id="insertAuths"> |
| | | insert into lf.sys_auth |
| | | (name,tag,create_user,create_time,bak) |
| | | values |
| | |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <delete id="deleteAuth" > |
| | | <delete id="deleteAuth"> |
| | | delete from lf.sys_auth where id = #{id} |
| | | </delete> |
| | | |
| | | <delete id="deleteAuths" > |
| | | delete from lf.sys_auth where id in |
| | | <foreach item="ids" collection="list" index="index" open="(" |
| | | separator="," close=")"> |
| | | <foreach item="ids" collection="list" index="index" open="(" separator="," close=")"> |
| | | #{ids} |
| | | </foreach> |
| | | </delete> |
| | |
| | | <?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.lf.server.mapper.sys.ResMapper"> |
| | | <!-- 统计行数 --> |
| | | <select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.String"> |
| | | select count(*) from lf.sys_res |
| | | <where> |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <!-- 分页查询 --> |
| | | |
| | | <select id="selectByPage" resultType="com.lf.server.entity.sys.ResEntity"> |
| | | select a.*,b.name as depName,c.name as dirName from lf.sys_res a |
| | | inner join lf.sys_dep b on a.depid = b.id |
| | |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectCountForRole" resultType="java.lang.Integer" parameterType="java.lang.String"> |
| | | select count(a.*) from lf.sys_res a where not exists (select b.id from lf.sys_role_res b |
| | | <where> |
| | | b.resid = a.id |
| | | <if test="roleid != null"> |
| | | and b.roleid = #{roleid} |
| | | </if> |
| | | </where> |
| | | ) |
| | | </select> |
| | | |
| | | <select id="selectByPageForRole" resultType="com.lf.server.entity.sys.ResEntity"> |
| | | select a.* from lf.sys_res a where not exists (select b.id from lf.sys_role_res b |
| | | <where> |
| | | b.resid = a.id |
| | | <if test="roleid != null"> |
| | | and b.roleid = #{roleid} |
| | | </if> |
| | | </where> |
| | | ) |
| | | order by a.id |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectResAll" resultType="com.lf.server.entity.sys.ResEntity"> |
| | | select * from lf.sys_res order by id; |
| | |
| | | select * from lf.sys_res where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertRes" parameterType="com.lf.server.entity.data.DictEntity"> |
| | | <insert id="insertRes" parameterType="com.lf.server.entity.data.DictEntity"> |
| | | insert into lf.sys_res |
| | | (name,server,source,depid,dirid,code,descr,img,create_user,create_time,bak) |
| | | values |
| | | (#{name},#{server},#{source},#{depid},#{dirid},#{code},#{descr},#{img},#{createUser},now(),#{bak}); |
| | | </insert> |
| | | |
| | | <insert id="insertRess" > |
| | | <insert id="insertRess"> |
| | | insert into lf.sys_res |
| | | (name,server,source,depid,dirid,code,descr,img,create_user,create_time,bak) |
| | | values |
| | | <foreach collection="list" item="item" index="index" separator="," > |
| | | <foreach collection="list" item="item" index="index" separator=","> |
| | | #{item.name},#{item.server},#{item.source},#{item.depid},#{item.dirid},#{item.code},#{item.descr},#{item.img},#{item.createUser},now(),#{item.bak}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <delete id="deleteRes" > |
| | | <delete id="deleteRes"> |
| | | delete from lf.sys_res where id = #{id} |
| | | </delete> |
| | | |
| | | <delete id="deleteRess" > |
| | | <delete id="deleteRess"> |
| | | delete from lf.sys_res where id in |
| | | <foreach item="ids" collection="list" index="index" open="(" |
| | | separator="," close=")"> |
| | | <foreach item="ids" collection="list" index="index" open="(" separator="," close=")"> |
| | | #{ids} |
| | | </foreach> |
| | | </delete> |