小优化
This commit is contained in:
-42
@@ -1,42 +0,0 @@
|
|||||||
package com.central.user.mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Delete;
|
|
||||||
import org.apache.ibatis.annotations.Insert;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Options;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.apache.ibatis.annotations.Update;
|
|
||||||
|
|
||||||
import com.central.common.model.SysPermission;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zlt
|
|
||||||
* 权限
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SysPermissionMapper {
|
|
||||||
|
|
||||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
|
||||||
@Insert("insert into sys_permission(permission, name, createTime, updateTime) values(#{permission}, #{name}, #{createTime}, #{createTime})")
|
|
||||||
int save(SysPermission sysPermission);
|
|
||||||
|
|
||||||
@Update("update sys_permission t set t.name = #{name}, t.permission = #{permission}, t.updateTime = #{updateTime} where t.id = #{id}")
|
|
||||||
int update(SysPermission sysPermission);
|
|
||||||
|
|
||||||
@Delete("delete from sys_permission where id = #{id}")
|
|
||||||
int delete(Long id);
|
|
||||||
|
|
||||||
@Select("select * from sys_permission t where t.id = #{id}")
|
|
||||||
SysPermission findById(Long id);
|
|
||||||
|
|
||||||
@Select("select * from sys_permission t where t.permission = #{permission}")
|
|
||||||
SysPermission findByPermission(String permission);
|
|
||||||
|
|
||||||
int count(Map<String, Object> params);
|
|
||||||
|
|
||||||
List<SysPermission> findList(Map<String, Object> params);
|
|
||||||
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
package com.central.user.mapper;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Insert;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import com.central.common.model.SysPermission;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zlt
|
|
||||||
* 角色权限关系
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SysRolePermissionMapper {
|
|
||||||
|
|
||||||
@Insert("insert into sys_role_permission(roleId, permissionId) values(#{roleId}, #{permissionId})")
|
|
||||||
int saveRolePermission(@Param("roleId") Long roleId, @Param("permissionId") Long permissionId);
|
|
||||||
|
|
||||||
int deleteRolePermission(@Param("roleId") Long roleId, @Param("permissionId") Long permissionId);
|
|
||||||
|
|
||||||
Set<SysPermission> findPermissionsByRoleIds(@Param("roleIds") Set<Long> roleIds);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?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.central.user.mapper.SysPermissionMapper">
|
|
||||||
|
|
||||||
<sql id="where">
|
|
||||||
<where>
|
|
||||||
<if test="permission != null and permission != ''">
|
|
||||||
and t.permission like concat('%', #{permission}, '%')
|
|
||||||
</if>
|
|
||||||
<if test="name != null and name != ''">
|
|
||||||
and t.name like concat('%', #{name}, '%')
|
|
||||||
</if>
|
|
||||||
<if test="searchKey != null and searchKey != ''">
|
|
||||||
and t.name like concat('%', #{searchKey}, '%')
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</sql>
|
|
||||||
<select id="count" resultType="int">
|
|
||||||
select count(*) from sys_permission t
|
|
||||||
<include refid="where" />
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="findList" resultType="com.central.common.model.SysPermission">
|
|
||||||
select * from sys_permission t
|
|
||||||
<include refid="where" />
|
|
||||||
order by t.id desc
|
|
||||||
<!--<if test="start != null and start >= 0 and length != null and length > 0">-->
|
|
||||||
<!--limit #{start}, #{length}-->
|
|
||||||
<!--</if>-->
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?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.central.user.mapper.SysRolePermissionMapper">
|
|
||||||
|
|
||||||
<delete id="deleteRolePermission">
|
|
||||||
delete from sys_role_permission
|
|
||||||
<where>
|
|
||||||
<if test="roleId != null">
|
|
||||||
and roleId = #{roleId}
|
|
||||||
</if>
|
|
||||||
<if test="permissionId != null">
|
|
||||||
and permissionId = #{permissionId}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<select id="findPermissionsByRoleIds" resultType="com.central.common.model.SysPermission">
|
|
||||||
select p.* from
|
|
||||||
sys_permission p
|
|
||||||
inner join sys_role_permission rp on
|
|
||||||
p.id = rp.permissionId
|
|
||||||
<where>
|
|
||||||
rp.roleId in
|
|
||||||
<foreach collection="roleIds" item="roleId" open="("
|
|
||||||
separator="," close=")">
|
|
||||||
#{roleId}
|
|
||||||
</foreach>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
+4
@@ -26,6 +26,10 @@ public class Result<T> implements Serializable {
|
|||||||
return succeedWith(model, CodeEnum.SUCCESS.getCode(), msg);
|
return succeedWith(model, CodeEnum.SUCCESS.getCode(), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> Result<T> succeed(T model) {
|
||||||
|
return succeedWith(model, CodeEnum.SUCCESS.getCode(), "");
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> Result<T> succeedWith(T datas, Integer code, String msg) {
|
public static <T> Result<T> succeedWith(T datas, Integer code, String msg) {
|
||||||
return new Result<>(datas, code, msg);
|
return new Result<>(datas, code, msg);
|
||||||
}
|
}
|
||||||
|
|||||||
-29
@@ -1,29 +0,0 @@
|
|||||||
package com.central.common.model;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zlt
|
|
||||||
* 权限标识
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class SysPermission implements Serializable {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1389727646460449239L;
|
|
||||||
private Long id;
|
|
||||||
private String permission;
|
|
||||||
private String name;
|
|
||||||
private Date createTime;
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
private Long roleId;
|
|
||||||
private Set<Long> authIds;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import com.central.oauth.service.ZltUserDetailsService;
|
|||||||
import org.springframework.security.authentication.DisabledException;
|
import org.springframework.security.authentication.DisabledException;
|
||||||
import org.springframework.security.authentication.InternalAuthenticationServiceException;
|
import org.springframework.security.authentication.InternalAuthenticationServiceException;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
||||||
import org.springframework.social.security.SocialUserDetails;
|
import org.springframework.social.security.SocialUserDetails;
|
||||||
import org.springframework.social.security.SocialUserDetailsService;
|
import org.springframework.social.security.SocialUserDetailsService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
Reference in New Issue
Block a user