using DouyinApi.Common; using DouyinApi.IRepository.Base; using DouyinApi.IServices; using DouyinApi.Model.Models; using DouyinApi.Services.BASE; using System.Linq; using System.Threading.Tasks; namespace DouyinApi.Services { /// /// RoleServices /// public class RoleServices : BaseServices, IRoleServices { /// /// /// /// /// public async Task SaveRole(string roleName) { Role role = new Role(roleName); Role model = new Role(); var userList = await base.Query(a => a.Name == role.Name && a.Enabled); if (userList.Count > 0) { model = userList.FirstOrDefault(); } else { var id = await base.Add(role); model = await base.QueryById(id); } return model; } [Caching(AbsoluteExpiration = 30)] public async Task GetRoleNameByRid(int rid) { return ((await base.QueryById(rid))?.Name); } } }