123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using GxPress.Common.Page;
- using GxPress.Entity;
- using GxPress.Repository.Interface;
- using GxPress.Request.Thesaurus;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- namespace GxPress.Api.AdminControllers
- {
- /// <summary>
- /// 词库 热词 冷词
- /// </summary>
- [Route("api/admin/thesaurus")]
- [ApiController]
- [Authorize]
- public class AdminThesaurusController : ControllerBase
- {
- private readonly IThesaurusRepository _thesaurusRepository;
- public AdminThesaurusController(IThesaurusRepository thesaurusRepository)
- {
- _thesaurusRepository = thesaurusRepository;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="request">参数</param>
- /// <returns></returns>
- [HttpPut("add")]
- public async Task<bool> InThesaurus([FromBody] ThesaurusInRequest request)
- {
- if (!string.IsNullOrEmpty(request.ThesaurusName) && request.ThesaurusName.Length > 500)
- {
- throw new Exception("保存失败,字符数不能超出16字");
- }
- var appVersion = new Thesaurus { ThesaurusType = request.ThesaurusType, ThesaurusName = request.ThesaurusName };
- return await _thesaurusRepository.InsertAsync(appVersion);
- }
- /// <summary>
- /// 分页查询列表
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("page")]
- public async Task<PagedList<Thesaurus>> GetPagedList([FromBody] ThesaurusPageSearchRequest request)
- {
- return await _thesaurusRepository.GetPageList(request);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- public async Task<bool> Delete(int id)
- {
- return await _thesaurusRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [HttpDelete("delete")]
- public async Task<bool> Deletes(List<int> ids)
- {
- return await _thesaurusRepository.DeleteAsync(ids);
- }
- /// <summary>
- /// 详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- public async Task<Thesaurus> Get(int id)
- {
- return await _thesaurusRepository.GetDetailAsync(id);
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="id"></param>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPut("{id}")]
- public async Task<bool> Update(int id, [FromBody] ThesaurusUpdateRequest request)
- {
- if (!string.IsNullOrEmpty(request.ThesaurusName) && request.ThesaurusName.Length > 500)
- {
- throw new Exception("保存失败,字符数不能超出16字");
- }
- return await _thesaurusRepository.UpdateAsync(id, request);
- }
- }
- }
|