// public static final String ROOT_PARENT_ID = "0";
- public static final String SYSTEM_ID = "1";
+ public static final String APPLICATION_ID = "1";
public static final String TYPE_SYSTEM = "1";
public static final String TYPE_MENU = "2";
@Column(name = "URL", nullable = true)
private String url;
+ /**
+ * 系统ID
+ */
+ @Column(name = "APPLICATION_ID", nullable = true)
+ private String applicationId;
+
/**
* 父级ID
*/
package com.supwisdom.institute.backend.base.domain.repo;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
-import org.springframework.data.domain.Example;
-import org.springframework.data.domain.ExampleMatcher;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Repository;
+import org.springframework.util.StringUtils;
import com.supwisdom.institute.backend.base.domain.entity.Group;
import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
@Repository
public interface GroupRepository extends BaseJpaRepository<Group> {
+
@Override
- public default Page<Group> selectPageList(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
- if (loadAll) {
- pageIndex = 0;
- pageSize = Integer.MAX_VALUE;
- }
-
- Group probe = new Group();
- if (mapBean != null) {
- probe.setDeleted(MapBeanUtils.getBoolean(mapBean, "deleted"));
- probe.setCode(MapBeanUtils.getString(mapBean, "code"));
- probe.setName(MapBeanUtils.getString(mapBean, "name"));
- probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
- probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
- }
+ public default Specification<Group> convertToSpec(Map<String, Object> mapBean) {
- ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("deleted", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
-
- PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
- Example<Group> example = Example.of(probe, matcher);
-
- Page<Group> page = this.findAll(example, pageRequest);
+ Specification<Group> spec = new Specification<Group>() {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5467747850605022253L;
+
+ @Override
+ public Predicate toPredicate(Root<Group> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
+ List<Predicate> predicates = new ArrayList<>();
+
+ if (mapBean != null) {
+
+ if (MapBeanUtils.getBoolean(mapBean, "deleted") != null) {
+ predicates.add(criteriaBuilder.equal(root.get("deleted"), MapBeanUtils.getBoolean(mapBean, "deleted")));
+ }
+
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "code"))) {
+ predicates.add(criteriaBuilder.like(root.get("code"), "%" + MapBeanUtils.getString(mapBean, "code") + "%"));
+ }
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "name"))) {
+ predicates.add(criteriaBuilder.like(root.get("name"), "%" + MapBeanUtils.getString(mapBean, "name") + "%"));
+ }
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "memo"))) {
+ predicates.add(criteriaBuilder.like(root.get("memo"), "%" + MapBeanUtils.getString(mapBean, "memo") + "%"));
+ }
+
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "status"))) {
+ predicates.add(criteriaBuilder.equal(root.get("status"), MapBeanUtils.getString(mapBean, "status")));
+ }
+
+ List<Predicate> predicatesKeyword = new ArrayList<>();
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "keyword"))) {
+ predicatesKeyword.add(criteriaBuilder.like(root.get("code"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+ predicatesKeyword.add(criteriaBuilder.like(root.get("name"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+ predicatesKeyword.add(criteriaBuilder.like(root.get("memo"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+
+ predicates.add(criteriaBuilder.or(predicatesKeyword.toArray(new Predicate[predicatesKeyword.size()])));
+ }
+ }
+
+ return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+ }
+
+ };
- return page;
+ return spec;
}
+
+// @Override
+// public default Page<Group> selectPageList(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+// if (loadAll) {
+// pageIndex = 0;
+// pageSize = Integer.MAX_VALUE;
+// }
+//
+// Group probe = new Group();
+// if (mapBean != null) {
+// probe.setDeleted(MapBeanUtils.getBoolean(mapBean, "deleted"));
+// probe.setCode(MapBeanUtils.getString(mapBean, "code"));
+// probe.setName(MapBeanUtils.getString(mapBean, "name"));
+// probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
+// probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
+// }
+//
+// ExampleMatcher matcher = ExampleMatcher.matching()
+// .withMatcher("deleted", ExampleMatcher.GenericPropertyMatchers.exact())
+// .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+//
+// PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+// Example<Group> example = Example.of(probe, matcher);
+//
+// Page<Group> page = this.findAll(example, pageRequest);
+//
+// return page;
+// }
}
/**
*
*/
- private static final long serialVersionUID = 9071470982419099273L;
+ private static final long serialVersionUID = 6195601104797641573L;
@Override
public Predicate toPredicate(Root<Permission> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
predicates.add(criteriaBuilder.like(root.get("url"), "%" + MapBeanUtils.getString(mapBean, "url") + "%"));
}
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "applicationId"))) {
+ predicates.add(criteriaBuilder.equal(root.get("applicationId"), MapBeanUtils.getString(mapBean, "applicationId")));
+ }
+
if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "parentId"))) {
predicates.add(criteriaBuilder.equal(root.get("parentId"), MapBeanUtils.getString(mapBean, "parentId")));
}
List<Predicate> predicatesKeyword = new ArrayList<>();
if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "keyword"))) {
- predicatesKeyword.add(criteriaBuilder.like(root.get("username"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+ predicatesKeyword.add(criteriaBuilder.like(root.get("code"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
predicatesKeyword.add(criteriaBuilder.like(root.get("name"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
predicatesKeyword.add(criteriaBuilder.like(root.get("memo"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
package com.supwisdom.institute.backend.base.domain.repo;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
+import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Repository;
+import org.springframework.util.StringUtils;
import com.supwisdom.institute.backend.base.domain.entity.Resource;
import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
public interface ResourceRepository extends BaseJpaRepository<Resource> {
@Override
- public default Page<Resource> selectPageList(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
- if (loadAll) {
- pageIndex = 0;
- pageSize = Integer.MAX_VALUE;
- }
-
- Resource probe = new Resource();
- if (mapBean != null) {
- probe.setDeleted(MapBeanUtils.getBoolean(mapBean, "deleted"));
- probe.setCode(MapBeanUtils.getString(mapBean, "code"));
- probe.setName(MapBeanUtils.getString(mapBean, "name"));
- probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
- probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
- }
-
- ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("deleted", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+ public default Specification<Resource> convertToSpec(Map<String, Object> mapBean) {
- PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
- Example<Resource> example = Example.of(probe, matcher);
-
- Page<Resource> page = this.findAll(example, pageRequest);
+ Specification<Resource> spec = new Specification<Resource>() {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7690039558726467041L;
+
+ @Override
+ public Predicate toPredicate(Root<Resource> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
+ List<Predicate> predicates = new ArrayList<>();
+
+ if (mapBean != null) {
+
+ if (MapBeanUtils.getBoolean(mapBean, "deleted") != null) {
+ predicates.add(criteriaBuilder.equal(root.get("deleted"), MapBeanUtils.getBoolean(mapBean, "deleted")));
+ }
+
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "code"))) {
+ predicates.add(criteriaBuilder.like(root.get("code"), "%" + MapBeanUtils.getString(mapBean, "code") + "%"));
+ }
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "name"))) {
+ predicates.add(criteriaBuilder.like(root.get("name"), "%" + MapBeanUtils.getString(mapBean, "name") + "%"));
+ }
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "memo"))) {
+ predicates.add(criteriaBuilder.like(root.get("memo"), "%" + MapBeanUtils.getString(mapBean, "memo") + "%"));
+ }
+
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "status"))) {
+ predicates.add(criteriaBuilder.equal(root.get("status"), MapBeanUtils.getString(mapBean, "status")));
+ }
+
+ List<Predicate> predicatesKeyword = new ArrayList<>();
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "keyword"))) {
+ predicatesKeyword.add(criteriaBuilder.like(root.get("code"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+ predicatesKeyword.add(criteriaBuilder.like(root.get("name"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+ predicatesKeyword.add(criteriaBuilder.like(root.get("memo"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+
+ predicates.add(criteriaBuilder.or(predicatesKeyword.toArray(new Predicate[predicatesKeyword.size()])));
+ }
+ }
+
+ return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+ }
+
+ };
- return page;
+ return spec;
}
+
+// @Override
+// public default Page<Resource> selectPageList(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+// if (loadAll) {
+// pageIndex = 0;
+// pageSize = Integer.MAX_VALUE;
+// }
+//
+// Resource probe = new Resource();
+// if (mapBean != null) {
+// probe.setDeleted(MapBeanUtils.getBoolean(mapBean, "deleted"));
+// probe.setCode(MapBeanUtils.getString(mapBean, "code"));
+// probe.setName(MapBeanUtils.getString(mapBean, "name"));
+// probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
+// probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
+// }
+//
+// ExampleMatcher matcher = ExampleMatcher.matching()
+// .withMatcher("deleted", ExampleMatcher.GenericPropertyMatchers.exact())
+// .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+//
+// PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+// Example<Resource> example = Example.of(probe, matcher);
+//
+// Page<Resource> page = this.findAll(example, pageRequest);
+//
+// return page;
+// }
public default Resource selectByCode(String code) {
Resource probe = new Resource();
import java.util.Map;
import java.util.Optional;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
+import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
+import org.springframework.util.StringUtils;
import com.supwisdom.institute.backend.base.domain.entity.Role;
import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
public interface RoleRepository extends BaseJpaRepository<Role> {
@Override
- public default Page<Role> selectPageList(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
- if (loadAll) {
- pageIndex = 0;
- pageSize = Integer.MAX_VALUE;
- }
-
- Role probe = new Role();
- if (mapBean != null) {
- probe.setDeleted(MapBeanUtils.getBoolean(mapBean, "deleted"));
- probe.setCode(MapBeanUtils.getString(mapBean, "code"));
- probe.setName(MapBeanUtils.getString(mapBean, "name"));
- probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
- probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
- }
-
- ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("deleted", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
- .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+ public default Specification<Role> convertToSpec(Map<String, Object> mapBean) {
- PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
- Example<Role> example = Example.of(probe, matcher);
-
- Page<Role> page = this.findAll(example, pageRequest);
+ Specification<Role> spec = new Specification<Role>() {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -263282246904382286L;
+
+ @Override
+ public Predicate toPredicate(Root<Role> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
+ List<Predicate> predicates = new ArrayList<>();
+
+ if (mapBean != null) {
+
+ if (MapBeanUtils.getBoolean(mapBean, "deleted") != null) {
+ predicates.add(criteriaBuilder.equal(root.get("deleted"), MapBeanUtils.getBoolean(mapBean, "deleted")));
+ }
+
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "code"))) {
+ predicates.add(criteriaBuilder.like(root.get("code"), "%" + MapBeanUtils.getString(mapBean, "code") + "%"));
+ }
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "name"))) {
+ predicates.add(criteriaBuilder.like(root.get("name"), "%" + MapBeanUtils.getString(mapBean, "name") + "%"));
+ }
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "memo"))) {
+ predicates.add(criteriaBuilder.like(root.get("memo"), "%" + MapBeanUtils.getString(mapBean, "memo") + "%"));
+ }
+
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "status"))) {
+ predicates.add(criteriaBuilder.equal(root.get("status"), MapBeanUtils.getString(mapBean, "status")));
+ }
+
+ List<Predicate> predicatesKeyword = new ArrayList<>();
+ if (!StringUtils.isEmpty(MapBeanUtils.getString(mapBean, "keyword"))) {
+ predicatesKeyword.add(criteriaBuilder.like(root.get("code"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+ predicatesKeyword.add(criteriaBuilder.like(root.get("name"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+ predicatesKeyword.add(criteriaBuilder.like(root.get("memo"), "%" + MapBeanUtils.getString(mapBean, "keyword") + "%"));
+
+ predicates.add(criteriaBuilder.or(predicatesKeyword.toArray(new Predicate[predicatesKeyword.size()])));
+ }
+ }
+
+ return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+ }
+
+ };
- return page;
+ return spec;
}
+
+// @Override
+// public default Page<Role> selectPageList(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+// if (loadAll) {
+// pageIndex = 0;
+// pageSize = Integer.MAX_VALUE;
+// }
+//
+// Role probe = new Role();
+// if (mapBean != null) {
+// probe.setDeleted(MapBeanUtils.getBoolean(mapBean, "deleted"));
+// probe.setCode(MapBeanUtils.getString(mapBean, "code"));
+// probe.setName(MapBeanUtils.getString(mapBean, "name"));
+// probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
+// probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
+// }
+//
+// ExampleMatcher matcher = ExampleMatcher.matching()
+// .withMatcher("deleted", ExampleMatcher.GenericPropertyMatchers.exact())
+// .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
+// .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+//
+// PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+// Example<Role> example = Example.of(probe, matcher);
+//
+// Page<Role> page = this.findAll(example, pageRequest);
+//
+// return page;
+// }
public default Role selectByCode(String code) {
private GroupRoleRepository groupRoleRepository;
+ public void deleteBatch(List<String> ids) {
+
+ ids.stream().forEach(id -> {
+ this.deleteById(id);
+ });
+ }
+
public Page<AccountGroup> selectGroupAccounts(int pageIndex, int pageSize, Map<String, Object> mapBean) {
});
}
- private Permission selectSystem() {
- Permission permission = permissionRepository.selectById(Permission.SYSTEM_ID);
+ private Permission selectApplicationPermission() {
+ Permission permission = permissionRepository.selectById(Permission.APPLICATION_ID);
return permission;
}
public PermissionTreeNode selectPermissionTree(Map<String, Object> mapBean) {
- Permission systemPermission = this.selectSystem();
+ Permission applicationPermission = this.selectApplicationPermission();
Map<String, PermissionTreeNode> parentTreeNode = new LinkedHashMap<String, PermissionTreeNode>();
PermissionTreeNode rootTreeNode = new PermissionTreeNode();
- rootTreeNode.setId(systemPermission.getId());
- rootTreeNode.setCode(systemPermission.getCode());
- rootTreeNode.setName(systemPermission.getName());
+ rootTreeNode.setId(applicationPermission.getId());
+ rootTreeNode.setCode(applicationPermission.getCode());
+ rootTreeNode.setName(applicationPermission.getName());
rootTreeNode.setChildren(new ArrayList<PermissionTreeNode>());
parentTreeNode.put(rootTreeNode.getId(), rootTreeNode);
package com.supwisdom.institute.backend.base.domain.service;
+import java.util.List;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Autowired
private ResourceRepository resourceRepository;
+
+ public void deleteBatch(List<String> ids) {
+
+ ids.stream().forEach(id -> {
+ this.deleteById(id);
+ });
+ }
+
+
}
@Autowired
private RolePermissionRepository rolePermissionRepository;
-
public void deleteBatch(List<String> ids) {
});
}
+
public Page<AccountRole> selectRoleAccounts(int pageIndex, int pageSize, Map<String, Object> mapBean) {
AccountRole probe = new AccountRole();