当前位置 : 主页 > 编程语言 > c++ >

简单权限管理之mapper层和dao层的构建

来源:互联网 收集:自由互联 发布时间:2021-07-03
mapper以及dao层 package org.jxnd.mapper;import java.util.List;import org.apache.ibatis.annotations.Param;import org.apache.ibatis.annotations.Select;import org.apache.ibatis.annotations.SelectProvider;import org.jxnd.bean.Systems;import
mapper以及dao层
package org.jxnd.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.jxnd.bean.Systems;
import org.jxnd.bean.UserInfo;

public interface UserInfoMapper {
	//根据用户名和密码查询用户信息
	@Select("select * from userinfo where name=#{name} and pwd=#{pwd}")
	UserInfo getUserByNameAndPwd(@Param("name")String name,@Param("pwd")String pwd);

	//查询角色所有权限
	@Select("select * from systems where id in(select sid from rolesystem where rid=#{rid}) order by oid desc")
	List
 
   getSystemsByRolesId(int rid);
}



package org.jxnd.dao.impl;

import java.util.List;

import org.jxnd.bean.Systems;
import org.jxnd.bean.UserInfo;
import org.jxnd.dao.UserInfoDao;
import org.jxnd.mapper.UserInfoMapper;
import org.jxnd.tools.DBTools;

public class UserInfoDaoImpl implements UserInfoDao{
	UserInfoMapper mapper=DBTools.getSqlSession().getMapper(UserInfoMapper.class);
	@Override
	public UserInfo getUserByNameAndPwd(String name, String pwd) {
		return mapper.getUserByNameAndPwd(name, pwd);
	}
	@Override
	public List
  
    getSystemsByRolesId(int rid) { return mapper.getSystemsByRolesId(rid); } }
  
 
网友评论