/* * Copyright (C) 2023 杭州白书科技有限公司 * * Licensed under the Apache License, Version 2.0 (the "License"); * 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 xyz.playedu.api.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import xyz.playedu.api.domain.AdminPermission; import xyz.playedu.api.mapper.AdminPermissionMapper; import xyz.playedu.api.service.AdminPermissionService; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * @author tengteng * @description 针对表【admin_permissions】的数据库操作Service实现 * @createDate 2023-02-20 14:27:50 */ @Service public class AdminPermissionServiceImpl extends ServiceImpl implements AdminPermissionService { @Override public HashMap allSlugs() { List data = list(); HashMap map = new HashMap<>(); for (AdminPermission permission : data) { map.put(permission.getSlug(), true); } return map; } @Override public List listOrderBySortAsc() { return list(query().getWrapper().orderByAsc("group_name", "sort")); } @Override public HashMap getSlugsByIds(List ids) { List adminPermissions = list(query().getWrapper().in("id", ids)); HashMap map = new HashMap<>(); for (AdminPermission adminPermission : adminPermissions) { map.put(adminPermission.getSlug(), true); } return map; } @Override public List allIds() { List permissions = list(query().getWrapper().eq("1", "1").select("id")); List ids = new ArrayList<>(); for (AdminPermission permission : permissions) { ids.add(permission.getId()); } return ids; } @Override public List chunks(List ids) { return list(query().getWrapper().in("id", ids)); } }