com.loy.upm.sys.repository.ResourceRepository Maven / Gradle / Ivy
/*
* Copyright Loy Fu. 付厚俊
* 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 com.loy.upm.sys.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import com.loy.e.core.repository.GenericRepository;
import com.loy.upm.sys.domain.entity.ResourceEntity;
/**
*
* @author Loy Fu qq群 540553957 http://www.17jee.com
* @since 1.7
* @version 1.0.0
*
*/
public interface ResourceRepository extends GenericRepository {
@Query("SELECT distinct re FROM UserEntity u join u.roles r join r.resources re "
+ " where u.username = ?1 and re.systemId = ?2 and re.resourceType = 'MENU' order by re.parentId ,re.sortNum")
List findMenuByUsernameAndCode(String userId, String code);
@Query("SELECT distinct re FROM UserEntity u join u.roles r join r.resources re "
+ " where u.username = ?1 and re.resourceType = 'MENU' order by re.parentId ,re.sortNum")
List findMenuByUsername(String username);
@Query("SELECT distinct re FROM RoleEntity r join r.resources re"
+ " where r.id = ?1 order by re.parentId ,re.sortNum")
List findResourceByRoleId(String roleId);
@Query("SELECT distinct re FROM UserEntity u join u.roles r join r.resources re"
+ " where u.username = ?1")
List findResourceByUsername(String username);
@Query("SELECT distinct re FROM UserEntity u join u.roles r join r.resources re"
+ " where u.username = ?1 and re.systemId = ?2")
List findResourceByUsernameAndCode(String username, String code);
@Query("SELECT r FROM ResourceEntity r "
+ " where r.parentId is null order by r.sortNum")
List findResourceByParentIdIsNull();
@Query("SELECT r FROM ResourceEntity r "
+ " where r.parentId = ?1 order by r.sortNum")
List findResourceByParentId(String parentId);
@Query("SELECT r FROM ResourceEntity r ")
List findAllResource();
@Query("SELECT r FROM ResourceEntity r "
+ " where r.systemId = ?1")
List findResourceBySystemCode(String code);
@Query(" FROM ResourceEntity r "
+ " where r.resourceType = 'BUTTON'")
List findResourceByTypeButton();
}