76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
using New_College.IServices;
|
|
using New_College.Model;
|
|
using New_College.Model.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Linq.Expressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace New_College.Api.Controllers
|
|
{
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[Authorize(Permissions.Name)]
|
|
public class D_QualificationLineController : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
|
|
/// </summary>
|
|
private readonly ID_QualificationLineServices _d_QualificationLineServices;
|
|
|
|
public D_QualificationLineController(ID_QualificationLineServices D_QualificationLineServices)
|
|
{
|
|
_d_QualificationLineServices = D_QualificationLineServices;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<MessageModel<PageModel<D_QualificationLine>>> Get(int page = 1, string key = "", int intPageSize = 50)
|
|
{
|
|
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
|
|
{
|
|
key = "";
|
|
}
|
|
|
|
Expression<Func<D_QualificationLine, bool>> whereExpression = a => a.Id > 0;
|
|
|
|
return new MessageModel<PageModel<D_QualificationLine>>()
|
|
{
|
|
msg = "获取成功",
|
|
success = true,
|
|
response = await _d_QualificationLineServices.QueryPage(whereExpression, page, intPageSize)
|
|
};
|
|
|
|
}
|
|
|
|
[HttpGet("{id}")]
|
|
public async Task<MessageModel<D_QualificationLine>> Get(int id = 0)
|
|
{
|
|
return new MessageModel<D_QualificationLine>()
|
|
{
|
|
msg = "获取成功",
|
|
success = true,
|
|
response = await _d_QualificationLineServices.QueryById(id)
|
|
};
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<MessageModel<string>> Post([FromBody] D_QualificationLine request)
|
|
{
|
|
var data = new MessageModel<string>();
|
|
|
|
var id = await _d_QualificationLineServices.Add(request);
|
|
data.success = id > 0;
|
|
|
|
if (data.success)
|
|
{
|
|
data.response = id.ObjToString();
|
|
data.msg = "添加成功";
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
|
|
}
|
|
} |