Commit 7c35a79c authored by ZhengJie's avatar ZhengJie
Browse files

[新增功能](el-admin v2.5): v2.5 beta

详情 https://www.ydyno.com/archives/1225.html
parent d35ffc9d
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.security.service; package me.zhengjie.modules.security.service;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -14,14 +29,14 @@ import java.util.*; ...@@ -14,14 +29,14 @@ import java.util.*;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @Date 2019年10月26日21:56:27 * @date 2019年10月26日21:56:27
*/ */
@Service @Service
@Slf4j @Slf4j
public class OnlineUserService { public class OnlineUserService {
private final SecurityProperties properties; private final SecurityProperties properties;
private RedisUtils redisUtils; private final RedisUtils redisUtils;
public OnlineUserService(SecurityProperties properties, RedisUtils redisUtils) { public OnlineUserService(SecurityProperties properties, RedisUtils redisUtils) {
this.properties = properties; this.properties = properties;
...@@ -35,13 +50,13 @@ public class OnlineUserService { ...@@ -35,13 +50,13 @@ public class OnlineUserService {
* @param request / * @param request /
*/ */
public void save(JwtUserDto jwtUserDto, String token, HttpServletRequest request){ public void save(JwtUserDto jwtUserDto, String token, HttpServletRequest request){
String job = jwtUserDto.getUser().getDept().getName() + "/" + jwtUserDto.getUser().getJob().getName(); String dept = jwtUserDto.getUser().getDept().getName();
String ip = StringUtils.getIp(request); String ip = StringUtils.getIp(request);
String browser = StringUtils.getBrowser(request); String browser = StringUtils.getBrowser(request);
String address = StringUtils.getCityInfo(ip); String address = StringUtils.getCityInfo(ip);
OnlineUserDto onlineUserDto = null; OnlineUserDto onlineUserDto = null;
try { try {
onlineUserDto = new OnlineUserDto(jwtUserDto.getUsername(), jwtUserDto.getUser().getNickName(), job, browser , ip, address, EncryptUtils.desEncrypt(token), new Date()); onlineUserDto = new OnlineUserDto(jwtUserDto.getUsername(), jwtUserDto.getUser().getNickName(), dept, browser , ip, address, EncryptUtils.desEncrypt(token), new Date());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -114,7 +129,7 @@ public class OnlineUserService { ...@@ -114,7 +129,7 @@ public class OnlineUserService {
for (OnlineUserDto user : all) { for (OnlineUserDto user : all) {
Map<String,Object> map = new LinkedHashMap<>(); Map<String,Object> map = new LinkedHashMap<>();
map.put("用户名", user.getUserName()); map.put("用户名", user.getUserName());
map.put("岗位", user.getJob()); map.put("部门", user.getDept());
map.put("登录IP", user.getIp()); map.put("登录IP", user.getIp());
map.put("登录地点", user.getAddress()); map.put("登录地点", user.getAddress());
map.put("浏览器", user.getBrowser()); map.put("浏览器", user.getBrowser());
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.security.service; package me.zhengjie.modules.security.service;
import lombok.RequiredArgsConstructor;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.exception.EntityNotFoundException; import me.zhengjie.exception.EntityNotFoundException;
import me.zhengjie.modules.security.service.dto.JwtUserDto; import me.zhengjie.modules.security.service.dto.JwtUserDto;
...@@ -16,19 +32,14 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -16,19 +32,14 @@ import org.springframework.transaction.annotation.Transactional;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-11-22 * @date 2018-11-22
*/ */
@RequiredArgsConstructor
@Service("userDetailsService") @Service("userDetailsService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserDetailsServiceImpl implements UserDetailsService { public class UserDetailsServiceImpl implements UserDetailsService {
private final UserService userService; private final UserService userService;
private final RoleService roleService; private final RoleService roleService;
public UserDetailsServiceImpl(UserService userService, RoleService roleService) {
this.userService = userService;
this.roleService = roleService;
}
@Override @Override
public JwtUserDto loadUserByUsername(String username) { public JwtUserDto loadUserByUsername(String username) {
UserDto user; UserDto user;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.security.service.dto; package me.zhengjie.modules.security.service.dto;
import lombok.Getter; import lombok.Getter;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.security.service.dto; package me.zhengjie.modules.security.service.dto;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.security.service.dto; package me.zhengjie.modules.security.service.dto;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -27,7 +42,7 @@ public class OnlineUserDto { ...@@ -27,7 +42,7 @@ public class OnlineUserDto {
/** /**
* 岗位 * 岗位
*/ */
private String job; private String dept;
/** /**
* 浏览器 * 浏览器
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp; import me.zhengjie.base.BaseEntity;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
...@@ -19,36 +34,33 @@ import java.util.Set; ...@@ -19,36 +34,33 @@ import java.util.Set;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@Table(name="dept") @Table(name="sys_dept")
public class Dept implements Serializable { public class Dept extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "dept_id")
@Column(name = "id")
@NotNull(groups = Update.class) @NotNull(groups = Update.class)
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Column(name = "name",nullable = false) @JsonIgnore
@ManyToMany(mappedBy = "depts")
@ApiModelProperty(value = "角色")
private Set<Role> roles;
@NotBlank @NotBlank
@ApiModelProperty(value = "部门名称")
private String name; private String name;
@NotNull @NotNull
@ApiModelProperty(value = "是否启用")
private Boolean enabled; private Boolean enabled;
@Column(name = "pid",nullable = false)
@NotNull @NotNull
@ApiModelProperty(value = "上级部门")
private Long pid; private Long pid;
@JsonIgnore
@ManyToMany(mappedBy = "depts")
private Set<Role> roles;
@Column(name = "create_time")
@CreationTimestamp
private Timestamp createTime;
public @interface Update {}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.zhengjie.base.BaseEntity; import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List; import java.util.List;
/** /**
...@@ -18,28 +32,23 @@ import java.util.List; ...@@ -18,28 +32,23 @@ import java.util.List;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@Table(name="dict") @Table(name="sys_dict")
public class Dict implements Serializable { public class Dict extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "dict_id")
@Column(name = "id")
@NotNull(groups = Update.class) @NotNull(groups = Update.class)
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Column(name = "name",nullable = false,unique = true)
@NotBlank
private String name;
@Column(name = "remark")
private String remark;
@Column(name = "create_time")
@CreationTimestamp
private Timestamp createTime;
@OneToMany(mappedBy = "dict",cascade={CascadeType.PERSIST,CascadeType.REMOVE}) @OneToMany(mappedBy = "dict",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
private List<DictDetail> dictDetails; private List<DictDetail> dictDetails;
public @interface Update {} @NotBlank
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "描述")
private String description;
} }
\ No newline at end of file
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp; import me.zhengjie.base.BaseEntity;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
/** /**
* @author Zheng Jie * @author Zheng Jie
...@@ -15,34 +30,27 @@ import java.sql.Timestamp; ...@@ -15,34 +30,27 @@ import java.sql.Timestamp;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@Table(name="dict_detail") @Table(name="sys_dict_detail")
public class DictDetail implements Serializable { public class DictDetail extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "detail_id")
@Column(name = "id")
@NotNull(groups = Update.class) @NotNull(groups = Update.class)
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
/** 字典标签 */
@Column(name = "label",nullable = false)
private String label;
/** 字典值 */
@Column(name = "value",nullable = false)
private String value;
/** 排序 */
@Column(name = "sort")
private Integer sort = 999;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "dict_id") @JoinColumn(name = "dict_id")
@ManyToOne(fetch=FetchType.LAZY)
@ApiModelProperty(value = "字典", hidden = true)
private Dict dict; private Dict dict;
@Column(name = "create_time") @ApiModelProperty(value = "字典标签")
@CreationTimestamp private String label;
private Timestamp createTime;
@ApiModelProperty(value = "字典值")
private String value;
public @interface Update {} @ApiModelProperty(value = "排序")
private Integer dictSort = 999;
} }
\ No newline at end of file
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp; import me.zhengjie.base.BaseEntity;
import javax.persistence.*; import javax.persistence.*;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
/** /**
* @author Zheng Jie * @author Zheng Jie
...@@ -18,34 +33,25 @@ import java.sql.Timestamp; ...@@ -18,34 +33,25 @@ import java.sql.Timestamp;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@Table(name="job") @Table(name="sys_job")
public class Job implements Serializable { public class Job extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "job_id")
@Column(name = "id")
@NotNull(groups = Update.class) @NotNull(groups = Update.class)
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Column(name = "name",nullable = false)
@NotBlank @NotBlank
@ApiModelProperty(value = "岗位名称")
private String name; private String name;
@Column(unique = true)
@NotNull @NotNull
private Long sort; @ApiModelProperty(value = "岗位排序")
private Long jobSort;
@Column(name = "enabled",nullable = false)
@NotNull @NotNull
@ApiModelProperty(value = "是否启用")
private Boolean enabled; private Boolean enabled;
@OneToOne
@JoinColumn(name = "dept_id")
private Dept dept;
@Column(name = "create_time")
@CreationTimestamp
private Timestamp createTime;
public @interface Update {}
} }
\ No newline at end of file
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
...@@ -19,62 +36,61 @@ import java.util.Set; ...@@ -19,62 +36,61 @@ import java.util.Set;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@Table(name = "menu") @Table(name = "sys_menu")
public class Menu implements Serializable { public class Menu extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "menu_id")
@NotNull(groups = {Update.class}) @NotNull(groups = {Update.class})
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@JsonIgnore
@ManyToMany(mappedBy = "menus")
@ApiModelProperty(value = "菜单角色")
private Set<Role> roles;
@NotBlank @NotBlank
private String name; @ApiModelProperty(value = "菜单标题")
private String title;
@Column(unique = true) @Column(name = "name")
private Long sort = 999L; @ApiModelProperty(value = "菜单组件名称")
private String componentName;
@Column(name = "path") @ApiModelProperty(value = "排序")
private String path; private Integer menuSort = 999;
@ApiModelProperty(value = "组件路径")
private String component; private String component;
/** 类型,目录、菜单、按钮 */ @ApiModelProperty(value = "路由地址")
@Column(name = "type") private String path;
@ApiModelProperty(value = "菜单类型,目录、菜单、按钮")
private Integer type; private Integer type;
/** 权限 */ @ApiModelProperty(value = "权限标识")
@Column(name = "permission")
private String permission; private String permission;
@Column(unique = true,name = "component_name") @ApiModelProperty(value = "菜单图标")
private String componentName;
private String icon; private String icon;
@Column(columnDefinition = "bit(1) default 0") @Column(columnDefinition = "bit(1) default 0")
@ApiModelProperty(value = "缓存")
private Boolean cache; private Boolean cache;
@Column(columnDefinition = "bit(1) default 0") @Column(columnDefinition = "bit(1) default 0")
@ApiModelProperty(value = "是否隐藏")
private Boolean hidden; private Boolean hidden;
/** 上级菜单ID */ @ApiModelProperty(value = "上级菜单")
@Column(name = "pid",nullable = false)
private Long pid; private Long pid;
/** 是否为外链 true/false */ @ApiModelProperty(value = "外链菜单")
@Column(name = "i_frame")
private Boolean iFrame; private Boolean iFrame;
@ManyToMany(mappedBy = "menus")
@JsonIgnore
private Set<Role> roles;
@Column(name = "create_time")
@CreationTimestamp
private Timestamp createTime;
public @interface Update {}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
...@@ -17,53 +34,51 @@ import java.util.Set; ...@@ -17,53 +34,51 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-11-22 * @date 2018-11-22
*/ */
@Entity
@Table(name = "role")
@Getter @Getter
@Setter @Setter
public class Role implements Serializable { @Entity
@Table(name = "sys_role")
public class Role extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "role_id")
@NotNull(groups = {Update.class}) @NotNull(groups = {Update.class})
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value = "ID", hidden = true)
private Long id; private Long id;
@Column(nullable = false)
@NotBlank
private String name;
/** 数据权限类型 全部 、 本级 、 自定义 */
@Column(name = "data_scope")
private String dataScope = "本级";
/** 数值越小,级别越大 */
@Column(name = "level")
private Integer level = 3;
@Column
private String remark;
/** 权限 */
@Column(name = "permission")
private String permission;
@JsonIgnore @JsonIgnore
@ManyToMany(mappedBy = "roles") @ManyToMany(mappedBy = "roles")
@ApiModelProperty(value = "用户", hidden = true)
private Set<User> users; private Set<User> users;
@ManyToMany @ManyToMany
@JoinTable(name = "roles_menus", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")}) @JoinTable(name = "sys_roles_menus",
joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")},
inverseJoinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "menu_id")})
@ApiModelProperty(value = "菜单", hidden = true)
private Set<Menu> menus; private Set<Menu> menus;
@ManyToMany @ManyToMany
@JoinTable(name = "roles_depts", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "dept_id",referencedColumnName = "id")}) @JoinTable(name = "sys_roles_depts",
joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")},
inverseJoinColumns = {@JoinColumn(name = "dept_id",referencedColumnName = "dept_id")})
@ApiModelProperty(value = "部门", hidden = true)
private Set<Dept> depts; private Set<Dept> depts;
@Column(name = "create_time") @NotBlank
@CreationTimestamp @ApiModelProperty(value = "名称", hidden = true)
private Timestamp createTime; private String name;
@ApiModelProperty(value = "数据权限,全部 、 本级 、 自定义")
private String dataScope = "本级";
@Column(name = "level")
@ApiModelProperty(value = "级别,数值越小,级别越大")
private Integer level = 3;
public @interface Update {} @ApiModelProperty(value = "描述")
private String description;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp; import me.zhengjie.base.BaseEntity;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.Email; import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
...@@ -21,61 +35,75 @@ import java.util.Set; ...@@ -21,61 +35,75 @@ import java.util.Set;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@Table(name="user") @Table(name="sys_user")
public class User implements Serializable { public class User extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "user_id")
@NotNull(groups = Update.class) @NotNull(groups = Update.class)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value = "ID", hidden = true)
private Long id; private Long id;
@ManyToMany
@ApiModelProperty(value = "用户角色")
@JoinTable(name = "sys_users_roles",
joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")},
inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")})
private Set<Role> roles;
@ManyToMany
@ApiModelProperty(value = "用户岗位")
@JoinTable(name = "sys_users_jobs",
joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")},
inverseJoinColumns = {@JoinColumn(name = "job_id",referencedColumnName = "job_id")})
private Set<Job> jobs;
@OneToOne
@JoinColumn(name = "dept_id")
@ApiModelProperty(value = "用户部门")
private Dept dept;
@NotBlank @NotBlank
@Column(unique = true) @Column(unique = true)
@ApiModelProperty(value = "用户名称")
private String username; private String username;
/** 用户昵称 */
@NotBlank @NotBlank
@ApiModelProperty(value = "用户昵称")
private String nickName; private String nickName;
/** 性别 */
private String sex;
@OneToOne
@JoinColumn(name = "avatar_id")
private UserAvatar userAvatar;
@NotBlank
@Email @Email
@NotBlank
@ApiModelProperty(value = "邮箱")
private String email; private String email;
@NotBlank @NotBlank
@ApiModelProperty(value = "电话号码")
private String phone; private String phone;
@NotNull @ApiModelProperty(value = "用户性别")
private Boolean enabled; private String gender;
private String password;
@Column(name = "create_time") @ApiModelProperty(value = "头像真实名称",hidden = true)
@CreationTimestamp private String avatarName;
private Timestamp createTime;
@Column(name = "last_password_reset_time") @ApiModelProperty(value = "头像存储的路径", hidden = true)
private Date lastPasswordResetTime; private String avatarPath;
@ManyToMany @ApiModelProperty(value = "密码")
@JoinTable(name = "users_roles", joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}) private String password;
private Set<Role> roles;
@OneToOne @NotNull
@JoinColumn(name = "job_id") @ApiModelProperty(value = "是否启用")
private Job job; private Boolean enabled;
@OneToOne @ApiModelProperty(value = "是否为admin账号", hidden = true)
@JoinColumn(name = "dept_id") private Boolean isAdmin = false;
private Dept dept;
public @interface Update {} @Column(name = "pwd_reset_time")
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
private Date pwdResetTime;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
......
package me.zhengjie.modules.system.domain;
import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author Zheng Jie
* @date 2019年9月7日 16:16:59
*/
@Entity
@Getter
@Setter
@NoArgsConstructor
@Table(name = "user_avatar")
public class UserAvatar implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String realName;
private String path;
private String size;
@Column(name = "create_time")
@CreationTimestamp
private Timestamp createTime;
public UserAvatar(UserAvatar userAvatar,String realName, String path, String size) {
this.id = ObjectUtil.isNotEmpty(userAvatar) ? userAvatar.getId() : null;
this.realName = realName;
this.path = path;
this.size = size;
}
}
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain.vo; package me.zhengjie.modules.system.domain.vo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain.vo; package me.zhengjie.modules.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.domain.vo; package me.zhengjie.modules.system.domain.vo;
import lombok.Data; import lombok.Data;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.repository; package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.domain.Dept;
...@@ -26,7 +41,7 @@ public interface DeptRepository extends JpaRepository<Dept, Long>, JpaSpecificat ...@@ -26,7 +41,7 @@ public interface DeptRepository extends JpaRepository<Dept, Long>, JpaSpecificat
* @param id ID * @param id ID
* @return / * @return /
*/ */
@Query(value = "select name from dept where id = ?1",nativeQuery = true) @Query(value = "select name from sys_dept where dept_id = ?1",nativeQuery = true)
String findNameById(Long id); String findNameById(Long id);
/** /**
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.repository; package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.DictDetail;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.repository; package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.Dict; import me.zhengjie.modules.system.domain.Dict;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.repository; package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.domain.Job;
...@@ -9,4 +24,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; ...@@ -9,4 +24,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @date 2019-03-29 * @date 2019-03-29
*/ */
public interface JobRepository extends JpaRepository<Job, Long>, JpaSpecificationExecutor<Job> { public interface JobRepository extends JpaRepository<Job, Long>, JpaSpecificationExecutor<Job> {
/**
* 根据名称查询
* @param name 名称
* @return /
*/
Job findByName(String name);
} }
\ 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