using Entity.Api.Req; using Entity.Api.Resp; using Entity.Base; using Entity.DbModel.System.SysBaseObject; using Entity.Dto.Req; using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; using Service.Mgr; using Service.Station; using Service.System; using System.ComponentModel.DataAnnotations; namespace WebStarter.Controllers.System { [Produces("application/json")] [ApiController] public class SysConfigController { private readonly SysConfigService _sysConfigService; private readonly IWebHostEnvironment _webHostEnvironment; public SysConfigController(SysConfigService sysConfigService, IWebHostEnvironment webHostEnvironment) { _sysConfigService = sysConfigService; _webHostEnvironment = webHostEnvironment; } [HttpPost] [Route("/api/sysConfig/page")] public async Task> Page(PageConfigReq input) { return await _sysConfigService.Page(input); } [HttpGet] [Route("/api/sysConfig/list")] public async Task> GetList() { return await _sysConfigService.GetList(); } [HttpGet] [Route("/api/sysConfig/detail")] public async Task GetDetail([FromQuery] ConfigReq input) { return await _sysConfigService.GetDetail(input); } [HttpGet] [Route("/api/sysConfig/groupList")] public async Task> GetGroupList() { return await _sysConfigService.GetGroupList(); } [HttpPost] [Route("/api/sysConfig/add")] public async Task Add(AddConfigReq input) { await _sysConfigService.AddConfig(input); } [HttpPost] [Route("/api/sysConfig/update")] public async Task Update(UpdateConfigReq input) { await _sysConfigService.UpdateConfig(input); } [HttpPost] [Route("/api/sysConfig/delete")] public async Task Delete(DeleteConfigReq input) { await _sysConfigService.DeleteConfig(input); } [HttpPost] [Route("/api/sysConfig/batchDelete")] public async Task BatchDelete(List input) { await _sysConfigService.BatchDeleteConfig(input); } /// /// 返回 站点基础信息 /// [HttpGet("StationBaseInfo")] public async Task> StationBaseInfo() { StationBaseInfoResp stationBaseInfoResp = new StationBaseInfoResp { StationNo = _sysConfigService.Get(StationParamConst.StationNo), StationName = _sysConfigService.Get(StationParamConst.StationName), StationType = _sysConfigService.Get(StationParamConst.StationType), StationSn = _sysConfigService.Get(StationParamConst.StationSn), StationLocation = _sysConfigService.Get(StationParamConst.StationLocation), Longitude = _sysConfigService.Get(StationParamConst.Longitude), Latitude = _sysConfigService.Get(StationParamConst.Latitude), AreaCode = _sysConfigService.Get(StationParamConst.AreaCode), AreaName = _sysConfigService.Get(StationParamConst.AreaName), Operatetionstime = _sysConfigService.Get(StationParamConst.StationNo), Operatetionetime = _sysConfigService.Get(StationParamConst.StationNo), Sevstatus = Convert.ToSByte(_sysConfigService.Get(StationParamConst.StationNo)), Status = Convert.ToSByte(_sysConfigService.Get(StationParamConst.StationNo)), LaunchTime = _sysConfigService.Get(StationParamConst.StationNo), ContactWay = _sysConfigService.Get(StationParamConst.StationNo), Principal = _sysConfigService.Get(StationParamConst.StationNo), StationCompany = _sysConfigService.Get(StationParamConst.StationNo), SocialCreditCode = _sysConfigService.Get(StationParamConst.StationNo), StationSftVer = _sysConfigService.Get(StationParamConst.StationNo), SupplierCode = _sysConfigService.Get(StationParamConst.StationNo), StationVersion = _sysConfigService.Get(StationParamConst.StationNo), HardwareVersion = Convert.ToSByte(_sysConfigService.Get(StationParamConst.StationNo)), }; return Result.Success(stationBaseInfoResp); } /// /// 站点编辑 /// [HttpPost("StationInfoEditor")] public void StationInfoEditor(List listStationBaseInfoReq) { foreach(var req in listStationBaseInfoReq) { _sysConfigService.Set(req.BaseStationInfoName, req.BaseStationInfoContent); } } /// /// 系统基础配置 上传图片 /// /// /// [HttpPost("ImgUpLoad")] public async Task ImgUpLoad([Required] IFormFile file) { return await _sysConfigService.UploadAvatar(file, _webHostEnvironment.WebRootPath); } } }