@ Data
@ NoArgsConstructor
@ AllArgsConstructor
@ the Entity
@ Table (name="t_user")
Public class User extends BaseEntity {
@ the Column (columnDefinition="varchar (20) DEFAULT 'COMMENT' user name '", nullable=false)
Private String username;
@ the Column (columnDefinition="varchar (100) the DEFAULT 'COMMENT' password '", nullable=false)
private String password;
@ ManyToOne (cascade=CascadeType. ALL the fetch=FetchType. LAZY)
@ JoinColumn (name="dept_id")
Private Department dept;
@ ManyToOne (cascade=CascadeType. ALL the fetch=FetchType. LAZY)
@ JoinColumn (name="role_id")
Private Role Role;
}
@ Data
@ NoArgsConstructor
@ AllArgsConstructor
@ the Entity
@ Table (name="t_dept")
Public class Department extends BaseEntity {
@ the Column (columnDefinition="varchar (20) DEFAULT 'COMMENT' department name")
Private String the deptName.
@ the Column (columnDefinition="varchar (20) DEFAULT 'COMMENT' names")
Private String dept;
@ the Column (columnDefinition="int the DEFAULT 0 COMMENT 'superior department ID")
Private Integer parentDeptId;
The @onetomany (mappedBy="dept", cascade=CascadeType. ALL, fetch=FetchType. LAZY)
Private Set
The @onetomany (mappedBy="dept", cascade=CascadeType. ALL, fetch=FetchType. LAZY)
Private Set}
@ Data
@ NoArgsConstructor
@ AllArgsConstructor
Public class UserUpdateReq {
Private Integer userId.
Private String username;
Private Integer deptId;
}
@ Mapper (componentModel="spring")
Public interface UserConvert {
The User userUpdateReqToUser (userUpdateRequser the req);
}
CodePudding user response:
Feel the MapStrut nothing much, advice or a mapper. XML is flexible