fix api
This commit is contained in:
18
Src/Dlhis.Basic.Api/IBusinessPlacePermissionsApi.cs
Normal file
18
Src/Dlhis.Basic.Api/IBusinessPlacePermissionsApi.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Dlhis.Basic.Api.Request;
|
||||||
|
using Kurisu.Core.Result;
|
||||||
|
using Kurisu.RemoteCall.Attributes;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.Api
|
||||||
|
{
|
||||||
|
[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
|
||||||
|
public interface IBusinessPlacePermissionsApi
|
||||||
|
{
|
||||||
|
[Auth]
|
||||||
|
[Get("/api/businessplacepermissions/getPlaces")]
|
||||||
|
Task<DefaultApiResult<List<Guid>>> GetPlaceByUserIdAsync(int userId);
|
||||||
|
|
||||||
|
[Auth]
|
||||||
|
[Post("/api/businessplacepermissions/savePlace")]
|
||||||
|
Task SaveBusinessPlacePermissionAsync(SaveBusinessPlacePermissionRequest request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.Api.Request
|
||||||
|
{
|
||||||
|
public class SaveBusinessPlacePermissionRequest
|
||||||
|
{
|
||||||
|
public long? Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 管理人员
|
||||||
|
/// </summary>
|
||||||
|
public int ManagerUserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 营业点
|
||||||
|
/// </summary>
|
||||||
|
public Guid BusinessPlaceCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using Dlhis.Basic.BusinessPlace.Request;
|
||||||
|
using Dlhis.Basic.BusinessPlace.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Org.BouncyCastle.Asn1.Ocsp;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.BusinessPlace.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 营业点管理
|
||||||
|
/// </summary>
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class BusinessPlacePermissionsController
|
||||||
|
{
|
||||||
|
private readonly IBusinessPlacePermissionsService _businessPlacePermissionsService;
|
||||||
|
|
||||||
|
public BusinessPlacePermissionsController(IBusinessPlacePermissionsService businessPlacePermissionsService)
|
||||||
|
{
|
||||||
|
_businessPlacePermissionsService = businessPlacePermissionsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据用户获取管理点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getPlaces")]
|
||||||
|
public async Task<List<Guid>> GetPlaceByUserIdAsync(int userId)
|
||||||
|
{
|
||||||
|
return await _businessPlacePermissionsService.GetPlaceByUserIdAsync(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存营业点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("savePlace")]
|
||||||
|
public async Task SaveBusinessPlacePermissionAsync(SaveBusinessPlacePermissionRequest request)
|
||||||
|
{
|
||||||
|
await _businessPlacePermissionsService.SaveBusinessPlacePermissionAsync(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.BusinessPlace.Request
|
||||||
|
{
|
||||||
|
public class SaveBusinessPlacePermissionRequest
|
||||||
|
{
|
||||||
|
public long? Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 管理人员
|
||||||
|
/// </summary>
|
||||||
|
public int ManagerUserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 营业点
|
||||||
|
/// </summary>
|
||||||
|
public Guid BusinessPlaceCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Dlhis.Basic.BusinessPlace.Request;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.BusinessPlace.Services
|
||||||
|
{
|
||||||
|
public interface IBusinessPlacePermissionsService : IScopeDependency
|
||||||
|
{
|
||||||
|
Task SaveBusinessPlacePermissionAsync(SaveBusinessPlacePermissionRequest request);
|
||||||
|
|
||||||
|
Task<List<Guid>> GetPlaceByUserIdAsync(int userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using Dlhis.Basic.BusinessPlace.Request;
|
||||||
|
using Dlhis.Entity.Basic.Entity;
|
||||||
|
using Kurisu.SqlSugar.Services;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.BusinessPlace.Services.Implements
|
||||||
|
{
|
||||||
|
public class BusinessPlacePermissionsService : IBusinessPlacePermissionsService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
private readonly IBusinessPlaceService _businessPlaceService;
|
||||||
|
|
||||||
|
public BusinessPlacePermissionsService(IDbContext dbContext, IBusinessPlaceService businessPlaceService)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
_businessPlaceService = businessPlaceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Guid>> GetPlaceByUserIdAsync(int userId)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<BusinessPlaceManagerRelationshipEntity>()
|
||||||
|
.Where(x => x.ManagerUserId == userId)
|
||||||
|
.Select(x => x.BusinessPlaceCode)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SaveBusinessPlacePermissionAsync(SaveBusinessPlacePermissionRequest request)
|
||||||
|
{
|
||||||
|
if(request.Id.HasValue)
|
||||||
|
{
|
||||||
|
var entity =await _dbContext.Queryable<BusinessPlaceManagerRelationshipEntity>()
|
||||||
|
.Where(x => x.Id == request.Id).FirstAsync();
|
||||||
|
request.Adapt(entity);
|
||||||
|
await _dbContext.UpdateAsync(entity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var entity = request.Adapt<BusinessPlaceManagerRelationshipEntity>();
|
||||||
|
await _dbContext.InsertAsync(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user