Initial commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.linln.modules.system.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2021/3/19
|
||||
*/
|
||||
@ComponentScan(basePackages = "com.linln.modules.system")
|
||||
@EnableJpaRepositories(basePackages = "com.linln.modules.system")
|
||||
@EntityScan(basePackages = "com.linln.modules.system")
|
||||
public class SystemAutoConfig {
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.linln.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/10/19
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="sys_action_log")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class ActionLog implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
private Byte type;
|
||||
private String ipaddr;
|
||||
private String clazz;
|
||||
private String method;
|
||||
private String model;
|
||||
private Long recordId;
|
||||
@Lob @Column(columnDefinition="TEXT")
|
||||
private String message;
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action=NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="oper_by")
|
||||
@JsonIgnore
|
||||
private User operBy;
|
||||
private String operName;
|
||||
|
||||
public ActionLog(){}
|
||||
/**
|
||||
* 封装日志对象
|
||||
* @param name 日志名称
|
||||
* @param message 日志消息
|
||||
*/
|
||||
public ActionLog(String name, String message){
|
||||
this.name = name;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.linln.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.utils.StatusUtil;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/12/02
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_dept")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Where(clause = StatusUtil.NOT_DELETE)
|
||||
public class Dept implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 部门名称 */
|
||||
private String title;
|
||||
|
||||
/** 父级编号 */
|
||||
private Long pid;
|
||||
|
||||
/** 所有父级编号 */
|
||||
private String pids;
|
||||
|
||||
/** 排序 */
|
||||
private Integer sort;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 创建时间 */
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
|
||||
/** 更新时间 */
|
||||
@LastModifiedDate
|
||||
private Date updateDate;
|
||||
|
||||
// /** 创建者 */
|
||||
// @CreatedBy
|
||||
// @ManyToOne(fetch = FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @JoinColumn(name = "create_by")
|
||||
// @JsonIgnore
|
||||
// private User createBy;
|
||||
|
||||
// /** 更新者 */
|
||||
// @LastModifiedBy
|
||||
// @ManyToOne(fetch = FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @JoinColumn(name = "update_by")
|
||||
// @JsonIgnore
|
||||
// private User updateBy;
|
||||
|
||||
/** 数据状态 */
|
||||
private Byte status = StatusEnum.OK.getCode();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.linln.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.utils.StatusUtil;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="sys_dict")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Where(clause = StatusUtil.NOT_DELETE)
|
||||
public class Dict implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
private String title;
|
||||
private Byte type;
|
||||
@Lob @Column(columnDefinition="TEXT")
|
||||
private String value;
|
||||
private String remark;
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
@LastModifiedDate
|
||||
private Date updateDate;
|
||||
@CreatedBy
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action=NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="create_by")
|
||||
@JsonIgnore
|
||||
private User createBy;
|
||||
@LastModifiedBy
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action=NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="update_by")
|
||||
@JsonIgnore
|
||||
private User updateBy;
|
||||
private Byte status = StatusEnum.OK.getCode();
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.linln.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.utils.StatusUtil;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_menu")
|
||||
@ToString(exclude = {"roles", "createBy", "updateBy"})
|
||||
@EqualsAndHashCode(exclude = {"roles", "createBy", "updateBy"})
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Where(clause = StatusUtil.NOT_DELETE)
|
||||
public class Menu implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private Long pid;
|
||||
private String pids;
|
||||
private String title;
|
||||
private String url;
|
||||
private String perms;
|
||||
private String icon;
|
||||
private Byte type;
|
||||
private Integer sort;
|
||||
private String remark;
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
@LastModifiedDate
|
||||
private Date updateDate;
|
||||
@CreatedBy
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
@JoinColumn(name = "create_by")
|
||||
@JsonIgnore
|
||||
private User createBy;
|
||||
@LastModifiedBy
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
@JoinColumn(name = "update_by")
|
||||
@JsonIgnore
|
||||
private User updateBy;
|
||||
private Byte status = StatusEnum.OK.getCode();
|
||||
|
||||
@ManyToMany(mappedBy = "menus")
|
||||
@JsonIgnore
|
||||
private Set<Role> roles = new HashSet<>(0);
|
||||
|
||||
@Transient
|
||||
@JsonIgnore
|
||||
private Map<Long, Menu> children = new HashMap<>();
|
||||
|
||||
public Menu(){
|
||||
|
||||
}
|
||||
|
||||
public Menu(Long id, String title, String pids) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.pids = pids;
|
||||
}
|
||||
|
||||
public void setPids(String pids) {
|
||||
if (pids.startsWith(",")){
|
||||
pids = pids.substring(1);
|
||||
}
|
||||
this.pids = pids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.linln.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.utils.StatusUtil;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.*;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_role")
|
||||
@ToString(exclude = {"users", "menus", "createBy", "updateBy"})
|
||||
@EqualsAndHashCode(exclude = {"users", "menus", "createBy", "updateBy"})
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@SQLDelete(sql = "update sys_role" + StatusUtil.SLICE_DELETE)
|
||||
@Where(clause = StatusUtil.NOT_DELETE)
|
||||
public class Role implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
private String title;
|
||||
private String remark;
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
@LastModifiedDate
|
||||
private Date updateDate;
|
||||
@CreatedBy
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
@JoinColumn(name = "create_by")
|
||||
@JsonIgnore
|
||||
private User createBy;
|
||||
@LastModifiedBy
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
@JoinColumn(name = "update_by")
|
||||
@JsonIgnore
|
||||
private User updateBy;
|
||||
private Byte status = StatusEnum.OK.getCode();
|
||||
|
||||
@ManyToMany(mappedBy = "roles", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@JsonIgnore
|
||||
private Set<User> users = new HashSet<>(0);
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "sys_role_menu",
|
||||
joinColumns = @JoinColumn(name = "role_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "menu_id"))
|
||||
@JsonIgnore
|
||||
private Set<Menu> menus = new HashSet<>(0);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.linln.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.linln.common.utils.HttpServletUtil;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/11/02
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="sys_file")
|
||||
@Data
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class Upload implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 文件名 */
|
||||
private String name;
|
||||
|
||||
/** 文件路径 */
|
||||
private String path;
|
||||
|
||||
/** 文件类型 */
|
||||
private String mime;
|
||||
|
||||
/** 文件大小 */
|
||||
private Long size;
|
||||
|
||||
/** 文件md5值 */
|
||||
private String md5;
|
||||
|
||||
/** 文件sha1值 */
|
||||
private String sha1;
|
||||
|
||||
/** 创建时间 */
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
|
||||
/** 创建者 */
|
||||
@CreatedBy
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action= NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="create_by")
|
||||
@JsonIgnore
|
||||
private User createBy;
|
||||
|
||||
/**
|
||||
* 获取文件绝对路径
|
||||
*/
|
||||
public String getUrl() {
|
||||
HttpServletRequest request = HttpServletUtil.getRequest();
|
||||
if (!StringUtils.isEmpty(path)) {
|
||||
StringBuffer url = request.getRequestURL();
|
||||
String baseUrl = url.delete(url.length() - request.getRequestURI().length(), url.length())
|
||||
.append(request.getContextPath()).toString();
|
||||
return baseUrl + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.linln.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.utils.StatusUtil;
|
||||
import com.linln.component.excel.annotation.Excel;
|
||||
import com.linln.component.excel.enums.ExcelType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_user")
|
||||
@ToString(exclude = {"dept", "roles"})
|
||||
@EqualsAndHashCode(exclude = {"dept", "roles"})
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@SQLDelete(sql = "update sys_user" + StatusUtil.SLICE_DELETE)
|
||||
@Where(clause = StatusUtil.NOT_DELETE)
|
||||
@Excel("用户数据")
|
||||
public class User implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Excel(value = "用户ID", type = ExcelType.EXPORT)
|
||||
private Long id;
|
||||
@Excel("用户名")
|
||||
private String username;
|
||||
@JsonIgnore
|
||||
private String password;
|
||||
@JsonIgnore
|
||||
private String salt;
|
||||
@Excel("昵称")
|
||||
private String nickname;
|
||||
private String picture;
|
||||
@Excel(value = "性别", dict = "USER_SEX")
|
||||
private Byte sex;
|
||||
@Excel("手机号码")
|
||||
private String phone;
|
||||
@Excel("电子邮箱")
|
||||
private String email;
|
||||
@CreatedDate
|
||||
@Excel("创建时间")
|
||||
private Date createDate;
|
||||
@LastModifiedDate
|
||||
@Excel("更新时间")
|
||||
private Date updateDate;
|
||||
@Excel("备注")
|
||||
private String remark;
|
||||
@Excel(value = "状态", dict = "DATA_STATUS")
|
||||
private Byte status = StatusEnum.OK.getCode();
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "dept_id")
|
||||
@JsonIgnore
|
||||
private Dept dept;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "sys_user_role",
|
||||
joinColumns = @JoinColumn(name = "user_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "role_id"))
|
||||
@JsonIgnore
|
||||
private Set<Role> roles = new HashSet<>(0);
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
private Long company;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.linln.modules.system.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/10/14
|
||||
*/
|
||||
@Getter
|
||||
public enum ActionLogEnum {
|
||||
|
||||
/**
|
||||
* 业务日志行为
|
||||
*/
|
||||
BUSINESS((byte) 1, "业务"),
|
||||
/**
|
||||
* 用户登录日志行为
|
||||
*/
|
||||
LOGIN((byte) 2, "登录"),
|
||||
/**
|
||||
* 系统日志行为(报错信息)
|
||||
*/
|
||||
SYSTEM((byte) 3, "系统");
|
||||
|
||||
private Byte code;
|
||||
|
||||
private String message;
|
||||
|
||||
ActionLogEnum(Byte code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.linln.modules.system.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 字典类型枚举
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Getter
|
||||
public enum DictTypeEnum {
|
||||
|
||||
/**
|
||||
* 字符值类型
|
||||
*/
|
||||
VALUE((byte)1, "字符值"),
|
||||
/**
|
||||
* 键值对类型
|
||||
*/
|
||||
KEY_VALUE((byte)2, "键值对"),
|
||||
/**
|
||||
* 枚举类类型
|
||||
*/
|
||||
ENUM_VALUE((byte)3, "枚举类");
|
||||
|
||||
private Byte code;
|
||||
|
||||
private String message;
|
||||
|
||||
DictTypeEnum(Byte code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.linln.modules.system.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 菜单类型枚举
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Getter
|
||||
public enum MenuTypeEnum {
|
||||
|
||||
/**
|
||||
* 目录类型
|
||||
*/
|
||||
DIRECTORY((byte)1, "目录"),
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
MENU((byte)2, "菜单"),
|
||||
/**
|
||||
* 按钮类型
|
||||
*/
|
||||
BUTTON((byte)3, "按钮"),
|
||||
|
||||
/**
|
||||
* 一级菜单
|
||||
* {该枚举已过期,请使用目录类型}
|
||||
*/
|
||||
@Deprecated
|
||||
TOP_LEVEL((byte)1, "一级菜单"),
|
||||
/**
|
||||
* 子级菜单
|
||||
* {该枚举已过期,请使用菜单类型}
|
||||
*/
|
||||
@Deprecated
|
||||
SUB_LEVEL((byte)2, "子级菜单"),
|
||||
/**
|
||||
* 按钮类型
|
||||
* {该枚举已过期,请使用按钮类型}
|
||||
*/
|
||||
@Deprecated
|
||||
NOT_MENU((byte)3, "不是菜单");
|
||||
|
||||
private Byte code;
|
||||
|
||||
private String message;
|
||||
|
||||
MenuTypeEnum(Byte code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.modules.system.domain.ActionLog;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/10/19
|
||||
*/
|
||||
public interface ActionLogRepository extends JpaRepository<ActionLog, Long> {
|
||||
|
||||
/**
|
||||
* 根据模型和数据ID查询日志列表
|
||||
* @param model 模型(表名)
|
||||
* @param recordId 数据ID
|
||||
* @return 日志列表
|
||||
*/
|
||||
public List<ActionLog> findByModelAndRecordId(String model, Long recordId);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.common.constant.StatusConst;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@NoRepositoryBean
|
||||
public interface BaseRepository<T, ID> extends JpaRepository<T,ID> {
|
||||
|
||||
/**
|
||||
* 查找ID且状态正常
|
||||
* @param id 主键ID
|
||||
* @param status 状态
|
||||
* @return 实体对象
|
||||
*/
|
||||
T findByIdAndStatus(ID id, Byte status);
|
||||
|
||||
/**
|
||||
* 批量更新数据状态
|
||||
* #{#entityName} 实体类对象
|
||||
* @param status 状态
|
||||
* @param id ID列表
|
||||
* @return 更新数量
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query("update #{#entityName} set status = ?1 where id in ?2 and status <> " + StatusConst.DELETE)
|
||||
Integer updateStatus(Byte status, List<ID> id);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.common.constant.StatusConst;
|
||||
import com.linln.modules.system.domain.Dept;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/12/02
|
||||
*/
|
||||
public interface DeptRepository extends BaseRepository<Dept, Long> {
|
||||
|
||||
/**
|
||||
* 查找多个部门
|
||||
* @param ids id列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
public List<Dept> findByIdIn(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获取排序最大值
|
||||
* @param pid 父部门ID
|
||||
* @return 最大值
|
||||
*/
|
||||
@Query("select max(sort) from Menu m where m.pid = ?1 and m.status <> " + StatusConst.DELETE)
|
||||
public Integer findSortMax(long pid);
|
||||
|
||||
/**
|
||||
* 根据父ID查找子孙部门
|
||||
* @param pids pid列表
|
||||
* @param status 数据状态
|
||||
* @return 部门列表
|
||||
*/
|
||||
public List<Dept> findByPidsLikeAndStatus(String pids, Byte status);
|
||||
|
||||
/**
|
||||
* 根据父级部门ID获取本级全部部门
|
||||
* @param sort 排序对象
|
||||
* @param pid 父部门ID
|
||||
* @param notId 需要排除的部门ID
|
||||
* @return 部门列表
|
||||
*/
|
||||
public List<Dept> findByPidAndIdNot(Sort sort, long pid, long notId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.modules.system.domain.Dict;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface DictRepository extends BaseRepository<Dict, Long> {
|
||||
|
||||
/**
|
||||
* 根据字典标识查询
|
||||
* @param name 字典标识
|
||||
* @param status 状态
|
||||
* @return 字典信息
|
||||
*/
|
||||
public Dict findByNameAndStatus(String name, Byte status);
|
||||
|
||||
/**
|
||||
* 根据标识查询字典数据,且排查指定ID的字典
|
||||
* @param name 字典标识
|
||||
* @param id 字典ID
|
||||
* @return 字典信息
|
||||
*/
|
||||
public Dict findByNameAndIdNot(String name, Long id);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.common.constant.StatusConst;
|
||||
import com.linln.modules.system.domain.Menu;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface MenuRepository extends BaseRepository<Menu, Long> {
|
||||
|
||||
/**
|
||||
* 查找多个菜单
|
||||
* @param ids id列表
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<Menu> findByIdIn(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 查找响应状态的菜单
|
||||
* @param sort 排序对象
|
||||
* @param status 数据状态
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<Menu> findAllByStatus(Sort sort, Byte status);
|
||||
|
||||
/**
|
||||
* 查询菜单URL
|
||||
* @param url id列表
|
||||
* @return 菜单信息
|
||||
*/
|
||||
public Menu findByUrl(String url);
|
||||
|
||||
/**
|
||||
* 根据父ID查找子菜单
|
||||
* @param pids pid列表
|
||||
* @param status 数据状态
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<Menu> findByPidsLikeAndStatus(String pids, Byte status);
|
||||
|
||||
/**
|
||||
* 获取排序最大值
|
||||
* @param pid 父菜单ID
|
||||
* @return 最大值
|
||||
*/
|
||||
@Query("select max(sort) from Menu m where m.pid = ?1 and m.status <> " + StatusConst.DELETE)
|
||||
public Integer findSortMax(long pid);
|
||||
|
||||
/**
|
||||
* 根据父级菜单ID获取本级全部菜单
|
||||
* @param sort 排序对象
|
||||
* @param pid 父菜单ID
|
||||
* @param notId 需要排除的菜单ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<Menu> findByPidAndIdNot(Sort sort, long pid, long notId);
|
||||
|
||||
/**
|
||||
* 取消菜单与角色之间的关系
|
||||
* @param id 菜单ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query(value = "DELETE FROM sys_role_menu WHERE menu_id = ?1", nativeQuery = true)
|
||||
public Integer cancelRoleJoin(Long id);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.modules.system.domain.Role;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface RoleRepository extends BaseRepository<Role,Long> {
|
||||
|
||||
/**
|
||||
* 查找多个角色
|
||||
* @param ids id列表
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<Role> findByIdIn(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 查找相应状态的角色
|
||||
* @param sort 排序对象
|
||||
* @param status 数据状态
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<Role> findAllByStatus(Sort sort, Byte status);
|
||||
|
||||
/**
|
||||
* 查询指定用户的角色列表
|
||||
* @param id 用户ID
|
||||
* @param status 角色状态
|
||||
* @return 角色列表
|
||||
*/
|
||||
public Set<Role> findByUsers_IdAndStatus(Long id, Byte status);
|
||||
|
||||
/**
|
||||
* 根据标识查询角色数据,且排查指定ID的角色
|
||||
* @param name 角色标识
|
||||
* @param id 角色ID
|
||||
* @return 角色信息
|
||||
*/
|
||||
public Role findByNameAndIdNot(String name, Long id);
|
||||
|
||||
/**
|
||||
* 判断指定的用户是否存在角色
|
||||
* @param id 用户ID
|
||||
* @param status 角色状态
|
||||
* @return 是否存在角色
|
||||
*/
|
||||
public Boolean existsByUsers_IdAndStatus(Long id, Byte status);
|
||||
|
||||
/**
|
||||
* 取消角色与用户之间的关系
|
||||
* @param ids 角色ID
|
||||
* @return 影响结果
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query(value = "DELETE FROM sys_user_role WHERE role_id in ?1", nativeQuery = true)
|
||||
public Integer cancelUserJoin(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 取消角色与菜单之间的关系
|
||||
* @param ids 角色ID
|
||||
* @return 影响结果
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query(value = "DELETE FROM sys_role_menu WHERE role_id in ?1", nativeQuery = true)
|
||||
public Integer cancelMenuJoin(List<Long> ids);
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.modules.system.domain.Upload;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/11/02
|
||||
*/
|
||||
public interface UploadRepository extends JpaRepository<Upload, Long> {
|
||||
|
||||
/**
|
||||
* 查找指定文件sha1记录
|
||||
* @param sha1 文件sha1值
|
||||
* @return 文件信息
|
||||
*/
|
||||
public Upload findBySha1(String sha1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.linln.modules.system.repository;
|
||||
|
||||
import com.linln.modules.system.domain.Dept;
|
||||
import com.linln.modules.system.domain.User;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface UserRepository extends BaseRepository<User, Long>, JpaSpecificationExecutor<User> {
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户数据
|
||||
* @param username 用户名
|
||||
* @return 用户数据
|
||||
*/
|
||||
public User findByUsername(String username);
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户数据,且排查指定ID的用户
|
||||
* @param username 用户名
|
||||
* @param id 排除的用户ID
|
||||
* @return 用户数据
|
||||
*/
|
||||
public User findByUsernameAndIdNot(String username, Long id);
|
||||
|
||||
/**
|
||||
* 查找多个相应部门的用户列表
|
||||
* @param dept 部门对象
|
||||
* @return 用户列表
|
||||
*/
|
||||
public List<User> findByDept(Dept dept);
|
||||
|
||||
/**
|
||||
* 删除多条数据
|
||||
* @param ids ID列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
public Integer deleteByIdIn(List<Long> ids);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.linln.modules.system.service;
|
||||
|
||||
import com.linln.modules.system.domain.ActionLog;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/10/19
|
||||
*/
|
||||
public interface ActionLogService {
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
Page<ActionLog> getPageList(Example<ActionLog> example);
|
||||
|
||||
/**
|
||||
* 根据日志ID查询日志数据
|
||||
* @param id 日志ID
|
||||
* @return 日志数据
|
||||
*/
|
||||
ActionLog getById(Long id);
|
||||
|
||||
/**
|
||||
* 获取数据的日志列表
|
||||
* @param model 模型(表名)
|
||||
* @param recordId 数据ID
|
||||
* @return 日志列表
|
||||
*/
|
||||
List<ActionLog> getDataLogList(String model, Long recordId);
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
* @param actionLog 日志实体类
|
||||
* @return 日志信息
|
||||
*/
|
||||
ActionLog save(ActionLog actionLog);
|
||||
|
||||
/**
|
||||
* 删除指指定ID日志
|
||||
* @param id 日志ID
|
||||
*/
|
||||
void deleteId(Long id);
|
||||
|
||||
/**
|
||||
* 清空日志
|
||||
*/
|
||||
@Transactional
|
||||
void emptyLog();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.linln.modules.system.service;
|
||||
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.Dept;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/12/02
|
||||
*/
|
||||
public interface DeptService {
|
||||
|
||||
/**
|
||||
* 获取部门列表数据
|
||||
* @param example 查询实例
|
||||
* @param sort 排序对象
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<Dept> getListByExample(Example<Dept> example, Sort sort);
|
||||
|
||||
/**
|
||||
* 获取排序最大值
|
||||
* @param pid 父菜单ID
|
||||
* @return 最大值
|
||||
*/
|
||||
Integer getSortMax(Long pid);
|
||||
|
||||
/**
|
||||
* 根据父级部门ID获取本级全部部门
|
||||
* @param pid 父部门ID
|
||||
* @param notId 需要排除的部门ID
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<Dept> getListByPid(Long pid, Long notId);
|
||||
|
||||
/**
|
||||
* 保存多个部门
|
||||
* @param deptList 部门实体类列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<Dept> save(List<Dept> deptList);
|
||||
|
||||
/**
|
||||
* 根据部门管理ID查询部门管理数据
|
||||
* @param id 部门管理ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
Dept getById(Long id);
|
||||
|
||||
/**
|
||||
* 根据ID查找子孙部门
|
||||
* @param id [id]形式
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<Dept> getListByPidLikeOk(Long id);
|
||||
|
||||
/**
|
||||
* 保存部门管理
|
||||
* @param dept 部门管理实体类
|
||||
* @return 部门信息
|
||||
*/
|
||||
Dept save(Dept dept);
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
* @param statusEnum 数据状态
|
||||
* @param idList 数据ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Transactional
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.linln.modules.system.service;
|
||||
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.Dict;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface DictService {
|
||||
|
||||
/**
|
||||
* 根据字典标识获取字典数据
|
||||
* @param name 字典标识
|
||||
* @return 字典信息
|
||||
*/
|
||||
Dict getByNameOk(String name);
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
Page<Dict> getPageList(Example<Dict> example);
|
||||
|
||||
/**
|
||||
* 根据字典ID查询字典数据
|
||||
* @param id 字典ID
|
||||
* @return 字典信息
|
||||
*/
|
||||
Dict getById(Long id);
|
||||
|
||||
/**
|
||||
* 字典标识是否重复
|
||||
* @param dict 字典实体类
|
||||
* @return 是否重复
|
||||
*/
|
||||
boolean repeatByName(Dict dict);
|
||||
|
||||
/**
|
||||
* 保存字典
|
||||
* @param dict 字典实体类
|
||||
* @return 字典信息
|
||||
*/
|
||||
Dict save(Dict dict);
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
* @param statusEnum 数据状态
|
||||
* @param idList 数据ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Transactional
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.linln.modules.system.service;
|
||||
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.Menu;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface MenuService {
|
||||
|
||||
/**
|
||||
* 获取菜单列表数据
|
||||
* @param example 查询实例
|
||||
* @param sort 排序对象
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<Menu> getListByExample(Example<Menu> example, Sort sort);
|
||||
|
||||
/**
|
||||
* 根据菜单对象的Example判断是否存在
|
||||
* @param menu 菜单对象
|
||||
* @return 菜单信息
|
||||
*/
|
||||
Menu getByMenuToExample(Menu menu);
|
||||
|
||||
/**
|
||||
* 根据菜单ID查询菜单数据
|
||||
* @param id 菜单ID
|
||||
* @return 菜单信息
|
||||
*/
|
||||
Menu getById(Long id);
|
||||
|
||||
/**
|
||||
* 根据菜单url查询菜单数据
|
||||
* @param url 菜单url
|
||||
* @return 菜单信息
|
||||
*/
|
||||
Menu getByUrl(String url);
|
||||
|
||||
/**
|
||||
* 获取菜单列表数据
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<Menu> getListBySortOk();
|
||||
|
||||
/**
|
||||
* 获取排序最大值
|
||||
* @param pid 父菜单ID
|
||||
* @return 最大值
|
||||
*/
|
||||
Integer getSortMax(Long pid);
|
||||
|
||||
/**
|
||||
* 根据父级菜单ID获取本级全部菜单
|
||||
* @param pid 父菜单ID
|
||||
* @param notId 需要排除的菜单ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<Menu> getListByPid(Long pid, Long notId);
|
||||
|
||||
/**
|
||||
* 保存菜单
|
||||
* @param menu 菜单实体类
|
||||
* @return 菜单信息
|
||||
*/
|
||||
Menu save(Menu menu);
|
||||
|
||||
/**
|
||||
* 保存多个菜单
|
||||
* @param menuList 菜单实体类列表
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<Menu> save(List<Menu> menuList);
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
* @param statusEnum 数据状态
|
||||
* @param idList 数据ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Transactional
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.linln.modules.system.service;
|
||||
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.Role;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface RoleService {
|
||||
|
||||
/**
|
||||
* 获取用户角色列表
|
||||
* @param id 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Transactional
|
||||
Set<Role> getUserOkRoleList(Long id);
|
||||
|
||||
/**
|
||||
* 判断指定的用户是否存在角色
|
||||
* @param id 用户ID
|
||||
* @return 是否存在角色
|
||||
*/
|
||||
Boolean existsUserOk(Long id);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询角色数据
|
||||
* @param id 角色ID
|
||||
* @return 角色信息
|
||||
*/
|
||||
@Transactional
|
||||
Role getById(Long id);
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
Page<Role> getPageList(Example<Role> example);
|
||||
|
||||
/**
|
||||
* 获取角色列表数据
|
||||
* @param sort 排序对象
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<Role> getListBySortOk(Sort sort);
|
||||
|
||||
/**
|
||||
* 角色标识是否重复
|
||||
* @param role 角色实体类
|
||||
* @return 标识是否重复
|
||||
*/
|
||||
boolean repeatByName(Role role);
|
||||
|
||||
/**
|
||||
* 保存角色
|
||||
* @param role 角色实体类
|
||||
* @return 角色信息
|
||||
*/
|
||||
Role save(Role role);
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
* @param statusEnum 数据状态
|
||||
* @param idList 数据ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Transactional
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.linln.modules.system.service;
|
||||
|
||||
import com.linln.modules.system.domain.Upload;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/11/02
|
||||
*/
|
||||
public interface UploadService {
|
||||
|
||||
/**
|
||||
* 获取文件sha1值的记录
|
||||
* @param sha1 文件sha1值
|
||||
* @return 文件信息
|
||||
*/
|
||||
Upload getBySha1(String sha1);
|
||||
|
||||
/**
|
||||
* 保存文件上传
|
||||
* @param upload 文件上传实体类
|
||||
* @return 文件信息
|
||||
*/
|
||||
Upload save(Upload upload);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.linln.modules.system.service;
|
||||
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.User;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
public interface UserService {
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param user 实体对象
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
Page<User> getPageList(User user);
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
* @param user 用户实体类
|
||||
* @return 用户信息
|
||||
*/
|
||||
User save(User user);
|
||||
|
||||
/**
|
||||
* 保存用户列表
|
||||
* @param userList 用户实体类
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<User> save(List<User> userList);
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户数据
|
||||
* @param username 用户名
|
||||
* @return 用户数据
|
||||
*/
|
||||
User getByName(String username);
|
||||
|
||||
/**
|
||||
* 用户名是否重复
|
||||
* @param user 用户对象
|
||||
* @return 用户数据
|
||||
*/
|
||||
Boolean repeatByUsername(User user);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询用户数据
|
||||
* @param id 用户ID
|
||||
* @return 用户信息
|
||||
*/
|
||||
User getById(Long id);
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
* @param statusEnum 数据状态
|
||||
* @param idList 数据ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Transactional
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
|
||||
int userCount();
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.linln.modules.system.service.impl;
|
||||
|
||||
import com.linln.common.data.PageSort;
|
||||
import com.linln.modules.system.domain.ActionLog;
|
||||
import com.linln.modules.system.repository.ActionLogRepository;
|
||||
import com.linln.modules.system.service.ActionLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/10/19
|
||||
*/
|
||||
@Service
|
||||
public class ActionLogServiceImpl implements ActionLogService {
|
||||
|
||||
@Autowired
|
||||
private ActionLogRepository actionLogRepository;
|
||||
|
||||
/**
|
||||
* 根据日志ID查询日志数据
|
||||
* @param id 日志ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public ActionLog getById(Long id) {
|
||||
return actionLogRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
@Override
|
||||
public Page<ActionLog> getPageList(Example<ActionLog> example) {
|
||||
// 创建分页对象
|
||||
PageRequest page = PageSort.pageRequest();
|
||||
return actionLogRepository.findAll(example, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据的日志列表
|
||||
* @param model 模型(表名)
|
||||
* @param recordId 数据ID
|
||||
*/
|
||||
@Override
|
||||
public List<ActionLog> getDataLogList(String model, Long recordId){
|
||||
return actionLogRepository.findByModelAndRecordId(model, recordId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
* @param actionLog 日志实体类
|
||||
*/
|
||||
@Override
|
||||
public ActionLog save(ActionLog actionLog){
|
||||
return actionLogRepository.save(actionLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指指定ID日志
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteId(Long id){
|
||||
actionLogRepository.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空日志
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void emptyLog(){
|
||||
actionLogRepository.deleteAll();
|
||||
}
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package com.linln.modules.system.service.impl;
|
||||
|
||||
import com.linln.common.enums.ResultEnum;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.exception.ResultException;
|
||||
import com.linln.modules.system.domain.Dept;
|
||||
import com.linln.modules.system.domain.User;
|
||||
import com.linln.modules.system.repository.DeptRepository;
|
||||
import com.linln.modules.system.repository.UserRepository;
|
||||
import com.linln.modules.system.service.DeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/12/02
|
||||
*/
|
||||
@Service
|
||||
public class DeptServiceImpl implements DeptService {
|
||||
|
||||
@Autowired
|
||||
private DeptRepository deptRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
/**
|
||||
* 根据部门管理ID查询部门管理数据
|
||||
* @param id 部门管理ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Dept getById(Long id) {
|
||||
return deptRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门列表数据
|
||||
* @param example 查询实例
|
||||
* @param sort 排序对象
|
||||
*/
|
||||
@Override
|
||||
public List<Dept> getListByExample(Example<Dept> example, Sort sort) {
|
||||
return deptRepository.findAll(example, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排序最大值
|
||||
* @param pid 父菜单ID
|
||||
*/
|
||||
@Override
|
||||
public Integer getSortMax(Long pid){
|
||||
return deptRepository.findSortMax(pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级部门ID获取本级全部部门
|
||||
* @param pid 父部门ID
|
||||
* @param notId 需要排除的部门ID
|
||||
*/
|
||||
@Override
|
||||
public List<Dept> getListByPid(Long pid, Long notId){
|
||||
Sort sort = Sort.by(Sort.Direction.ASC, "sort");
|
||||
return deptRepository.findByPidAndIdNot(sort, pid, notId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查找子孙部门
|
||||
* @param id [id]形式
|
||||
*/
|
||||
@Override
|
||||
public List<Dept> getListByPidLikeOk(Long id){
|
||||
return deptRepository.findByPidsLikeAndStatus("%["+id+"]%", StatusEnum.OK.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存部门管理
|
||||
* @param dept 部门管理实体类
|
||||
*/
|
||||
@Override
|
||||
public Dept save(Dept dept){
|
||||
return deptRepository.save(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存多个部门
|
||||
* @param deptList 部门实体类列表
|
||||
*/
|
||||
@Override
|
||||
public List<Dept> save(List<Dept> deptList){
|
||||
return deptRepository.saveAll(deptList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateStatus(StatusEnum statusEnum, List<Long> ids){
|
||||
// 获取与之关联的所有部门
|
||||
Set<Dept> treeDepts = new HashSet<>();
|
||||
List<Dept> depts = deptRepository.findByIdIn(ids);
|
||||
depts.forEach(dept -> {
|
||||
treeDepts.add(dept);
|
||||
treeDepts.addAll(deptRepository.findByPidsLikeAndStatus("%[" + dept.getId() + "]%", dept.getStatus()));
|
||||
});
|
||||
|
||||
treeDepts.forEach(dept -> {
|
||||
if(statusEnum == StatusEnum.DELETE){
|
||||
List<User> users = userRepository.findByDept(dept);
|
||||
if(users.size() > 0){
|
||||
throw new ResultException(ResultEnum.DEPT_EXIST_USER);
|
||||
}
|
||||
}
|
||||
// 更新关联的所有部门状态
|
||||
dept.setStatus(statusEnum.getCode());
|
||||
});
|
||||
|
||||
return treeDepts.size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.linln.modules.system.service.impl;
|
||||
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.data.PageSort;
|
||||
import com.linln.modules.system.domain.Dict;
|
||||
import com.linln.modules.system.repository.DictRepository;
|
||||
import com.linln.modules.system.service.DictService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Service
|
||||
public class DictServiceImpl implements DictService {
|
||||
|
||||
@Autowired
|
||||
private DictRepository dictRepository;
|
||||
|
||||
/**
|
||||
* 根据字典ID查询字典数据
|
||||
* @param id 字典ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Dict getById(Long id) {
|
||||
return dictRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典标识获取字典数据
|
||||
* @param name 字典标识
|
||||
*/
|
||||
@Override
|
||||
public Dict getByNameOk(String name){
|
||||
return dictRepository.findByNameAndStatus(name, StatusEnum.OK.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
@Override
|
||||
public Page<Dict> getPageList(Example<Dict> example) {
|
||||
// 创建分页对象
|
||||
PageRequest page = PageSort.pageRequest();
|
||||
return dictRepository.findAll(example, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典标识是否重复
|
||||
* @param dict 字典实体类
|
||||
*/
|
||||
@Override
|
||||
public boolean repeatByName(Dict dict) {
|
||||
Long id = dict.getId() != null ? dict.getId() : Long.MIN_VALUE;
|
||||
return dictRepository.findByNameAndIdNot(dict.getName(), id) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存字典
|
||||
* @param dict 字典实体类
|
||||
*/
|
||||
@Override
|
||||
public Dict save(Dict dict){
|
||||
return dictRepository.save(dict);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateStatus(StatusEnum statusEnum, List<Long> idList){
|
||||
return dictRepository.updateStatus(statusEnum.getCode(),idList) > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package com.linln.modules.system.service.impl;
|
||||
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.Menu;
|
||||
import com.linln.modules.system.repository.MenuRepository;
|
||||
import com.linln.modules.system.service.MenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Service
|
||||
public class MenuServiceImpl implements MenuService {
|
||||
|
||||
@Autowired
|
||||
private MenuRepository menuRepository;
|
||||
|
||||
/**
|
||||
* 根据菜单ID查询菜单数据
|
||||
* @param id 菜单ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Menu getById(Long id) {
|
||||
if (id == 0L){
|
||||
return new Menu(id, "顶级菜单", "");
|
||||
}
|
||||
return menuRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据菜单url查询菜单数据
|
||||
* @param url 菜单url
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Menu getByUrl(String url){
|
||||
return menuRepository.findByUrl(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表数据
|
||||
* @param example 查询实例
|
||||
* @param sort 排序对象
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> getListByExample(Example<Menu> example, Sort sort) {
|
||||
return menuRepository.findAll(example, sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据菜单对象的Example判断是否存在
|
||||
* @param menu 菜单对象
|
||||
*/
|
||||
@Override
|
||||
public Menu getByMenuToExample(Menu menu) {
|
||||
return menuRepository.findOne(Example.of(menu)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表数据
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> getListBySortOk() {
|
||||
Sort sort = Sort.by(Sort.Direction.ASC, "type", "sort");
|
||||
return menuRepository.findAllByStatus(sort, StatusEnum.OK.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取排序最大值
|
||||
* @param pid 父菜单ID
|
||||
*/
|
||||
@Override
|
||||
public Integer getSortMax(Long pid){
|
||||
return menuRepository.findSortMax(pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级菜单ID获取本级全部菜单
|
||||
* @param pid 父菜单ID
|
||||
* @param notId 需要排除的菜单ID
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> getListByPid(Long pid, Long notId){
|
||||
Sort sort = Sort.by(Sort.Direction.ASC, "sort");
|
||||
return menuRepository.findByPidAndIdNot(sort, pid, notId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存菜单
|
||||
* @param menu 菜单实体类
|
||||
*/
|
||||
@Override
|
||||
public Menu save(Menu menu){
|
||||
return menuRepository.save(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存多个菜单
|
||||
* @param menuList 菜单实体类列表
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> save(List<Menu> menuList){
|
||||
return menuRepository.saveAll(menuList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateStatus(StatusEnum statusEnum, List<Long> ids){
|
||||
// 获取与之关联的所有菜单
|
||||
Set<Menu> treeMenus = new HashSet<>();
|
||||
List<Menu> menus = menuRepository.findByIdIn(ids);
|
||||
menus.forEach(menu -> {
|
||||
treeMenus.add(menu);
|
||||
treeMenus.addAll(menuRepository.findByPidsLikeAndStatus("%[" + menu.getId() + "]%", menu.getStatus()));
|
||||
});
|
||||
|
||||
treeMenus.forEach(menu -> {
|
||||
// 删除菜单状态时,同时更新角色的权限
|
||||
if(statusEnum == StatusEnum.DELETE){
|
||||
// 非规范的Jpa操作,直接采用SQL语句
|
||||
menuRepository.cancelRoleJoin(menu.getId());
|
||||
}
|
||||
// 更新关联的所有菜单状态
|
||||
menu.setStatus(statusEnum.getCode());
|
||||
});
|
||||
|
||||
return treeMenus.size() > 0;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
package com.linln.modules.system.service.impl;
|
||||
|
||||
import com.linln.common.data.PageSort;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.Role;
|
||||
import com.linln.modules.system.repository.RoleRepository;
|
||||
import com.linln.modules.system.service.RoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
/**
|
||||
* 获取用户角色列表
|
||||
* @param id 用户ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Set<Role> getUserOkRoleList(Long id) {
|
||||
Byte status = StatusEnum.OK.getCode();
|
||||
return roleRepository.findByUsers_IdAndStatus(id, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断指定的用户是否存在角色
|
||||
* @param id 用户ID
|
||||
*/
|
||||
@Override
|
||||
public Boolean existsUserOk(Long id) {
|
||||
Byte status = StatusEnum.OK.getCode();
|
||||
return roleRepository.existsByUsers_IdAndStatus(id, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询角色数据
|
||||
* @param id 角色ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Role getById(Long id) {
|
||||
return roleRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
@Override
|
||||
public Page<Role> getPageList(Example<Role> example) {
|
||||
// 创建分页对象
|
||||
PageRequest page = PageSort.pageRequest(Sort.Direction.ASC);
|
||||
return roleRepository.findAll(example, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色列表数据
|
||||
* @param sort 排序对象
|
||||
*/
|
||||
@Override
|
||||
public List<Role> getListBySortOk(Sort sort) {
|
||||
return roleRepository.findAllByStatus(sort, StatusEnum.OK.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色标识是否重复
|
||||
* @param role 角色实体类
|
||||
*/
|
||||
@Override
|
||||
public boolean repeatByName(Role role) {
|
||||
Long id = role.getId() != null ? role.getId() : Long.MIN_VALUE;
|
||||
return roleRepository.findByNameAndIdNot(role.getName(), id) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色
|
||||
* @param role 角色实体类
|
||||
*/
|
||||
@Override
|
||||
public Role save(Role role){
|
||||
return roleRepository.save(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateStatus(StatusEnum statusEnum, List<Long> ids){
|
||||
// 删除角色时取消与角色和菜单的关联
|
||||
if(statusEnum == StatusEnum.DELETE){
|
||||
// 非规范的Jpa操作,直接采用SQL语句
|
||||
roleRepository.cancelUserJoin(ids);
|
||||
roleRepository.cancelMenuJoin(ids);
|
||||
}
|
||||
return roleRepository.updateStatus(statusEnum.getCode(), ids) > 0;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.linln.modules.system.service.impl;
|
||||
|
||||
import com.linln.modules.system.domain.Upload;
|
||||
import com.linln.modules.system.repository.UploadRepository;
|
||||
import com.linln.modules.system.service.UploadService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/11/02
|
||||
*/
|
||||
@Service
|
||||
public class UploadServiceImpl implements UploadService {
|
||||
|
||||
@Autowired
|
||||
private UploadRepository uploadRepository;
|
||||
|
||||
/**
|
||||
* 获取文件sha1值的记录
|
||||
*/
|
||||
@Override
|
||||
public Upload getBySha1(String sha1) {
|
||||
return uploadRepository.findBySha1(sha1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件上传
|
||||
* @param upload 文件上传实体类
|
||||
*/
|
||||
@Override
|
||||
public Upload save(Upload upload){
|
||||
return uploadRepository.save(upload);
|
||||
}
|
||||
}
|
||||
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
package com.linln.modules.system.service.impl;
|
||||
|
||||
import com.linln.common.data.PageSort;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.modules.system.domain.Dept;
|
||||
import com.linln.modules.system.domain.User;
|
||||
import com.linln.modules.system.repository.UserRepository;
|
||||
import com.linln.modules.system.service.DeptService;
|
||||
import com.linln.modules.system.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.criteria.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2018/8/14
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private DeptService deptService;
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户数据
|
||||
* @param username 用户名
|
||||
* @return 用户数据
|
||||
*/
|
||||
@Override
|
||||
public User getByName(String username) {
|
||||
return userRepository.findByUsername(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户名是否存在
|
||||
* @param user 用户对象
|
||||
* @return 用户数据
|
||||
*/
|
||||
@Override
|
||||
public Boolean repeatByUsername(User user) {
|
||||
Long id = user.getId() != null ? user.getId() : Long.MIN_VALUE;
|
||||
return userRepository.findByUsernameAndIdNot(user.getUsername(), id) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取用户信息
|
||||
* @param id 用户ID
|
||||
*/
|
||||
@Override
|
||||
public User getById(Long id) {
|
||||
return userRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param user 实体对象
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Page<User> getPageList(User user) {
|
||||
// 创建分页对象
|
||||
PageRequest page = PageSort.pageRequest(Sort.Direction.ASC);
|
||||
|
||||
// 使用Specification复杂查询
|
||||
return userRepository.findAll(new Specification<User>(){
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
||||
List<Predicate> preList = new ArrayList<>();
|
||||
if(user.getId() != null){
|
||||
preList.add(cb.equal(root.get("id").as(Long.class), user.getId()));
|
||||
}
|
||||
if(user.getUsername() != null){
|
||||
preList.add(cb.equal(root.get("username").as(String.class), user.getUsername()));
|
||||
}
|
||||
if(user.getNickname() != null){
|
||||
preList.add(cb.like(root.get("nickname").as(String.class), "%"+ user.getNickname() + "%"));
|
||||
}
|
||||
if(user.getDept() != null){
|
||||
// 联级查询部门
|
||||
Dept dept = user.getDept();
|
||||
List<Long> deptIn = new ArrayList<>();
|
||||
deptIn.add(dept.getId());
|
||||
List<Dept> deptList = deptService.getListByPidLikeOk(dept.getId());
|
||||
deptList.forEach(item -> deptIn.add(item.getId()));
|
||||
|
||||
Join<User, Dept> join = root.join("dept", JoinType.INNER);
|
||||
CriteriaBuilder.In<Long> in = cb.in(join.get("id").as(Long.class));
|
||||
deptIn.forEach(in::value);
|
||||
preList.add(in);
|
||||
}
|
||||
|
||||
// 数据状态
|
||||
if(user.getStatus() != null){
|
||||
preList.add(cb.equal(root.get("status").as(Byte.class), user.getStatus()));
|
||||
}
|
||||
|
||||
Predicate[] pres = new Predicate[preList.size()];
|
||||
return query.where(preList.toArray(pres)).getRestriction();
|
||||
}
|
||||
|
||||
}, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
* @param user 用户实体类
|
||||
*/
|
||||
@Override
|
||||
public User save(User user){
|
||||
return userRepository.save(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户列表
|
||||
* @param userList 用户实体类
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public List<User> save(List<User> userList){
|
||||
return userRepository.saveAll(userList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateStatus(StatusEnum statusEnum, List<Long> ids){
|
||||
// 联级删除与角色之间的关联
|
||||
if(statusEnum == StatusEnum.DELETE){
|
||||
return userRepository.deleteByIdIn(ids) > 0;
|
||||
}
|
||||
return userRepository.updateStatus(statusEnum.getCode(), ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int userCount() {
|
||||
return userRepository.findAll().size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.linln.modules.system.config.SystemAutoConfig
|
||||
Reference in New Issue
Block a user