You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.1 KiB
72 lines
2.1 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using AutoMapper;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
|
namespace Win_in.Sfs.Scp.WebApi
|
|
{
|
|
/// <summary>
|
|
/// 零件服务
|
|
/// </summary>
|
|
[AllowAnonymous]
|
|
[Route("api/scp/part")]
|
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
|
|
|
|
public class PartAppService :ReadOnlyAppService<Part,PartDTO,Guid, RequestDTO>, IPartAppService
|
|
{
|
|
private readonly IPartRepository _partRepository;
|
|
|
|
public PartAppService(IPartRepository repository) : base(repository)
|
|
{
|
|
_partRepository = repository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按ID获取零件 (Get part by ID)
|
|
/// </summary>
|
|
/// <param name="id">唯一ID(unique ID)</param>
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
[Route("{id}")]
|
|
public override async Task<PartDTO> GetAsync(Guid id)
|
|
{
|
|
return await base.GetAsync(id);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 按条件获取零件列表 (Get part list by request condition)
|
|
/// </summary>
|
|
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route("")]
|
|
public override async Task<PagedResultDto<PartDTO>> GetListAsync(RequestDTO requestDTO)
|
|
{
|
|
return await base.GetListAsync(requestDTO);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增零件(Create New part)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("")]
|
|
public async Task<PartDTO> CreateAsync(PartCreateDto partCreateDTO)
|
|
{
|
|
|
|
var entity = ObjectMapper.Map<PartCreateDto, Part>(partCreateDTO);
|
|
entity.SetId(GuidGenerator.Create());
|
|
var ret= await _partRepository.InsertAsync(entity);
|
|
var dto = ObjectMapper.Map<Part, PartDTO>(ret);
|
|
return dto;
|
|
}
|
|
|
|
}
|
|
}
|