123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using Autofac.Core;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Service;
- using Ropin.Inspection.Service.SYS.Interface;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using System;
- using Ropin.Inspection.Model.ViewModel.SYS;
- namespace Ropin.Inspection.Api.Controllers.SYS
- {
- [AllowAnonymous]
- public class TsysPrivController : BaseController
- {
- public ILogger<TsysPrivController> _logger { get; }
- private readonly ITsysPrivService _service;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="service"></param>
- /// <param name="logger"></param>
- public TsysPrivController(ITsysPrivService service, ILogger<TsysPrivController> logger)
- {
- _service = service;
- _logger = logger;
- }
- /// <summary>
- /// 获取树型列表
- /// </summary>
- /// <returns></returns>
- [HttpPost("GetPrivTree")]
- public async Task<ApiResult> GetListTreeAsync(TsysPrivSearch model)
- {
- try
- {
- if (model==null)
- {
- model = new TsysPrivSearch();
- }
- var list = await _service.GetPrivTree(model);
- return new ApiResult<List<TsysPrivTreeModel>>(list);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 创建
- /// </summary>
- /// <param name="entity"></param>
- /// <returns></returns>
- [Route("CreatePrivAsync")]
- [HttpPost]
- public async Task<ApiResult> CreatePrivAsync(TsysPrivViewModel entity)
- {
- if (entity == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- await _service.CreateOneAsync(entity);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 更新
- /// </summary>
- /// <param name="id"></param>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPut("UpdatePriv/{id}")]
- public async Task<ApiResult> UpdatePrivAsync(string id, TsysPrivViewModel updateModel)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _service.UpdateOneAsync(id, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("DeletePriv/{id}")]
- public async Task<ApiResult> DeletePriv(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _service.DeleteAsync(id);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- }
- }
|