Commit 05beecd0 authored by Huang's avatar Huang
Browse files

no commit message

parent bc5dd330
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import org.hibernate.validator.constraints.Length;
import com.jeespring.common.persistence.AbstractBaseEntity;
/**
* 字典Entity
* @author 黄炳桂 516821420@qq.com
* @version 2013-05-15
*/
public class Dict extends AbstractBaseEntity<Dict> {
private static final long serialVersionUID = 1L;
private String value; // 数据值
private String label; // 标签名
private String type; // 类型
private String description;// 描述
private Integer sort; // 排序
private String parentId;//父Id
private String picture;//图片
public Dict() {
super();
}
public Dict(String id){
super(id);
}
public Dict(String value, String label){
this.value = value;
this.label = label;
}
@XmlAttribute
@Length(min=1, max=100)
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@XmlAttribute
@Length(min=1, max=100)
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Length(min=1, max=100)
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@XmlAttribute
@Length(min=0, max=100)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@NotNull
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
@Length(min=1, max=100)
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
@Override
public String toString() {
return label;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import java.util.Date;
import java.util.Map;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.persistence.AbstractBaseEntity;
/**
* 日志Entity
* @author 黄炳桂 516821420@qq.com
* @version 2014-8-19
*/
public class Log extends AbstractBaseEntity<Log> {
private static final long serialVersionUID = 1L;
private String type; // 日志类型(1:接入日志;2:错误日志)
private String title; // 日志标题
private String remoteAddr; // 操作用户的IP地址
private String requestUri; // 操作的URI
private String method; // 操作的方式
private String params; // 操作提交的数据
private String userAgent; // 操作用户代理信息
private String exception; // 异常信息
private Date beginDate; // 开始日期
private Date endDate; // 结束日期
// 日志类型(1:接入日志;2:错误日志)
public static final String TYPE_ACCESS = "1";
public static final String TYPE_EXCEPTION = "2";
public Log(){
super();
}
public Log(String id){
super(id);
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getRemoteAddr() {
return remoteAddr;
}
public void setRemoteAddr(String remoteAddr) {
this.remoteAddr = remoteAddr;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public String getRequestUri() {
return requestUri;
}
public void setRequestUri(String requestUri) {
this.requestUri = requestUri;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public String getException() {
return exception;
}
public void setException(String exception) {
this.exception = exception;
}
public Date getBeginDate() {
return beginDate;
}
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
/**
* 设置请求参数
* @param paramMap
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setParams(Map paramMap){
if (paramMap == null){
return;
}
StringBuilder params = new StringBuilder();
for (Map.Entry<String, String[]> param : ((Map<String, String[]>)paramMap).entrySet()){
params.append(("".equals(params.toString()) ? "" : "&") + param.getKey() + "=");
String paramValue = (param.getValue() != null && param.getValue().length > 0 ? param.getValue()[0] : "");
params.append(StringUtils.abbr(StringUtils.endsWithIgnoreCase(param.getKey(), "password") ? "" : paramValue, 100));
}
this.params = params.toString();
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.modules.sys.utils.UserUtils;
/**
* 菜单Entity
* @author 黄炳桂 516821420@qq.com
* @version 2013-05-15
*/
public class Menu extends AbstractBaseEntity<Menu> {
private static final long serialVersionUID = 1L;
private Menu parent; // 父级菜单
private String parentIds; // 所有父级编号
private List<Menu> children; // 父级菜单
private String name; // 名称
private String href; // 链接
private String target; // 目标( mainFrame、_blank、_self、_parent、_top)
private String icon; // 图标
private Integer sort; // 排序
private String isShow; // 是否在菜单中显示(1:显示;0:不显示)
private String permission; // 权限标识
private String userId;
public Menu(){
super();
this.sort = 30;
this.isShow = "1";
}
public Menu(String id){
super(id);
}
@JsonBackReference
@NotNull
public Menu getParent() {
return parent;
}
public void setParent(Menu parent) {
this.parent = parent;
}
@Length(min=1, max=2000)
public String getParentIds() {
if(parentIds==null) {
parentIds = "0,";
}
return parentIds;
}
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
@Length(min=1, max=100)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Length(min=0, max=2000)
public String getHref() {
return href;
}
public void setHref(String href) {
this.href = href;
}
@Length(min=0, max=20)
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
@Length(min=0, max=100)
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
@NotNull
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
@Length(min=1, max=1)
public String getIsShow() {
return isShow;
}
public void setIsShow(String isShow) {
this.isShow = isShow;
}
@Length(min=0, max=200)
public String getPermission() {
return permission;
}
public void setPermission(String permission) {
this.permission = permission;
}
public String getParentId() {
return parent != null && parent.getId() != null ? parent.getId() : "0";
}
@JsonIgnore
public boolean hasChildren(){
if(children == null || children.size() == 0){
return false;
}
if(children.toString().contains("查看")) {
return false;
}
for(Menu child:children){
if("1".equals(child.getIsShow())){
return true;
}
}
return false;
}
@JsonIgnore
public boolean hasPermisson(){
List<Menu> menuList = UserUtils.getMenuList();
for(Menu menu:menuList){
if(menu.getId().equals(this.getId())) {
return true;
}
}
return false;
}
@JsonIgnore
public static void sortList(List<Menu> list, List<Menu> sourcelist, String parentId, boolean cascade){
for (int i=0; i<sourcelist.size(); i++){
Menu e = sourcelist.get(i);
if (e.getParent()!=null && e.getParent().getId()!=null
&& e.getParent().getId().equals(parentId)){
list.add(e);
if (cascade){
// 判断是否还有子节点, 有则继续获取子节点
for (int j=0; j<sourcelist.size(); j++){
Menu child = sourcelist.get(j);
if (child.getParent()!=null && child.getParent().getId()!=null
&& child.getParent().getId().equals(e.getId())){
sortList(list, sourcelist, e.getId(), true);
break;
}
}
}
}
}
}
@JsonIgnore
public static String getRootId(){
return "1";
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
@Override
public String toString() {
return name;
}
public void setChildren(List<Menu> children) {
this.children = children;
}
public List<Menu> getChildren() {
return children;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import com.jeespring.common.persistence.TreeEntity;
/**
* 机构Entity
* @author 黄炳桂 516821420@qq.com
* @version 2013-05-15
*/
public class Office extends TreeEntity<Office> {
private static final long serialVersionUID = 1L;
// private Office parent; // 父级编号
// private String parentIds; // 所有父级编号
private Area area; // 归属区域
private String code; // 机构编码
// private String name; // 机构名称
// private Integer sort; // 排序
private String type; // 机构类型(1:公司;2:部门;3:小组)
private String grade; // 机构等级(1:一级;2:二级;3:三级;4:四级)
private String address; // 联系地址
private String zipCode; // 邮政编码
private String master; // 负责人
private String phone; // 电话
private String fax; // 传真
private String email; // 邮箱
private String useable;//是否可用
private User primaryPerson;//主负责人
private User deputyPerson;//副负责人
private List<String> childDeptList;//快速添加子部门
public Office(){
super();
// this.sort = 30;
this.type = "2";
}
public Office(String id){
super(id);
}
public List<String> getChildDeptList() {
return childDeptList;
}
public void setChildDeptList(List<String> childDeptList) {
this.childDeptList = childDeptList;
}
public String getUseable() {
return useable;
}
public void setUseable(String useable) {
this.useable = useable;
}
public User getPrimaryPerson() {
return primaryPerson;
}
public void setPrimaryPerson(User primaryPerson) {
this.primaryPerson = primaryPerson;
}
public User getDeputyPerson() {
return deputyPerson;
}
public void setDeputyPerson(User deputyPerson) {
this.deputyPerson = deputyPerson;
}
// @JsonBackReference
// @NotNull
@Override
public Office getParent() {
return parent;
}
@Override
public void setParent(Office parent) {
this.parent = parent;
}
//
// @Length(min=1, max=2000)
// public String getParentIds() {
// return parentIds;
// }
//
// public void setParentIds(String parentIds) {
// this.parentIds = parentIds;
// }
@NotNull
public Area getArea() {
return area;
}
public void setArea(Area area) {
this.area = area;
}
//
// @Length(min=1, max=100)
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Integer getSort() {
// return sort;
// }
//
// public void setSort(Integer sort) {
// this.sort = sort;
// }
@Length(min=1, max=1)
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Length(min=1, max=1)
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
@Length(min=0, max=255)
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Length(min=0, max=100)
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
@Length(min=0, max=100)
public String getMaster() {
return master;
}
public void setMaster(String master) {
this.master = master;
}
@Length(min=0, max=200)
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Length(min=0, max=200)
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
@Length(min=0, max=200)
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Length(min=0, max=100)
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
// public String getParentId() {
// return parent != null && parent.getId() != null ? parent.getId() : "0";
// }
@Override
public String toString() {
return name;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;
import com.google.common.collect.Lists;
import com.jeespring.common.config.Global;
import com.jeespring.common.persistence.AbstractBaseEntity;
/**
* 角色Entity
* @author 黄炳桂 516821420@qq.com
* @version 2013-12-05
*/
public class Role extends AbstractBaseEntity<Role> {
private static final long serialVersionUID = 1L;
private Office office; // 归属机构
private String name; // 角色名称
private String enname; // 英文名称
private String roleType;// 权限类型
private String dataScope;// 数据范围
private String oldName; // 原角色名称
private String oldEnname; // 原英文名称
private String sysData; //是否是系统数据
private String useable; //是否是可用
private User user; // 根据用户ID查询角色列表
// private List<User> userList = Lists.newArrayList(); // 拥有用户列表
private List<Menu> menuList = Lists.newArrayList(); // 拥有菜单列表
private List<Office> officeList = Lists.newArrayList(); // 按明细设置数据范围
// 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;4:所在部门及以下数据;5:所在部门数据;8:仅本人数据;9:按明细设置)
public static final String DATA_SCOPE_ALL = "1";
public static final String DATA_SCOPE_COMPANY_AND_CHILD = "2";
public static final String DATA_SCOPE_COMPANY = "3";
public static final String DATA_SCOPE_OFFICE_AND_CHILD = "4";
public static final String DATA_SCOPE_OFFICE = "5";
public static final String DATA_SCOPE_SELF = "8";
public static final String DATA_SCOPE_CUSTOM = "9";
public Role() {
super();
this.dataScope = DATA_SCOPE_SELF;
this.useable=Global.YES;
}
public Role(String id){
super(id);
}
public Role(User user) {
this();
this.user = user;
}
public String getUseable() {
return useable;
}
public void setUseable(String useable) {
this.useable = useable;
}
public String getSysData() {
return sysData;
}
public void setSysData(String sysData) {
this.sysData = sysData;
}
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
@Length(min=1, max=100)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Length(min=1, max=100)
public String getEnname() {
return enname;
}
public void setEnname(String enname) {
this.enname = enname;
}
@Length(min=1, max=100)
public String getRoleType() {
return roleType;
}
public void setRoleType(String roleType) {
this.roleType = roleType;
}
public String getDataScope() {
return dataScope;
}
public void setDataScope(String dataScope) {
this.dataScope = dataScope;
}
public String getOldName() {
return oldName;
}
public void setOldName(String oldName) {
this.oldName = oldName;
}
public String getOldEnname() {
return oldEnname;
}
public void setOldEnname(String oldEnname) {
this.oldEnname = oldEnname;
}
// public List<User> getUserList() {
// return userList;
// }
//
// public void setUserList(List<User> userList) {
// this.userList = userList;
// }
//
// public List<String> getUserIdList() {
// List<String> nameIdList = Lists.newArrayList();
// for (User user : userList) {
// nameIdList.add(user.getId());
// }
// return nameIdList;
// }
//
// public String getUserIds() {
// return StringUtils.join(getUserIdList(), ",");
// }
public List<Menu> getMenuList() {
return menuList;
}
public void setMenuList(List<Menu> menuList) {
this.menuList = menuList;
}
public List<String> getMenuIdList() {
List<String> menuIdList = Lists.newArrayList();
for (Menu menu : menuList) {
menuIdList.add(menu.getId());
}
return menuIdList;
}
public void setMenuIdList(List<String> menuIdList) {
menuList = Lists.newArrayList();
for (String menuId : menuIdList) {
Menu menu = new Menu();
menu.setId(menuId);
menuList.add(menu);
}
}
public String getMenuIds() {
return StringUtils.join(getMenuIdList(), ",");
}
public void setMenuIds(String menuIds) {
menuList = Lists.newArrayList();
if (menuIds != null){
String[] ids = StringUtils.split(menuIds, ",");
setMenuIdList(Lists.newArrayList(ids));
}
}
public List<Office> getOfficeList() {
return officeList;
}
public void setOfficeList(List<Office> officeList) {
this.officeList = officeList;
}
public List<String> getOfficeIdList() {
List<String> officeIdList = Lists.newArrayList();
for (Office office : officeList) {
officeIdList.add(office.getId());
}
return officeIdList;
}
public void setOfficeIdList(List<String> officeIdList) {
officeList = Lists.newArrayList();
for (String officeId : officeIdList) {
Office office = new Office();
office.setId(officeId);
officeList.add(office);
}
}
public String getOfficeIds() {
return StringUtils.join(getOfficeIdList(), ",");
}
public void setOfficeIds(String officeIds) {
officeList = Lists.newArrayList();
if (officeIds != null){
String[] ids = StringUtils.split(officeIds, ",");
setOfficeIdList(Lists.newArrayList(ids));
}
}
/**
* 获取权限字符串列表
*/
public List<String> getPermissions() {
List<String> permissions = Lists.newArrayList();
for (Menu menu : menuList) {
if (menu.getPermission()!=null && !"".equals(menu.getPermission())){
permissions.add(menu.getPermission());
}
}
return permissions;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
// public boolean isAdmin(){
// return isAdmin(this.id);
// }
//
// public static boolean isAdmin(String id){
// return id != null && "1".equals(id);
// }
// @Transient
// public String getMenuNames() {
// List<String> menuNameList = Lists.newArrayList();
// for (Menu menu : menuList) {
// menuNameList.add(menu.getName());
// }
// return StringUtils.join(menuNameList, ",");
// }
}
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.common.utils.excel.annotation.ExcelField;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
/**
* 系统配置Entity
* @author 黄炳桂 516821420@qq.com
* @version 2017-11-17
*/
public class SysConfig extends AbstractBaseEntity<SysConfig> {
private static final long serialVersionUID = 1L;
private String type; // 类型
private String value; // 数据值
private String label; // 标签名
private String description; // 描述
private Long sort; // 排序(升序)
private String picture; //图片
public SysConfig() {
super();
}
public SysConfig(String id){
super(id);
}
@Length(min=1, max=100, message="类型长度必须介于 1 和 100 之间")
@ExcelField(title="类型", align=2, sort=1)
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Length(min=1, max=100, message="数据值长度必须介于 1 和 100 之间")
@ExcelField(title="数据值", align=2, sort=2)
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Length(min=1, max=100, message="标签名长度必须介于 1 和 100 之间")
@ExcelField(title="标签名", align=2, sort=3)
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Length(min=1, max=4000, message="描述长度必须介于 1 和 2000 之间")
@ExcelField(title="描述", align=2, sort=4)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@NotNull(message="排序(升序)不能为空")
@ExcelField(title="排序(升序)", align=2, sort=5)
public Long getSort() {
return sort;
}
public String getPicture() {return picture;}
public void setPicture(String picture) {this.picture = picture;}
public void setSort(Long sort) {
this.sort = sort;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonBackReference;
import java.util.Date;
import com.jeespring.common.persistence.TreeEntity;
/**
* 系统配置Entity
* @author JeeSpring
* @version 2018-08-22
*/
public class SysConfigTree extends TreeEntity<SysConfigTree> {
private static final long serialVersionUID = 1L;
private String type; // 类型
private String value; // 数据值
private String label; // 标签名
private String description; // 描述
//private Long sort; // 排序(升序)
private SysConfigTree parent; // 父级编号
private String parentIds; // 所有父级编号
private String picture; // 图片
private Date beginCreateDate; // 开始 创建时间
private Date endCreateDate; // 结束 创建时间
private Date beginUpdateDate; // 开始 更新时间
private Date endUpdateDate; // 结束 更新时间
public SysConfigTree() {
super();
}
public SysConfigTree(String id){
super(id);
}
@Length(min=1, max=100, message="类型长度必须介于 1 和 100 之间")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Length(min=1, max=100, message="数据值长度必须介于 1 和 100 之间")
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Length(min=1, max=100, message="标签名长度必须介于 1 和 100 之间")
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Length(min=1, max=4000, message="描述长度必须介于 1 和 4000 之间")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
//@JsonBackReference
@Override
public SysConfigTree getParent() {
return parent;
}
@Override
public void setParent(SysConfigTree parent) {
this.parent = parent;
}
@Override
@Length(min=0, max=2000, message="所有父级编号长度必须介于 0 和 2000 之间")
public String getParentIds() {
return parentIds;
}
@Override
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
@Length(min=0, max=255, message="图片长度必须介于 0 和 255 之间")
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public Date getBeginCreateDate() {
return beginCreateDate;
}
public void setBeginCreateDate(Date beginCreateDate) {
this.beginCreateDate = beginCreateDate;
}
public Date getEndCreateDate() {
return endCreateDate;
}
public void setEndCreateDate(Date endCreateDate) {
this.endCreateDate = endCreateDate;
}
public Date getBeginUpdateDate() {
return beginUpdateDate;
}
public void setBeginUpdateDate(Date beginUpdateDate) {
this.beginUpdateDate = beginUpdateDate;
}
public Date getEndUpdateDate() {
return endUpdateDate;
}
public void setEndUpdateDate(Date endUpdateDate) {
this.endUpdateDate = endUpdateDate;
}
@Override
public String getParentId() {
return parent != null && parent.getId() != null ? parent.getId() : "0";
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonBackReference;
import java.util.Date;
import com.jeespring.common.persistence.TreeEntity;
/**
* 数据字典Entity
* @author JeeSpring
* @version 2018-08-22
*/
public class SysDictTree extends TreeEntity<SysDictTree> {
private static final long serialVersionUID = 1L;
private String value; // 数据值
private String label; // 标签名
private String type; // 类型
private String description; // 描述
//private Long sort; // 排序(升序)
private SysDictTree parent; // 父级编号
private String parentIds; // 所有父级编号
private String picture; // 图片
private Date beginCreateDate; // 开始 创建时间
private Date endCreateDate; // 结束 创建时间
private Date beginUpdateDate; // 开始 更新时间
private Date endUpdateDate; // 结束 更新时间
public SysDictTree() {
super();
}
public SysDictTree(String id){
super(id);
}
@Length(min=1, max=100, message="数据值长度必须介于 1 和 100 之间")
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Length(min=1, max=100, message="标签名长度必须介于 1 和 100 之间")
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Length(min=1, max=100, message="类型长度必须介于 1 和 100 之间")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Length(min=1, max=100, message="描述长度必须介于 1 和 100 之间")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
//@NotNull(message="排序(升序)不能为空")
//public Long getSort() {
//return sort;
//}
//public void setSort(Long sort) {
//this.sort = sort;
//}
@Override
@JsonBackReference
public SysDictTree getParent() {
return parent;
}
@Override
public void setParent(SysDictTree parent) {
this.parent = parent;
}
@Override
@Length(min=0, max=2000, message="所有父级编号长度必须介于 0 和 2000 之间")
public String getParentIds() {
return parentIds;
}
@Override
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
@Length(min=0, max=255, message="图片长度必须介于 0 和 255 之间")
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public Date getBeginCreateDate() {
return beginCreateDate;
}
public void setBeginCreateDate(Date beginCreateDate) {
this.beginCreateDate = beginCreateDate;
}
public Date getEndCreateDate() {
return endCreateDate;
}
public void setEndCreateDate(Date endCreateDate) {
this.endCreateDate = endCreateDate;
}
public Date getBeginUpdateDate() {
return beginUpdateDate;
}
public void setBeginUpdateDate(Date beginUpdateDate) {
this.beginUpdateDate = beginUpdateDate;
}
public Date getEndUpdateDate() {
return endUpdateDate;
}
public void setEndUpdateDate(Date endUpdateDate) {
this.endUpdateDate = endUpdateDate;
}
@Override
public String getParentId() {
return parent != null && parent.getId() != null ? parent.getId() : "0";
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import com.jeespring.common.utils.AddressUtils;
import com.jeespring.modules.monitor.entity.OnlineSession;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.common.utils.excel.annotation.ExcelField;
import com.jeespring.modules.sys.utils.DictUtils;
/**
* 在线用户记录Entity
* @author JeeSpring
* @version 2018-08-16
*/
public class SysUserOnline extends AbstractBaseEntity<SysUserOnline> {
private static final long serialVersionUID = 1L;
private String loginName; // 登录账号
private String deptName; // 部门名称
private String ipaddr; // 登录IP地址
private String loginLocation; // 登录地点
private String browser; // 浏览器类型
private String os; // 操作系统
private String status; // 在线状态on_line在线off_line离线
private String statusLabel; // 在线状态on_line在线off_line离线Label
private String statusPicture; // 在线状态on_line在线off_line离线Picture
private java.util.Date startTimestsamp; // session创建时间
private java.util.Date lastAccessTime; // session最后访问时间
private Integer expireTime; // 超时时间,单位为分钟
private java.util.Date beginStartTimestsamp; // 开始 session创建时间
private java.util.Date endStartTimestsamp; // 结束 session创建时间
private java.util.Date beginLastAccessTime; // 开始 session最后访问时间
private java.util.Date endLastAccessTime; // 结束 session最后访问时间
private java.util.Date beginCreateDate; // 开始 创建时间
private java.util.Date endCreateDate; // 结束 创建时间
private OnlineSession session; /** 备份的当前用户会话 */
public SysUserOnline() {
super();
}
public SysUserOnline(String id){
super(id);
}
@Length(min=0, max=50, message="登录账号长度必须介于 0 和 50 之间")
@ExcelField(title="登录账号", align=2, sort=1)
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
@Length(min=0, max=50, message="部门名称长度必须介于 0 和 50 之间")
@ExcelField(title="部门名称", align=2, sort=2)
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
@Length(min=0, max=50, message="登录IP地址长度必须介于 0 和 50 之间")
@ExcelField(title="登录IP地址", align=2, sort=3)
public String getIpaddr() {
return ipaddr;
}
public void setIpaddr(String ipaddr) {
this.ipaddr = ipaddr;
}
@Length(min=0, max=255, message="登录地点长度必须介于 0 和 255 之间")
@ExcelField(title="登录地点", align=2, sort=4)
public String getLoginLocation() {
return loginLocation;
}
public void setLoginLocation(String loginLocation) {
this.loginLocation = loginLocation;
}
@Length(min=0, max=50, message="浏览器类型长度必须介于 0 和 50 之间")
@ExcelField(title="浏览器类型", align=2, sort=5)
public String getBrowser() {
return browser;
}
public void setBrowser(String browser) {
this.browser = browser;
}
@Length(min=0, max=50, message="操作系统长度必须介于 0 和 50 之间")
@ExcelField(title="操作系统", align=2, sort=6)
public String getOs() {
return os;
}
public void setOs(String os) {
this.os = os;
}
@Length(min=0, max=10, message="在线状态on_line在线off_line离线长度必须介于 0 和 10 之间")
@ExcelField(title="在线状态on_line在线off_line离线", dictType="on_line_status", align=2, sort=7)
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatusLabel() {
return DictUtils.getDictLabel(status,"on_line_status","");
}
public String getStatusPicture() {
return DictUtils.getDictPicture(status,"on_line_status","");
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelField(title="session创建时间", align=2, sort=8)
public Date getStartTimestsamp() {
return startTimestsamp;
}
public void setStartTimestsamp(Date startTimestsamp) {
this.startTimestsamp = startTimestsamp;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelField(title="session最后访问时间", align=2, sort=9)
public Date getLastAccessTime() {
return lastAccessTime;
}
public void setLastAccessTime(Date lastAccessTime) {
this.lastAccessTime = lastAccessTime;
}
@ExcelField(title="超时时间,单位为分钟", align=2, sort=10)
public Integer getExpireTime() {
return expireTime;
}
public void setExpireTime(Integer expireTime) {
this.expireTime = expireTime;
}
public Date getBeginStartTimestsamp() {
return beginStartTimestsamp;
}
public void setBeginStartTimestsamp(Date beginStartTimestsamp) {
this.beginStartTimestsamp = beginStartTimestsamp;
}
public Date getEndStartTimestsamp() {
return endStartTimestsamp;
}
public void setEndStartTimestsamp(Date endStartTimestsamp) {
this.endStartTimestsamp = endStartTimestsamp;
}
public Date getBeginLastAccessTime() {
return beginLastAccessTime;
}
public void setBeginLastAccessTime(Date beginLastAccessTime) {
this.beginLastAccessTime = beginLastAccessTime;
}
public Date getEndLastAccessTime() {
return endLastAccessTime;
}
public void setEndLastAccessTime(Date endLastAccessTime) {
this.endLastAccessTime = endLastAccessTime;
}
public Date getBeginCreateDate() {
return beginCreateDate;
}
public void setBeginCreateDate(Date beginCreateDate) {
this.beginCreateDate = beginCreateDate;
}
public Date getEndCreateDate() {
return endCreateDate;
}
public void setEndCreateDate(Date endCreateDate) {
this.endCreateDate = endCreateDate;
}
public OnlineSession getSession() {
return session;
}
public void setSession(OnlineSession session) {
this.session = session;
}
/**
* 设置session对象
*/
public static final SysUserOnline fromOnlineSession(OnlineSession session)
{
SysUserOnline online = new SysUserOnline();
online.setId(String.valueOf(session.getId()));
online.setDeptName(session.getDeptName());
online.setLoginName(session.getLoginName());
online.setStartTimestsamp(session.getStartTimestamp());
online.setLastAccessTime(session.getLastAccessTime());
online.setExpireTime((int)session.getTimeout());
online.setIpaddr(session.getHost());
online.setLoginLocation(AddressUtils.getRealAddressByIP(session.getHost()));
online.setBrowser(session.getBrowser());
online.setOs(session.getOs());
online.setStatus(session.getStatus().toString());
online.setSession(session);
return online;
}
}
\ No newline at end of file
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.sys.entity;
import org.hibernate.validator.constraints.Length;
import com.jeespring.common.persistence.AbstractBaseEntity;
import com.jeespring.common.utils.excel.annotation.ExcelField;
/**
* 系统配置Entity
* @author liugf
* @version 2016-02-07
*/
public class SystemConfig extends AbstractBaseEntity<SystemConfig> {
private static final long serialVersionUID = 1L;
private String smtp; // 邮箱服务器地址
private String port; // 邮箱服务器端口
private String mailName; // 系统邮箱地址
private String mailPassword; // 系统邮箱密码
private String smsName; // 短信用户名
private String smsPassword; // 短信密码
private boolean test = false;
public SystemConfig() {
super();
}
public SystemConfig(String id){
super(id);
}
@Length(min=0, max=64, message="邮箱服务器地址长度必须介于 0 和 64 之间")
@ExcelField(title="邮箱服务器地址", align=2, sort=1)
public String getSmtp() {
return smtp;
}
public void setSmtp(String smtp) {
this.smtp = smtp;
}
@Length(min=0, max=64, message="邮箱服务器端口长度必须介于 0 和 64 之间")
@ExcelField(title="邮箱服务器端口", align=2, sort=2)
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
@Length(min=0, max=64, message="系统邮箱地址长度必须介于 0 和 64 之间")
@ExcelField(title="系统邮箱地址", align=2, sort=3)
public String getMailName() {
return mailName;
}
public void setMailName(String mailName) {
this.mailName = mailName;
}
@Length(min=0, max=64, message="系统邮箱密码长度必须介于 0 和 64 之间")
@ExcelField(title="系统邮箱密码", align=2, sort=4)
public String getMailPassword() {
return mailPassword;
}
public void setMailPassword(String mailPassword) {
this.mailPassword = mailPassword;
}
@Length(min=0, max=64, message="短信用户名长度必须介于 0 和 64 之间")
@ExcelField(title="短信用户名", align=2, sort=5)
public String getSmsName() {
return smsName;
}
public void setSmsName(String smsName) {
this.smsName = smsName;
}
@Length(min=0, max=64, message="短信密码长度必须介于 0 和 64 之间")
@ExcelField(title="短信密码", align=2, sort=6)
public String getSmsPassword() {
return smsPassword;
}
public void setSmsPassword(String smsPassword) {
this.smsPassword = smsPassword;
}
public void setTest(boolean test) {
this.test = test;
}
public boolean isTest() {
return test;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.entity;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.jeespring.common.config.Global;
import com.jeespring.common.utils.Collections3;
import com.jeespring.common.utils.excel.annotation.ExcelField;
import com.jeespring.common.utils.excel.fieldtype.RoleListType;
import com.jeespring.common.persistence.AbstractBaseEntity;
/**
* 用户Entity
* @author 黄炳桂 516821420@qq.com
* @version 2013-12-05
*/
public class User extends AbstractBaseEntity<User> {
private static final long serialVersionUID = 1L;
private Office company; // 归属公司
private Office office; // 归属部门
private String loginName;// 登录名
private String password;// 密码
private String no; // 工号
private String name; // 姓名
private String email; // 邮箱
private String phone; // 电话
private String mobile; // 手机
private String userType;// 用户类型
private String loginIp; // 最后登陆IP
private Date loginDate; // 最后登陆日期
private String loginFlag; // 是否允许登陆
private String photo; // 头像
private String qrCode; //二维码
private String oldLoginName;// 原登录名
private String newPassword; // 新密码
private String oldLoginIp; // 上次登陆IP
private Date oldLoginDate; // 上次登陆日期
private Role role; // 根据角色查询用户条件
private List<Role> roleList = Lists.newArrayList(); // 拥有角色列表
private String oauthId; //小程序唯一标识
private String oauthSecret; //小程序秘钥
public User() {
super();
this.loginFlag = Global.YES;
}
public User(String id){
super(id);
}
public User(String id, String loginName){
super(id);
this.loginName = loginName;
}
public User(Role role){
super();
this.role = role;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public String getLoginFlag() {
return loginFlag;
}
public void setLoginFlag(String loginFlag) {
this.loginFlag = loginFlag;
}
//SupCol(isUnique="true", isHide="true")
@Override
@ExcelField(title="ID", type=1, align=2, sort=1)
public String getId() {
return id;
}
@JsonIgnore
@NotNull(message="归属公司不能为空")
@ExcelField(title="归属公司", align=2, sort=20)
public Office getCompany() {
return company;
}
public void setCompany(Office company) {
this.company = company;
}
@JsonIgnore
@NotNull(message="归属部门不能为空")
@ExcelField(title="归属部门", align=2, sort=25)
public Office getOffice() {
return office;
}
public void setOffice(Office office) {
this.office = office;
}
@Length(min=1, max=100, message="登录名长度必须介于 1 和 100 之间")
@ExcelField(title="登录名", align=2, sort=30)
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
@JsonIgnore
@Length(min=1, max=100, message="密码长度必须介于 1 和 100 之间")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Length(min=1, max=100, message="姓名长度必须介于 1 和 100 之间")
@ExcelField(title="姓名", align=2, sort=40)
public String getName() {
return name;
}
@Length(min=1, max=100, message="工号长度必须介于 1 和 100 之间")
@ExcelField(title="工号", align=2, sort=45)
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public void setName(String name) {
this.name = name;
}
@Email(message="邮箱格式不正确")
@Length(min=0, max=200, message="邮箱长度必须介于 1 和 200 之间")
@ExcelField(title="邮箱", align=1, sort=50)
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Length(min=0, max=200, message="电话长度必须介于 1 和 200 之间")
@ExcelField(title="电话", align=2, sort=60)
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Length(min=0, max=200, message="手机长度必须介于 1 和 200 之间")
@ExcelField(title="手机", align=2, sort=70)
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
@Override
@ExcelField(title="备注", align=1, sort=900)
public String getRemarks() {
return remarks;
}
@Length(min=0, max=100, message="用户类型长度必须介于 1 和 100 之间")
@ExcelField(title="用户类型", align=2, sort=80, dictType="sys_user_type")
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
@Override
@ExcelField(title="创建时间", type=0, align=1, sort=90)
public Date getCreateDate() {
return createDate;
}
@ExcelField(title="最后登录IP", type=1, align=1, sort=100)
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelField(title="最后登录日期", type=1, align=1, sort=110)
public Date getLoginDate() {
return loginDate;
}
public void setLoginDate(Date loginDate) {
this.loginDate = loginDate;
}
public String getOldLoginName() {
return oldLoginName;
}
public void setOldLoginName(String oldLoginName) {
this.oldLoginName = oldLoginName;
}
public String getNewPassword() {
return newPassword;
}
public void setNewPassword(String newPassword) {
this.newPassword = newPassword;
}
public String getOldLoginIp() {
if (oldLoginIp == null){
return loginIp;
}
return oldLoginIp;
}
public void setOldLoginIp(String oldLoginIp) {
this.oldLoginIp = oldLoginIp;
}
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public Date getOldLoginDate() {
if (oldLoginDate == null){
return loginDate;
}
return oldLoginDate;
}
public void setOldLoginDate(Date oldLoginDate) {
this.oldLoginDate = oldLoginDate;
}
public Role getRole() {
return role;
}
public void setRole(Role role) {
this.role = role;
}
@JsonIgnore
@ExcelField(title="拥有角色", align=1, sort=800, fieldType=RoleListType.class)
public List<Role> getRoleList() {
return roleList;
}
public void setRoleList(List<Role> roleList) {
this.roleList = roleList;
}
@JsonIgnore
public List<String> getRoleIdList() {
List<String> roleIdList = Lists.newArrayList();
for (Role role : roleList) {
roleIdList.add(role.getId());
}
return roleIdList;
}
public void setRoleIdList(List<String> roleIdList) {
roleList = Lists.newArrayList();
for (String roleId : roleIdList) {
Role role = new Role();
role.setId(roleId);
roleList.add(role);
}
}
/**
* 用户拥有的角色名称字符串, 多个角色名称用','分隔.
*/
public String getRoleNames() {
return Collections3.extractToString(roleList, "name", ",");
}
public boolean isAdmin(){
return isAdmin(this.id);
}
public static boolean isAdmin(String id){
return id != null && "1".equals(id);
}
@Override
public String toString() {
return id;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getQrCode() {
return qrCode;
}
public String getOauthId() {
return oauthId;
}
public void setOauthId(String oauthId) {
this.oauthId = oauthId;
}
public String getOauthSecret() {
return oauthSecret;
}
public void setOauthSecret(String oauthSecret) {
this.oauthSecret = oauthSecret;
}
}
\ No newline at end of file
package com.jeespring.modules.sys.entity;
import com.jeespring.common.security.ShiroUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 自定义Realm 处理登录 权限
*
* @author JeeSpring
*/
public class UserRealm extends AuthorizingRealm
{
private static final Logger log = LoggerFactory.getLogger(UserRealm.class);
/**
* 授权
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0)
{
Long userId = ShiroUtils.getUserId();
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
// 角色加入AuthorizationInfo认证对象
//info.setRoles(roleService.selectRoleKeys(userId));
// 权限加入AuthorizationInfo认证对象
//info.setStringPermissions(menuService.selectPermsByUserId(userId));
return info;
}
/**
* 登录认证 /admin/login
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException
{
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
String password = "";
if (upToken.getPassword() != null)
{
password = new String(upToken.getPassword());
}
User user = null;
try
{
//user = loginService.login(username, password);
}
/*catch (CaptchaException e)
{
throw new AuthenticationException(e.getMessage(), e);
}
catch (UserNotExistsException e)
{
throw new UnknownAccountException(e.getMessage(), e);
}
catch (UserPasswordNotMatchException e)
{
throw new IncorrectCredentialsException(e.getMessage(), e);
}
catch (UserPasswordRetryLimitExceedException e)
{
throw new ExcessiveAttemptsException(e.getMessage(), e);
}
catch (UserBlockedException e)
{
throw new LockedAccountException(e.getMessage(), e);
}
catch (RoleBlockedException e)
{
throw new LockedAccountException(e.getMessage(), e);
}*/
catch (Exception e)
{
log.info("对用户[" + username + "]进行登录验证..验证未通过{}", e.getMessage());
throw new AuthenticationException(e.getMessage(), e);
}
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, password, getName());
return info;
}
/**
* 清理缓存权限
*/
public void clearCachedAuthorizationInfo()
{
this.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals());
}
}
package com.jeespring.modules.sys.interceptor;
import com.jeespring.modules.sys.entity.Log;
/**
* Created by
* Created on 2017/1/15 20:51
* JeeSpring
*/
public class InterceptorLogEntity {
private Log log;
private Object handler;
private Exception ex;
public InterceptorLogEntity(Log log, Object handler, Exception ex) {
this.log = log;
this.handler = handler;
this.ex = ex;
}
public Log getLog() {
return log;
}
public void setLog(Log log) {
this.log = log;
}
public Object getHandler() {
return handler;
}
public void setHandler(Object handler) {
this.handler = handler;
}
public Exception getEx() {
return ex;
}
public void setEx(Exception ex) {
this.ex = ex;
}
}
/**
* Copyright &copy; 2012-2016 <a href="https://github.com/HuangBingGui/jeespring">jeespring</a> All rights reserved.
*/
package com.jeespring.modules.sys.interceptor;
import com.jeespring.common.service.AbstractService;
import com.jeespring.common.utils.DateUtils;
import com.jeespring.modules.sys.utils.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.NamedThreadLocal;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 日志拦截器
*
* @author 黄炳桂 516821420@qq.com
* @version 2014-8-19
*/
@Component("controllerLogInterceptor")
public class LogInterceptor extends AbstractService implements HandlerInterceptor {
private Logger logger = LoggerFactory.getLogger("controller-log");
private static final ThreadLocal<Long> startTimeThreadLocal =new NamedThreadLocal<Long>("ThreadLocal StartTime");
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
startTimeThreadLocal.set(System.currentTimeMillis());
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
Object handler, Exception ex) throws Exception {
if(!"/error".equals(request.getRequestURI())) {
logger.info("URI: {},耗时:{} ", request.getRequestURI() + "-" + request.getMethod()
, DateUtils.formatDateTime(System.currentTimeMillis() - startTimeThreadLocal.get()));
}
//删除线程变量中的数据,防止内存泄漏
startTimeThreadLocal.remove();
// 保存日志
LogUtils.saveLog(request, handler, ex, null);
}
}
package com.jeespring.modules.sys.interceptor;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jeespring.common.config.Global;
import com.jeespring.common.utils.CacheUtils;
import com.jeespring.common.utils.Exceptions;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.modules.sys.dao.LogDao;
import com.jeespring.modules.sys.dao.MenuDao;
import com.jeespring.modules.sys.entity.Log;
import com.jeespring.modules.sys.entity.Menu;
/**
* Created by
* Created on 2017/1/15 20:55
* JeeSpring
*/
@Component
public class LogThread extends Thread {
public static LinkedBlockingQueue<InterceptorLogEntity> interceptorLogQueue = new LinkedBlockingQueue<>();
private static final String CACHE_MENU_NAME_PATH_MAP = "menuNamePathMap";
private static Logger logger = LoggerFactory.getLogger(LogThread.class);
@Autowired
private LogDao logDao;
@Autowired
private MenuDao menuDao;
@Override
public void run() {
logger.info("start the InterceptorLog thread");
while (true) {
try {
InterceptorLogEntity entiry = interceptorLogQueue.take();
Log log = entiry.getLog();
Exception ex = entiry.getEx();
Object handler = entiry.getHandler();
// 获取日志标题
if (StringUtils.isBlank(log.getTitle())) {
String permission = "";
if (handler instanceof HandlerMethod) {
Method m = ((HandlerMethod) handler).getMethod();
RequiresPermissions rp = m.getAnnotation(RequiresPermissions.class);
permission = (rp != null ? StringUtils.join(rp.value(), ",") : "");
}
log.setTitle(getMenuNamePath(log.getRequestUri(), permission));
if(StringUtils.isBlank(log.getTitle())){
log.setTitle(log.getRequestUri());
}
}
// 如果有异常,设置异常信息
//log.setException(Exceptions.getStackTraceAsString(ex));
if(ex!=null) {
log.setException(ex.getMessage());
}
// 如果无标题并无异常日志,则不保存信息
if (StringUtils.isBlank(log.getTitle()) && StringUtils.isBlank(log.getException())) {
continue;
}
log.setId(UUID.randomUUID().toString());
if(log.getParams()!=null && log.getParams().length()>=500) {
log.setParams(log.getParams().substring(0, 200));
}
logDao.insert(log);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
/**
* 获取菜单名称路径(如:系统设置-机构用户-用户管理-编辑)
*/
private String getMenuNamePath(String requestUri, String permission) {
String href = StringUtils.substringAfter(requestUri, Global.getAdminPath());
@SuppressWarnings("unchecked")
Map<String, String> menuMap = (Map<String, String>) CacheUtils.get(CACHE_MENU_NAME_PATH_MAP);
if (menuMap == null) {
menuMap = Maps.newHashMap();
List<Menu> menuList = menuDao.findAllList(new Menu());
for (Menu menu : menuList) {
// 获取菜单名称路径(如:系统设置-机构用户-用户管理-编辑)
String namePath = "";
if (menu.getParentIds() != null) {
List<String> namePathList = Lists.newArrayList();
for (String id : StringUtils.split(menu.getParentIds(), ",")) {
if (Menu.getRootId().equals(id)) {
continue; // 过滤跟节点
}
for (Menu m : menuList) {
if (m.getId().equals(id)) {
namePathList.add(m.getName());
break;
}
}
}
namePathList.add(menu.getName());
namePath = StringUtils.join(namePathList, "-");
}
// 设置菜单名称路径
if (StringUtils.isNotBlank(menu.getHref())) {
menuMap.put(menu.getHref(), namePath);
} else if (StringUtils.isNotBlank(menu.getPermission())) {
for (String p : StringUtils.split(menu.getPermission())) {
menuMap.put(p, namePath);
}
}
}
CacheUtils.put(CACHE_MENU_NAME_PATH_MAP, menuMap);
}
String menuNamePath = menuMap.get(href);
if (menuNamePath == null) {
for (String p : StringUtils.split(permission)) {
menuNamePath = menuMap.get(p);
if (StringUtils.isNotBlank(menuNamePath)) {
break;
}
}
if (menuNamePath == null) {
return "";
}
}
return menuNamePath;
}
}
/**
* Copyright &copy; 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package com.jeespring.modules.sys.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.jeespring.common.service.AbstractService;
/**
* 手机端视图拦截器
* @author jeespring
* @version 2014-9-1
*/
public class MobileInterceptor extends AbstractService implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
// if (modelAndView != null){//手机端没有开发,默认打开PC端界面。如果你自己开发app端界面,请取消该注释。
// // 如果是手机或平板访问的话,则跳转到手机视图页面。
// if(UserAgentUtils.isMobileOrTablet(request) && !StringUtils.startsWithIgnoreCase(modelAndView.getViewName(), "redirect:")){
// modelAndView.setViewName("mobile/" + modelAndView.getViewName());
// }
// }
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
Object handler, Exception ex) throws Exception {
}
}
package com.jeespring.modules.sys.interceptor;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator;
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor;
import com.jeespring.modules.sys.web.UserController;
import org.springframework.aop.Advisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.JdkRegexpMethodPointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
/**
* Created by
* Created on 2017/1/15 20:21
* JeeSpring
*/
@Component
public class WebInterceptorConfigurer extends WebMvcConfigurerAdapter{
@Autowired
private LogInterceptor logInterceptor;
@Autowired
private LogThread logThread;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(logInterceptor).addPathPatterns("/**");
super.addInterceptors(registry);
logThread.start();
}
/**
* druidServlet注册
*/
@Bean
public ServletRegistrationBean druidServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet());
registration.addUrlMappings("/druid/*");
return registration;
}
/**
* druid监控 配置URI拦截策略
*/
@Bean
public FilterRegistrationBean druidStatFilter() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter());
//添加过滤规则.
filterRegistrationBean.addUrlPatterns("/*");
//添加不需要忽略的格式信息.
filterRegistrationBean.addInitParameter(
"exclusions", "/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid,/druid/*");
//用于session监控页面的用户名显示 需要登录后主动将username注入到session里
filterRegistrationBean.addInitParameter("principalSessionName", "username");
return filterRegistrationBean;
}
/**
* druid数据库连接池监控
*/
@Bean
public DruidStatInterceptor druidStatInterceptor() {
return new DruidStatInterceptor();
}
@Bean
public JdkRegexpMethodPointcut druidStatPointcut() {
JdkRegexpMethodPointcut druidStatPointcut = new JdkRegexpMethodPointcut();
String patterns = "com.jeespring.modules.*.service.*";
//可以set多个
druidStatPointcut.setPatterns(patterns);
return druidStatPointcut;
}
/**
* druid数据库连接池监控
*/
@Bean
public BeanTypeAutoProxyCreator beanTypeAutoProxyCreator() {
BeanTypeAutoProxyCreator beanTypeAutoProxyCreator = new BeanTypeAutoProxyCreator();
beanTypeAutoProxyCreator.setTargetBeanType(DruidDataSource.class);
beanTypeAutoProxyCreator.setInterceptorNames("druidStatInterceptor");
return beanTypeAutoProxyCreator;
}
/**
* druid 为druidStatPointcut添加拦截
*
* @return
*/
@Bean
public Advisor druidStatAdvisor() {
return new DefaultPointcutAdvisor(druidStatPointcut(), druidStatInterceptor());
}
}
package com.jeespring.modules.sys.rest;
import com.jeespring.common.web.AbstractBaseController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jeespring.modules.sys.entity.Dict;
import com.jeespring.modules.sys.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.web.Result;
import com.jeespring.common.web.ResultFactory;
@RestController
@RequestMapping(value={"/rest/sys/dict"})
@Api(value="dict数据字典云接口", description="dict数据字典云接口")
public class DictRestController extends AbstractBaseController {
@Autowired
private DictService dictService;
@RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="数据字典获取信息(Content-Type为text/html)", notes="数据字典获取信息(Content-Type为text/html)")
@ApiImplicitParam(name = "id", value = "数据字典id", required = false, dataType = "String",paramType="query")
public Result get(@RequestParam(required=false) String id) {
Dict dict=null;
if (StringUtils.isNotBlank(id)){
dict=dictService.get(id);
}else{
dict=new Dict();
}
Result result = ResultFactory.getSuccessResult();
result.setResultObject(dict);
return result;
}
@RequestMapping(value = {"get/json"},method ={RequestMethod.POST})
@ApiOperation(value="数据字典获取信息(Content-Type为application/json)", notes="数据字典获取信息(Content-Type为application/json)")
@ApiImplicitParam(name = "id", value = "数据字典id", required = false, dataType = "String",paramType="body")
public Result getJson(@RequestBody(required=false) String id) {
Dict dict=null;
if (StringUtils.isNotBlank(id)){
dict=dictService.get(id);
}else{
dict=new Dict();
}
Result result = ResultFactory.getSuccessResult();
result.setResultObject(dict);
return result;
}
//RequiresPermissions("sys:dict:list")
@RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="数据字典获取列表(Content-Type为text/html)", notes="数据字典获取列表(Content-Type为text/html)")
@ApiImplicitParam(name = "dict", value = "数据字典", dataType = "Dict",paramType="query")
public Result list(Dict dict, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Dict> page = dictService.findPage(new Page<Dict>(request, response), dict);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(page);
return result;
}
@RequestMapping(value = {"list/json"},method ={RequestMethod.POST})
@ApiOperation(value="数据字典获取列表(Content-Type为application/json)", notes="数据字典获取列表(Content-Type为application/json)")
@ApiImplicitParam(name = "dict", value = "数据字典", dataType = "Dict",paramType="body")
public Result listJson(@RequestBody Dict dict, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Dict> page = dictService.findPage(new Page<Dict>(request, response), dict);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(page);
return result;
}
}
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.rest;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.modules.sys.entity.SysConfig;
import com.jeespring.modules.sys.service.SysConfigService;
import org.springframework.web.bind.annotation.RestController;
import com.jeespring.common.web.Result;
import com.jeespring.common.web.ResultFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
/**
* 系统配置Controller
* @author 黄炳桂 516821420@qq.com
* @version 2017-11-17
*/
@RestController
@RequestMapping(value = "/rest/sys/sysConfig")
@Api(value="SysConfig系统配置接口", description="SysConfig系统配置接口")
public class SysConfigRestController extends AbstractBaseController {
@Autowired
private SysConfigService sysConfigService;
/**
* 系统配置信息
*/
@RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="系统配置信息(Content-Type为text/html)", notes="系统配置信息(Content-Type为text/html)")
@ApiImplicitParam(name = "id", value = "系统配置id", required = false, dataType = "String",paramType="query")
public Result get(@RequestParam(required=false) String id) {
SysConfig entity = null;
if (StringUtils.isNotBlank(id)){
entity = sysConfigService.get(id);
}
if (entity == null){
entity = new SysConfig();
}
Result result = ResultFactory.getSuccessResult();
result.setResultObject(entity);
return result;
}
@RequestMapping(value = {"get/json"},method ={RequestMethod.POST})
@ApiOperation(value="系统配置信息(Content-Type为application/json)", notes="系统配置信息(Content-Type为application/json)")
@ApiImplicitParam(name = "id", value = "系统配置id", required = false, dataType = "String",paramType="body")
public Result getJson(@RequestBody(required=false) String id) {
SysConfig entity = null;
if (StringUtils.isNotBlank(id)){
entity = sysConfigService.get(id);
}
if (entity == null){
entity = new SysConfig();
}
Result result = ResultFactory.getSuccessResult();
result.setResultObject(entity);
return result;
}
/**
* 系统配置列表(不包含页信息)
*/
//RequiresPermissions("sys:sysConfig:findList")
@RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="系统配置列表(不包含页信息)(Content-Type为text/html)", notes="系统配置列表(不包含页信息)(Content-Type为text/html)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query")
public Result findList(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) {
List<SysConfig> list = sysConfigService.findList(sysConfig);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(list);
return result;
}
@RequestMapping(value = {"findList/json"},method ={RequestMethod.POST})
@ApiOperation(value="系统配置列表(不包含页信息)(Content-Type为application/json)", notes="系统配置列表(不包含页信息)(Content-Type为application/json)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body")
public Result findListJson(@RequestBody SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) {
List<SysConfig> list = sysConfigService.findList(sysConfig);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(list);
return result;
}
/**
* 系统配置列表(包含页信息)
*/
//RequiresPermissions("sys:sysConfig:list")
@RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="系统配置列表(包含页信息)(Content-Type为text/html)", notes="系统配置列表(包含页信息)(Content-Type为text/html)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query")
public Result list(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<SysConfig> page = sysConfigService.findPage(new Page<SysConfig>(request, response), sysConfig);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(page);
return result;
}
@RequestMapping(value = {"list/json"},method ={RequestMethod.POST})
@ApiOperation(value="系统配置列表(包含页信息)(Content-Type为application/json)", notes="系统配置列表(包含页信息)(Content-Type为application/json)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body")
public Result listJson(@RequestBody SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<SysConfig> page = sysConfigService.findPage(new Page<SysConfig>(sysConfig.getPageNo(),sysConfig.getPageSize(),sysConfig.getOrderBy()), sysConfig);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(page);
return result;
}
/**
* 系统配置获取列表第一条记录
*/
//RequiresPermissions("sys:sysConfig:listFrist")
@RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="系统配置获取列表第一条记录(Content-Type为text/html)", notes="系统配置获取列表第一条记录(Content-Type为text/html)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query")
public Result listFrist(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<SysConfig> page = sysConfigService.findPage(new Page<SysConfig>(request, response), sysConfig);
Result result = ResultFactory.getSuccessResult();
if(page.getList().size()>0){
result.setResultObject(page.getList().get(0));
}else{
result=ResultFactory.getErrorResult("没有记录!");
}
return result;
}
@RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST})
@ApiOperation(value="系统配置获取列表第一条记录(Content-Type为application/json)", notes="系统配置获取列表第一条记录(Content-Type为application/json)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body")
public Result listFristJson(@RequestBody SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<SysConfig> page = sysConfigService.findPage(new Page<SysConfig>(sysConfig.getPageNo(),sysConfig.getPageSize(),sysConfig.getOrderBy()), sysConfig);
Result result = ResultFactory.getSuccessResult();
if(page.getList().size()>0){
result.setResultObject(page.getList().get(0));
}else{
result=ResultFactory.getErrorResult("没有记录!");
}
return result;
}
/**
* 保存系统配置
*/
//RequiresPermissions(value={"sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR)
@RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="保存系统配置(Content-Type为text/html)", notes="保存系统配置(Content-Type为text/html)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query")
public Result save(SysConfig sysConfig, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, sysConfig)){
Result result = ResultFactory.getErrorResult("数据验证失败");
}
sysConfigService.save(sysConfig);
Result result = ResultFactory.getSuccessResult("保存系统配置成功");
return result;
}
@RequestMapping(value = "save/json",method ={RequestMethod.POST})
@ApiOperation(value="保存系统配置(Content-Type为application/json)", notes="保存系统配置(Content-Type为application/json)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body")
public Result saveJson(@RequestBody SysConfig sysConfig, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, sysConfig)){
Result result = ResultFactory.getErrorResult("数据验证失败");
}
sysConfigService.save(sysConfig);
Result result = ResultFactory.getSuccessResult("保存系统配置成功");
return result;
}
/**
* 删除系统配置
*/
//RequiresPermissions("sys:sysConfig:del")
@RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="删除系统配置(Content-Type为text/html)", notes="删除系统配置(Content-Type为text/html)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query")
public Result delete(SysConfig sysConfig, RedirectAttributes redirectAttributes) {
sysConfigService.delete(sysConfig);
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
/**
* 删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="逻辑删除系统配置(Content-Type为text/html)", notes="逻辑删除系统配置(Content-Type为text/html)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query")
public Result deleteByLogic(SysConfig sysConfig, RedirectAttributes redirectAttributes) {
sysConfigService.deleteByLogic(sysConfig);
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
@RequestMapping(value = "delete/json",method ={RequestMethod.POST})
@ApiOperation(value="删除系统配置(Content-Type为application/json)", notes="删除系统配置(Content-Type为application/json)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body")
public Result deleteJson(@RequestBody SysConfig sysConfig, RedirectAttributes redirectAttributes) {
sysConfigService.delete(sysConfig);
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
/**
* 删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST})
@ApiOperation(value="逻辑删除系统配置(Content-Type为application/json)", notes="逻辑删除系统配置(Content-Type为application/json)")
@ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body")
public Result deleteByLogicJson(@RequestBody SysConfig sysConfig, RedirectAttributes redirectAttributes) {
sysConfigService.deleteByLogic(sysConfig);
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
/**
* 批量删除系统配置
*/
//RequiresPermissions("sys:sysConfig:del")
@RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="批量删除系统配置(Content-Type为text/html)", notes="批量删除系统配置(Content-Type为text/html)")
@ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="query")
public Result deleteAll(String ids, RedirectAttributes redirectAttributes) {
String[] idArray = ids.split(",");
for(String id : idArray){
sysConfigService.delete(sysConfigService.get(id));
}
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
/**
* 批量删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="逻辑批量删除系统配置(Content-Type为text/html)", notes="逻辑批量删除系统配置(Content-Type为text/html)")
@ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="query")
public Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) {
String[] idArray = ids.split(",");
for(String id : idArray){
sysConfigService.deleteByLogic(sysConfigService.get(id));
}
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
@RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST})
@ApiOperation(value="批量删除系统配置(Content-Type为application/json)", notes="批量删除系统配置(Content-Type为application/json)")
@ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="body")
public Result deleteAllJson(@RequestBody String ids, RedirectAttributes redirectAttributes) {
String[] idArray = ids.split(",");
for(String id : idArray){
sysConfigService.delete(sysConfigService.get(id));
}
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
/**
* 批量删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST})
@ApiOperation(value="逻辑批量删除系统配置(Content-Type为application/json)", notes="逻辑批量删除系统配置(Content-Type为application/json)")
@ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="body")
public Result deleteAllByLogicJson(@RequestBody String ids, RedirectAttributes redirectAttributes) {
String[] idArray = ids.split(",");
for(String id : idArray){
sysConfigService.deleteByLogic(sysConfigService.get(id));
}
Result result = ResultFactory.getSuccessResult("删除系统配置成功");
return result;
}
}
\ No newline at end of file
/**
* * Copyright &copy; 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package com.jeespring.modules.sys.rest;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Lists;
import com.jeespring.common.utils.DateUtils;
import com.jeespring.common.config.Global;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.utils.excel.ExportExcel;
import com.jeespring.common.utils.excel.ImportExcel;
import com.jeespring.modules.sys.entity.SysUserOnline;
import com.jeespring.modules.sys.service.SysUserOnlineService;
import org.springframework.web.bind.annotation.RestController;
import com.jeespring.common.web.Result;
import com.jeespring.common.web.ResultFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
/**
* 在线用户记录Controller
* @author JeeSpring
* @version 2018-08-16
*/
@RestController
@RequestMapping(value = "/rest/sys/sysUserOnline")
@Api(value="在线用户记录接口", description="在线用户记录接口")
public class SysUserOnlineRestController extends AbstractBaseController {
@Autowired
private SysUserOnlineService sysUserOnlineService;
/**
* 在线用户记录信息
*/
@RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="在线用户记录信息(Content-Type为text/html)", notes="在线用户记录信息(Content-Type为text/html)")
@ApiImplicitParam(name = "id", value = "在线用户记录id", required = false, dataType = "String",paramType="query")
public Result getRequestParam(@RequestParam(required=false) String id) {
return get(id);
}
@RequestMapping(value = {"get/json"},method ={RequestMethod.POST})
@ApiOperation(value="在线用户记录信息(Content-Type为application/json)", notes="在线用户记录信息(Content-Type为application/json)")
@ApiImplicitParam(name = "id", value = "在线用户记录id", required = false, dataType = "String",paramType="body")
public Result getRequestBody(@RequestBody(required=false) String id) {
return get(id);
}
private Result get(String id) {
SysUserOnline entity = null;
if (StringUtils.isNotBlank(id)){
entity = sysUserOnlineService.getCache(id);
//entity = sysUserOnlineService.get(id);
}
if (entity == null){
entity = new SysUserOnline();
}
Result result = ResultFactory.getSuccessResult();
result.setResultObject(entity);
return result;
}
/**
* 在线用户记录列表(不包含页信息)
*/
//RequiresPermissions("sys:sysUserOnline:findList")
@RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="在线用户记录列表(不包含页信息)(Content-Type为text/html)", notes="在线用户记录列表(不包含页信息)(Content-Type为text/html)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query")
public Result findListRequestParam(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) {
return findList( sysUserOnline,model);
}
@RequestMapping(value = {"findList/json"},method ={RequestMethod.POST})
@ApiOperation(value="在线用户记录列表(不包含页信息)(Content-Type为application/json)", notes="在线用户记录列表(不包含页信息)(Content-Type为application/json)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body")
public Result findListRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model) {
return findList( sysUserOnline,model);
}
private Result findList(SysUserOnline sysUserOnline, Model model) {
List<SysUserOnline> list = sysUserOnlineService.findListCache(sysUserOnline);
//List<SysUserOnline> list = sysUserOnlineService.findList(sysUserOnline);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(list);
return result;
}
/**
* 在线用户记录列表(包含页信息)
*/
//RequiresPermissions("sys:sysUserOnline:list")
@RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="在线用户记录列表(包含页信息)(Content-Type为text/html)", notes="在线用户记录列表(包含页信息)(Content-Type为text/html)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query")
public Result listRequestParam(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) {
return list(sysUserOnline,model);
}
@RequestMapping(value = {"list/json"},method ={RequestMethod.POST})
@ApiOperation(value="在线用户记录列表(包含页信息)(Content-Type为application/json)", notes="在线用户记录列表(包含页信息)(Content-Type为application/json)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body")
public Result listRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model) {
return list(sysUserOnline,model);
}
private Result list(SysUserOnline sysUserOnline, Model model) {
Page<SysUserOnline> page = sysUserOnlineService.findPageCache(new Page<SysUserOnline>(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline);
//Page<SysUserOnline> page = sysUserOnlineService.findPage(new Page<SysUserOnline>(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline);
Result result = ResultFactory.getSuccessResult();
result.setResultObject(page);
return result;
}
/**
* 在线用户记录获取列表第一条记录
*/
//RequiresPermissions("sys:sysUserOnline:listFrist")
@RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="在线用户记录获取列表第一条记录(Content-Type为text/html)", notes="在线用户记录获取列表第一条记录(Content-Type为text/html)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query")
public Result listFristRequestParam(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) {
return listFrist(sysUserOnline,model);
}
@RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST})
@ApiOperation(value="在线用户记录获取列表第一条记录(Content-Type为application/json)", notes="在线用户记录获取列表第一条记录(Content-Type为application/json)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body")
public Result listFristRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model) {
return listFrist(sysUserOnline,model);
}
private Result listFrist(SysUserOnline sysUserOnline, Model model) {
Page<SysUserOnline> page = sysUserOnlineService.findPageCache(new Page<SysUserOnline>(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline);
//Page<SysUserOnline> page = sysUserOnlineService.findPage(new Page<SysUserOnline>(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline);
Result result = ResultFactory.getSuccessResult();
if(page.getList().size()>0){
result.setResultObject(page.getList().get(0));
}else{
result=ResultFactory.getErrorResult("没有记录!");
}
return result;
}
/**
* 保存在线用户记录
*/
//RequiresPermissions(value={"sys:sysUserOnline:add","sys:sysUserOnline:edit"},logical=Logical.OR)
@RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="保存在线用户记录(Content-Type为text/html)", notes="保存在线用户记录(Content-Type为text/html)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query")
public Result saveRequestParam(SysUserOnline sysUserOnline, Model model, RedirectAttributes redirectAttributes) {
return save(sysUserOnline,model,redirectAttributes);
}
@RequestMapping(value = "save/json",method ={RequestMethod.POST})
@ApiOperation(value="保存在线用户记录(Content-Type为application/json)", notes="保存在线用户记录(Content-Type为application/json)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body")
public Result saveRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model, RedirectAttributes redirectAttributes) {
return save(sysUserOnline,model,redirectAttributes);
}
private Result save(SysUserOnline sysUserOnline, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, sysUserOnline)){
Result result = ResultFactory.getErrorResult("数据验证失败");
}
sysUserOnlineService.save(sysUserOnline);
Result result = ResultFactory.getSuccessResult("保存在线用户记录成功");
return result;
}
/**
* 删除在线用户记录
*/
//RequiresPermissions("sys:sysUserOnline:del")
@RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="删除在线用户记录(Content-Type为text/html)", notes="删除在线用户记录(Content-Type为text/html)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query")
public Result deleteRequestParam(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) {
return delete(sysUserOnline,redirectAttributes);
}
@RequestMapping(value = "delete/json",method ={RequestMethod.POST})
@ApiOperation(value="删除在线用户记录(Content-Type为application/json)", notes="删除在线用户记录(Content-Type为application/json)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body")
public Result deleteRequestBody(@RequestBody SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) {
return delete(sysUserOnline,redirectAttributes);
}
private Result delete(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) {
sysUserOnlineService.delete(sysUserOnline);
Result result = ResultFactory.getSuccessResult("删除在线用户记录成功");
return result;
}
/**
* 删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="逻辑删除在线用户记录(Content-Type为text/html)", notes="逻辑删除在线用户记录(Content-Type为text/html)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query")
public Result deleteByLogicRequestParam(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) {
return deleteByLogic(sysUserOnline,redirectAttributes);
}
/**
* 删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST})
@ApiOperation(value="逻辑删除在线用户记录(Content-Type为application/json)", notes="逻辑删除在线用户记录(Content-Type为application/json)")
@ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body")
public Result deleteByLogicRequestBody(@RequestBody SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) {
return deleteByLogic(sysUserOnline,redirectAttributes);
}
private Result deleteByLogic(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) {
sysUserOnlineService.deleteByLogic(sysUserOnline);
Result result = ResultFactory.getSuccessResult("删除在线用户记录成功");
return result;
}
/**
* 批量删除在线用户记录
*/
//RequiresPermissions("sys:sysUserOnline:del")
@RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="批量删除在线用户记录(Content-Type为text/html)", notes="批量删除在线用户记录(Content-Type为text/html)")
@ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="query")
public Result deleteAllRequestParam(String ids, RedirectAttributes redirectAttributes) {
return deleteAll(ids,redirectAttributes);
}
@RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST})
@ApiOperation(value="批量删除在线用户记录(Content-Type为application/json)", notes="批量删除在线用户记录(Content-Type为application/json)")
@ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="body")
public Result deleteAllRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) {
return deleteAll(ids,redirectAttributes);
}
private Result deleteAll(String ids, RedirectAttributes redirectAttributes) {
String[] idArray = ids.split(",");
for(String id : idArray){
sysUserOnlineService.delete(sysUserOnlineService.get(id));
}
Result result = ResultFactory.getSuccessResult("删除在线用户记录成功");
return result;
}
/**
* 批量删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET})
@ApiOperation(value="逻辑批量删除在线用户记录(Content-Type为text/html)", notes="逻辑批量删除在线用户记录(Content-Type为text/html)")
@ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="query")
public Result deleteAllByLogicRequestParam(String ids, RedirectAttributes redirectAttributes) {
return deleteAllByLogic(ids,redirectAttributes);
}
/**
* 批量删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST})
@ApiOperation(value="逻辑批量删除在线用户记录(Content-Type为application/json)", notes="逻辑批量删除在线用户记录(Content-Type为application/json)")
@ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="body")
public Result deleteAllByLogicRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) {
return deleteAllByLogic(ids,redirectAttributes);
}
private Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) {
String[] idArray = ids.split(",");
for(String id : idArray){
sysUserOnlineService.deleteByLogic(sysUserOnlineService.get(id));
}
Result result = ResultFactory.getSuccessResult("删除在线用户记录成功");
return result;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment