• 大小: 4.04MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-07
  • 语言: 其他
  • 标签: ssm  shiro  easyui  

资源简介

ssm+shiro+easyui权限管理系统

资源截图

代码片段和文件信息

package com.wangzhixuan.commons.base;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.baomidou.mybatisplus.plugins.Page;
import com.wangzhixuan.commons.result.PageInfo;
import com.wangzhixuan.commons.result.Result;
import com.wangzhixuan.commons.shiro.ShiroUser;
import com.wangzhixuan.commons.utils.Charsets;
import com.wangzhixuan.commons.utils.StringEscapeEditor;
import com.wangzhixuan.commons.utils.URLUtils;

/**
 * @description:基础 controller
 * @author:zhixuan.wang
 * @date:2015/10/1 14:51
 */
public abstract class baseController {
    // 控制器本来就是单例,这样似乎更加合理
    protected Logger logger = LogManager.getLogger(getClass());

    @InitBinder
    public void initBinder(ServletRequestDataBinder binder) {
        /**
         * 自动转换日期类型的字段格式
         */
        binder.registerCustomEditor(Date.class new CustomDateEditor(new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss“) true));
        /**
         * 防止XSS攻击
         */
        binder.registerCustomEditor(String.class new StringEscapeEditor());
    }

    /**
     * 获取当前登录用户对象
     * @return {ShiroUser}
     */
    public ShiroUser getShiroUser() {
        return (ShiroUser) SecurityUtils.getSubject().getPrincipal();
    }

    /**
     * 获取当前登录用户id
     * @return {Long}
     */
    public Long getUserId() {
        return this.getShiroUser().getId();
    }

    /**
     * 获取当前登录用户名
     * @return {String}
     */
    public String getStaffName() {
        return this.getShiroUser().getName();
    }

    /**
     * ajax失败
     * @param msg 失败的消息
     * @return {object}
     */
    public object renderError(String msg) {
        Result result = new Result();
        result.setMsg(msg);
        return result;
    }
    
    /**
     * ajax成功
     * @return {object}
     */
    public object renderSuccess() {
        Result result = new Result();
        result.setSuccess(true);
        return result;
    }
    
    /**
     * ajax成功
     * @param msg 消息
     * @return {object}
     */
    public object renderSuccess(String msg) {
        Result result = new Result();
        result.setSuccess(true);
        result.setMsg(msg);
        return result;
    }

    /**
     * ajax成功
     * @param obj 成功

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-06-29 15:13  spring-shiro-training\
     文件        1509  2017-07-03 14:43  spring-shiro-training\.classpath
     文件         306  2017-06-28 18:40  spring-shiro-training\.gitignore
     文件        1230  2017-07-03 14:43  spring-shiro-training\.project
     目录           0  2017-06-29 15:13  spring-shiro-training\.settings\
     文件         639  2017-06-29 15:13  spring-shiro-training\.settings\.jsdtscope
     文件         190  2017-06-29 15:13  spring-shiro-training\.settings\org.eclipse.core.resources.prefs
     文件         430  2017-06-29 15:13  spring-shiro-training\.settings\org.eclipse.jdt.core.prefs
     文件          90  2017-06-29 15:12  spring-shiro-training\.settings\org.eclipse.m2e.core.prefs
     文件         776  2017-06-29 15:13  spring-shiro-training\.settings\org.eclipse.wst.common.component
     文件         252  2017-06-29 15:13  spring-shiro-training\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2017-06-29 15:13  spring-shiro-training\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2017-06-29 15:13  spring-shiro-training\.settings\org.eclipse.wst.jsdt.ui.superType.name
     文件          50  2017-06-29 15:13  spring-shiro-training\.settings\org.eclipse.wst.validation.prefs
     文件         685  2017-06-28 18:40  spring-shiro-training\build.sh
     目录           0  2017-06-29 15:10  spring-shiro-training\database\
     文件       17639  2017-06-28 18:40  spring-shiro-training\database\shiro_mysql.sql
     文件       14186  2017-06-28 18:40  spring-shiro-training\database\shiro_oracle.sql
     文件         786  2017-06-28 18:40  spring-shiro-training\database\update_20161011.sql
     文件         432  2017-06-28 18:40  spring-shiro-training\database\update_20161225.sql
     文件          89  2017-06-28 18:40  spring-shiro-training\database\update_20170210.sql
     文件          99  2017-06-28 18:40  spring-shiro-training\database\update_20170320.sql
     文件         102  2017-06-28 18:40  spring-shiro-training\database\说明.txt
     文件       10551  2017-06-28 18:40  spring-shiro-training\pom.xml
     文件        2747  2017-06-30 16:26  spring-shiro-training\README.md
     目录           0  2017-06-29 15:10  spring-shiro-training\src\
     目录           0  2017-06-29 15:10  spring-shiro-training\src\main\
     目录           0  2017-06-29 15:10  spring-shiro-training\src\main\conf\
     目录           0  2017-06-29 15:10  spring-shiro-training\src\main\conf\dev\
     目录           0  2017-06-29 15:10  spring-shiro-training\src\main\conf\dev\config\
     文件        1105  2017-06-29 15:13  spring-shiro-training\src\main\conf\dev\config\application.properties
............此处省略1187个文件信息

评论

共有 条评论