feat(iot): 添加设备、产品和基础实体的创建人和部门字段
- 在 BaseEntity、BaseParam、Device、Product 类中添加 createId 和 deptId 字段 - 在 MyMetaObjectHandler 中添加对 createId 和 deptId 的自动填充逻辑 - 在 UserDetailsImpl 中添加 deptId 和 createId 属性,用于获取当前用户信息
This commit is contained in:
parent
0ecd639619
commit
da24f15ca2
@ -24,8 +24,16 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||||||
if (userInfo.getUsername() == null) {
|
if (userInfo.getUsername() == null) {
|
||||||
userInfo.setUsername("system");
|
userInfo.setUsername("system");
|
||||||
}
|
}
|
||||||
|
if (userInfo.getDeptId() == null) {
|
||||||
|
userInfo.setDeptId(2L);
|
||||||
|
}
|
||||||
|
if (userInfo.getCreateId() == null) {
|
||||||
|
userInfo.setCreateId(1L);
|
||||||
|
}
|
||||||
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
|
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
|
||||||
this.strictInsertFill(metaObject, "createBy", String.class, userInfo.getUsername());
|
this.strictInsertFill(metaObject, "createBy", String.class, userInfo.getUsername());
|
||||||
|
this.strictInsertFill(metaObject, "deptId", Long.class, userInfo.getDeptId());
|
||||||
|
this.strictInsertFill(metaObject, "createId", Long.class, userInfo.getCreateId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,10 @@ public class UserDetailsImpl implements UserDetails {
|
|||||||
public Set<Authority> authorities;
|
public Set<Authority> authorities;
|
||||||
public Set<String> permissions;
|
public Set<String> permissions;
|
||||||
public Set<Long> dataScopeDeptIds;
|
public Set<Long> dataScopeDeptIds;
|
||||||
|
public Long deptId;
|
||||||
|
public Long createId;
|
||||||
|
|
||||||
public UserDetailsImpl(Long id, String username, String password, String name, Boolean enableState, Dept dept, Set<Long> dataScopeDeptIds, Role role, Set<Authority> authorities, Set<String> permissions, List<Role> roles) {
|
public UserDetailsImpl(Long id, String username, String password, String name, Boolean enableState, Dept dept, Set<Long> dataScopeDeptIds, Role role, Set<Authority> authorities, Set<String> permissions, List<Role> roles, Long deptId, Long createId) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
@ -64,7 +66,9 @@ public class UserDetailsImpl implements UserDetails {
|
|||||||
user.role,
|
user.role,
|
||||||
user.role.authorities,
|
user.role.authorities,
|
||||||
permissions,
|
permissions,
|
||||||
user.roles
|
user.roles,
|
||||||
|
user.deptId,
|
||||||
|
user.createId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.zsc.edu.gateway.modules.iot.device.entity;
|
package com.zsc.edu.gateway.modules.iot.device.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.IEnum;
|
import com.baomidou.mybatisplus.annotation.IEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
@ -91,6 +92,12 @@ public class Device extends BaseEntity {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
public Product product;
|
public Product product;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
@TableField(value = "dept_id", fill = FieldFill.INSERT)
|
||||||
|
public Long deptId;
|
||||||
|
|
||||||
|
|
||||||
public enum Status implements IEnum<Integer>, IState<Status> {
|
public enum Status implements IEnum<Integer>, IState<Status> {
|
||||||
UNACTIVATED(0, "未激活"),
|
UNACTIVATED(0, "未激活"),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.zsc.edu.gateway.modules.iot.product.entity;
|
package com.zsc.edu.gateway.modules.iot.product.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.IEnum;
|
import com.baomidou.mybatisplus.annotation.IEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
@ -32,6 +33,7 @@ public class Product extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
|
@TableField(value = "dept_id", fill = FieldFill.INSERT)
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
/**
|
/**
|
||||||
* 产品类型
|
* 产品类型
|
||||||
@ -54,6 +56,7 @@ public class Product extends BaseEntity {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Set<Param> params;
|
private Set<Param> params;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接入方式
|
* 接入方式
|
||||||
*/
|
*/
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.zsc.edu.gateway.modules.iot.tsl.entity;
|
package com.zsc.edu.gateway.modules.iot.tsl.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -43,6 +41,13 @@ public class BaseParam implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 部门ID(权限)
|
* 部门ID(权限)
|
||||||
*/
|
*/
|
||||||
|
@TableField(value = "dept_id", fill = FieldFill.INSERT)
|
||||||
public Long deptId;
|
public Long deptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人ID(权限)
|
||||||
|
*/
|
||||||
|
@TableField(value = "create_id", fill = FieldFill.INSERT)
|
||||||
|
public Long createId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public class BaseEntity implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 创建者ID
|
* 创建者ID
|
||||||
*/
|
*/
|
||||||
|
@TableField(value = "create_id", fill = FieldFill.INSERT)
|
||||||
public Long createId;
|
public Long createId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user