-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8b982c
commit 0821a77
Showing
30 changed files
with
1,189 additions
and
487 deletions.
There are no files selected for viewing
467 changes: 233 additions & 234 deletions
467
src/main/java/com/xcesys/extras/framework/core/controller/BaseCrudController.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 87 additions & 88 deletions
175
src/main/java/com/xcesys/extras/framework/entity/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,87 @@ | ||
package com.xcesys.extras.framework.entity; | ||
|
||
import static javax.persistence.FetchType.EAGER; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.LinkedHashSet; | ||
import java.util.Locale; | ||
import java.util.Set; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.JoinTable; | ||
import javax.persistence.ManyToMany; | ||
import javax.persistence.OneToMany; | ||
|
||
import org.hibernate.annotations.DynamicInsert; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
import org.springframework.data.jpa.datatables.mapping.DataTablesOutput; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
import com.fasterxml.jackson.annotation.JsonView; | ||
import com.xcesys.extras.framework.core.model.IEditable; | ||
import com.xcesys.extras.framework.core.model.IdAuditableEntity; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@DynamicInsert | ||
@DynamicUpdate | ||
@NoArgsConstructor | ||
@RequiredArgsConstructor | ||
@Getter | ||
@Setter | ||
public class User extends IdAuditableEntity implements UserDetails, IEditable { | ||
private static final long serialVersionUID = -6943871074854331138L; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean accountNonExpired = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean accountNonLocked = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean admin = false; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean credentialsNonExpired = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean editable = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private String email; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean enabled = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private String fullname; | ||
@JsonView(DataTablesOutput.View.class) | ||
private String mobile; | ||
@NonNull | ||
@JsonView(DataTablesOutput.View.class) | ||
private String password; | ||
@JsonView(DataTablesOutput.View.class) | ||
@OneToMany(fetch = EAGER) | ||
private Set<PreferenceValue> preferenceValues = new HashSet<PreferenceValue>(); | ||
|
||
@JsonView(DataTablesOutput.View.class) | ||
@ManyToMany(fetch = EAGER) | ||
@JoinTable(name = "user_roles", joinColumns = { | ||
@JoinColumn(name = "users_id", nullable = false, updatable = false) }, inverseJoinColumns = { | ||
@JoinColumn(name = "roles_id", nullable = false, updatable = false) }) | ||
private Set<Role> roles = new HashSet<Role>(); | ||
@Column(unique = true) | ||
@NonNull | ||
@JsonView(DataTablesOutput.View.class) | ||
private String username; | ||
|
||
@Override | ||
public Collection<? extends GrantedAuthority> getAuthorities() { | ||
Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>(); | ||
for (Role role : getRoles()) { | ||
grantedAuthorities.add(new SimpleGrantedAuthority(role.getName())); | ||
} | ||
return grantedAuthorities; | ||
} | ||
} | ||
package com.xcesys.extras.framework.entity; | ||
|
||
import static javax.persistence.FetchType.EAGER; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.JoinTable; | ||
import javax.persistence.ManyToMany; | ||
import javax.persistence.OneToMany; | ||
|
||
import org.hibernate.annotations.DynamicInsert; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
import org.springframework.data.jpa.datatables.mapping.DataTablesOutput; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
import com.fasterxml.jackson.annotation.JsonView; | ||
import com.xcesys.extras.framework.core.model.IEditable; | ||
import com.xcesys.extras.framework.core.model.IdAuditableEntity; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@DynamicInsert | ||
@DynamicUpdate | ||
@NoArgsConstructor | ||
@RequiredArgsConstructor | ||
@Getter | ||
@Setter | ||
public class User extends IdAuditableEntity implements UserDetails, IEditable { | ||
private static final long serialVersionUID = -6943871074854331138L; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean accountNonExpired = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean accountNonLocked = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean admin = false; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean credentialsNonExpired = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean editable = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private String email; | ||
@JsonView(DataTablesOutput.View.class) | ||
private boolean enabled = true; | ||
@JsonView(DataTablesOutput.View.class) | ||
private String fullname; | ||
@JsonView(DataTablesOutput.View.class) | ||
private String mobile; | ||
@NonNull | ||
@JsonView(DataTablesOutput.View.class) | ||
private String password; | ||
@JsonView(DataTablesOutput.View.class) | ||
@OneToMany(fetch = EAGER) | ||
private Set<PreferenceValue> preferenceValues = new HashSet<PreferenceValue>(); | ||
|
||
@JsonView(DataTablesOutput.View.class) | ||
@ManyToMany(fetch = EAGER) | ||
@JoinTable(name = "user_roles", joinColumns = { | ||
@JoinColumn(name = "users_id", nullable = false, updatable = false) }, inverseJoinColumns = { | ||
@JoinColumn(name = "roles_id", nullable = false, updatable = false) }) | ||
private Set<Role> roles = new HashSet<Role>(); | ||
@Column(unique = true) | ||
@NonNull | ||
@JsonView(DataTablesOutput.View.class) | ||
private String username; | ||
|
||
@Override | ||
public Collection<? extends GrantedAuthority> getAuthorities() { | ||
Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>(); | ||
for (Role role : getRoles()) { | ||
grantedAuthorities.add(new SimpleGrantedAuthority(role.getName())); | ||
} | ||
return grantedAuthorities; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/xcesys/extras/framework/repository/DictRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.xcesys.extras.framework.repository; | ||
|
||
import com.xcesys.extras.framework.core.repository.IBaseRepository; | ||
import com.xcesys.extras.framework.entity.Dict; | ||
|
||
public interface DictRepository extends IBaseRepository<Dict, Long> { | ||
|
||
Dict findByName(String name); | ||
|
||
int countByTypeIdAndName(Long typeId, String name); | ||
|
||
Iterable<Dict> findByTypeId(Long id); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/xcesys/extras/framework/repository/DictTypeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.xcesys.extras.framework.repository; | ||
|
||
import com.xcesys.extras.framework.core.repository.IBaseRepository; | ||
import com.xcesys.extras.framework.entity.DictType; | ||
|
||
public interface DictTypeRepository extends IBaseRepository<DictType, Long> { | ||
|
||
DictType findByName(String name); | ||
|
||
int countByName(String name); | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/xcesys/extras/framework/service/DictService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.xcesys.extras.framework.service; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.xcesys.extras.framework.core.repository.IBaseRepository; | ||
import com.xcesys.extras.framework.core.service.impl.BaseCrudService; | ||
import com.xcesys.extras.framework.entity.Dict; | ||
import com.xcesys.extras.framework.repository.DictRepository; | ||
|
||
@Service | ||
@Transactional | ||
public class DictService extends BaseCrudService<Dict, Long> { | ||
@Autowired | ||
private DictRepository reposity; | ||
|
||
public Dict findByName(String Dictname) { | ||
return reposity.findByName(Dictname); | ||
} | ||
|
||
@Override | ||
public IBaseRepository<Dict, Long> getRepository() { | ||
return reposity; | ||
} | ||
|
||
public int countByTypeIdAndName(Long typeId, String name) { | ||
return reposity.countByTypeIdAndName(typeId, name); | ||
} | ||
|
||
public Iterable<Dict> findByTypeId(@Param("typeId") Long typeId) { | ||
return reposity.findByTypeId(typeId); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/xcesys/extras/framework/service/DictTypeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.xcesys.extras.framework.service; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.xcesys.extras.framework.core.repository.IBaseRepository; | ||
import com.xcesys.extras.framework.core.service.impl.BaseCrudService; | ||
import com.xcesys.extras.framework.entity.DictType; | ||
import com.xcesys.extras.framework.repository.DictTypeRepository; | ||
|
||
@Service | ||
@Transactional | ||
public class DictTypeService extends BaseCrudService<DictType, Long> { | ||
@Autowired | ||
private DictTypeRepository reposity; | ||
|
||
public DictType findByName(String DictTypename) { | ||
return reposity.findByName(DictTypename); | ||
} | ||
|
||
@Override | ||
public IBaseRepository<DictType, Long> getRepository() { | ||
return reposity; | ||
} | ||
|
||
public int countByName(String name) { | ||
return reposity.countByName(name); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.