13693261870
2 天以前 bbbc39611d232e013b900ba5e6a5a483a062e2f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.terra.common.mapper;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.terra.common.entity.lf.OperatePo;
import com.terra.common.entity.lf.TokenPo;
import com.terra.common.entity.lf.UserPo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
 
import java.util.List;
import java.util.Map;
 
@Mapper
@Repository
public interface CommonMapper extends BaseMapper<OperatePo> {
    @Insert("INSERT INTO lf.sys_operate(url, ip, exec, clazz, type, userid, bak, modular1, modular2) VALUES (#{url}, #{ip}, #{exec}, #{clazz}, #{type}, #{userid}, #{bak}, #{modular1}, #{modular2})")
    int insertOperate(Map<String, Object> map);
 
    @Select("select * from lf.sys_user where id = (select create_user from lf.sys_token where token=#{token} and expire > now() limit 1)")
    UserPo selectByToken(String token);
 
    @Select("select a.* from lf.sys_token a where token = #{token} and expire > now() limit 1")
    TokenPo selectOneByToken(String token);
 
    @Select("select ip from lf.sys_blacklist where type = #{type}")
    List<String> selectIpList(Integer type);
 
    @Select("SELECT DISTINCT e.perms || f.tag AS perms " +
            "FROM lf.sys_user a " +
            "INNER JOIN lf.sys_role_user b ON a.id = b.userid " +
            "INNER JOIN lf.sys_role_menu_auth c ON b.roleid = c.roleid " +
            "INNER JOIN lf.sys_menu_auth d ON c.menu_auth_id = d.id " +
            "INNER JOIN lf.sys_menu e ON d.menuid = e.id " +
            "INNER JOIN lf.sys_auth f ON d.authid = f.id " +
            "WHERE e.perms IS NOT NULL " +
            "AND (#{uid} IS NULL OR a.uid = #{uid}) " +
            "ORDER BY perms")
    List<String> selectPerms(String type);
}