实现接口和添加文件
This commit is contained in:
parent
75b2e279a0
commit
c24d526707
|
|
@ -179,7 +179,22 @@ namespace Competition.Mysql.BLL
|
|||
|
||||
#endregion BasicMethod
|
||||
#region ExtensionMethod
|
||||
/// <summary>
|
||||
/// 获取记录总数
|
||||
/// </summary>
|
||||
public int GetRecordentErpriseCount(string strWhere)
|
||||
{
|
||||
return dal.GetRecordentErpriseCount(strWhere);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得数据列表
|
||||
/// </summary>
|
||||
public List<Competition.Mysql.Model.v_model_version> GetErpriseList(string strWhere)
|
||||
{
|
||||
DataSet ds = dal.GetList(strWhere);
|
||||
return DataTableToList(ds.Tables[0]);
|
||||
}
|
||||
#endregion ExtensionMethod
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,4 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Other\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -387,7 +387,41 @@ namespace Competition.Mysql.DAL
|
|||
|
||||
#endregion BasicMethod
|
||||
#region ExtensionMethod
|
||||
/// <summary>
|
||||
/// 获取记录总数
|
||||
/// </summary>
|
||||
public int GetRecordentErpriseCount(string strWhere)
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("select count(1) FROM T_BAS_CORPORATION T1 left join v_model_version T2 on T2.MONITOR_ID=T1.MONITOR_ID ");
|
||||
if (strWhere.Trim() != "")
|
||||
{
|
||||
strSql.Append(" where " + strWhere);
|
||||
}
|
||||
object obj = DbHelperSQL.GetSingle(strSql.ToString());
|
||||
if (obj == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt32(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得数据列表
|
||||
/// </summary>
|
||||
public DataSet GetErpriseList(string strWhere)
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("select T1.MONITOR_ID,T1.MONITOR_NAME,T1.CUSTOMS_CODE,T2.ModelName,T2.VersionNumber,T2.MapLongitude,T2.MapLatitude,T2.TrainingSize,T2.ModelResources,T2.UpdateTime from T_BAS_CORPORATION T1 left join v_model_version T2 on T2.MONITOR_ID=T1.MONITOR_ID ");
|
||||
if (strWhere.Trim() != "")
|
||||
{
|
||||
strSql.Append(" where " + strWhere);
|
||||
}
|
||||
return DbHelperSQL.Query(strSql.ToString());
|
||||
}
|
||||
#endregion ExtensionMethod
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Competition.Mysql.Other
|
||||
{
|
||||
public class erprise_model_version
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,87 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Competition.Common.Util;
|
||||
using CompetitionAPI.api.version;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CompetitionAPI.Controllers.version
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class EditStarterController : ControllerBase
|
||||
public class EditStarterController : Controller
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
|
||||
Competition.Mysql.BLL.v_starter_version bll = new Competition.Mysql.BLL.v_starter_version();
|
||||
|
||||
public EditStarterController(IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑启动器接口
|
||||
/// </summary>
|
||||
/// <param name="req">请求参数</param>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
public JsonResult Index([FromBody] EditStarterRequest req)
|
||||
{
|
||||
//获取当前web目录
|
||||
var webRootPath = _webHostEnvironment.WebRootPath;
|
||||
if (string.IsNullOrWhiteSpace(req.StarterId))
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "版本id不能为空"));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(req.SoftwareName))
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "软件名称不能为空"));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(req.VersionNumber))
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "版本号不能为空"));
|
||||
}
|
||||
if (!System.IO.File.Exists(webRootPath + "/" + req.LauncherResources))
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "启动器资源不存在,请先上传启动器资源"));
|
||||
}
|
||||
if (!System.IO.File.Exists(webRootPath + "/" + req.UpdateResources))
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "更新包资源不存在,请先上传更新包资源"));
|
||||
}
|
||||
|
||||
var model = bll.GetModel(req.StarterId);
|
||||
model.SoftwareName = req.SoftwareName;
|
||||
model.VersionNumber = req.VersionNumber;
|
||||
var old_launcher_resources = model.LauncherResources;
|
||||
model.LauncherResources = req.LauncherResources;
|
||||
var old_update_resources = model.UpdateResources;
|
||||
model.UpdateResources = req.UpdateResources;
|
||||
|
||||
if (bll.Update(model))
|
||||
{
|
||||
if (req.LauncherResources != old_launcher_resources)
|
||||
{
|
||||
if (System.IO.File.Exists(webRootPath + "/" + old_launcher_resources))
|
||||
{
|
||||
System.IO.File.Delete(webRootPath + "/" + old_launcher_resources);
|
||||
}
|
||||
}
|
||||
if (req.UpdateResources != old_update_resources)
|
||||
{
|
||||
if (System.IO.File.Exists(webRootPath + "/" + old_update_resources))
|
||||
{
|
||||
System.IO.File.Delete(webRootPath + "/" + old_update_resources);
|
||||
}
|
||||
}
|
||||
return Json(Tool.GetJsonWithCode(APICode.Success, "编辑成功!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json(Tool.GetJsonWithCode(APICode.Fail, "编辑失败!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,62 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Competition.Common.Util;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text;
|
||||
|
||||
namespace CompetitionAPI.Controllers.version
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class GetModelListController : ControllerBase
|
||||
public class GetModelListController : Controller
|
||||
{
|
||||
Competition.Mysql.BLL.v_model_version bll = new Competition.Mysql.BLL.v_model_version();
|
||||
|
||||
public GetModelListController()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取模型版本列表接口
|
||||
/// </summary>
|
||||
/// <param name="EnterpriseName">企业名称</param>
|
||||
/// <param name="EnterpriseCode">企业编码</param>
|
||||
/// <param name="ModelName">模型名称/param>
|
||||
/// <param name="PageIndex">页码/param>
|
||||
/// <param name="PageSize">每页数量/param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public JsonResult Index(int PageIndex, int PageSize, string EnterpriseName = "", string EnterpriseCode = "", string ModelName = "")
|
||||
{
|
||||
var query = new StringBuilder(" 1 = 1 ");
|
||||
var total_query = new StringBuilder(" 1 = 1 ");
|
||||
|
||||
//学习名称
|
||||
if (!string.IsNullOrWhiteSpace(StudyName))
|
||||
{
|
||||
query.AppendFormat(" AND StudyName LIKE '%{0}%'", StudyName);
|
||||
total_query.AppendFormat(" AND StudyName LIKE '%{0}%' ", StudyName);
|
||||
}
|
||||
|
||||
//学习分类
|
||||
if (!string.IsNullOrWhiteSpace(StudyClass))
|
||||
{
|
||||
query.AppendFormat(" AND StudyClass='{0}' ", StudyClass);
|
||||
total_query.AppendFormat(" AND StudyClass='{0}' ", StudyClass);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Status))
|
||||
{
|
||||
query.AppendFormat(" AND Status='{0}' ", Status);
|
||||
total_query.AppendFormat(" AND Status='{0}' ", Status);
|
||||
}
|
||||
|
||||
var offset = (PageIndex - 1) * PageSize;
|
||||
query.AppendFormat(" order by CreateTime desc LIMIT {0} OFFSET {1} ", PageSize, offset);
|
||||
|
||||
var total = bll.GetRecordCount(total_query.ToString());
|
||||
var list = bll.GetModelList(query.ToString());
|
||||
return Json(Tool.GetJsonWithCode(APICode.Success, new { total = total, list = list }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,29 +8,24 @@ namespace CompetitionAPI.Controllers.version
|
|||
[ApiController]
|
||||
public class GetStarterListController : Controller
|
||||
{
|
||||
//Competition.Mysql.BLL.v bll = new Competition.Mysql.BLL.T_BAS_CORPORATION();
|
||||
Competition.Mysql.BLL.v_starter_version bll = new Competition.Mysql.BLL.v_starter_version();
|
||||
|
||||
|
||||
//public GetStarterListController()
|
||||
//{
|
||||
public GetStarterListController()
|
||||
{
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 获取企业接口
|
||||
///// </summary>
|
||||
///// <param name="req"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//public JsonResult Index()
|
||||
//{
|
||||
// //读取配置文件示例
|
||||
// var mysql = Configuration.GetConnectionString("MySQL").ToString();
|
||||
|
||||
// //查询企业表所有数据
|
||||
// var list = bll.GetModelList("");
|
||||
|
||||
// return Json(Tool.GetJsonWithCode(APICode.Success, list));
|
||||
//}
|
||||
/// <summary>
|
||||
/// 获取启动器列表接口
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public JsonResult Index()
|
||||
{
|
||||
var list = bll.GetModelList("");
|
||||
return Json(Tool.GetJsonWithCode(APICode.Success, list));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,32 @@
|
|||
namespace CompetitionAPI.api.version
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
namespace CompetitionAPI.api.version
|
||||
{
|
||||
public class EditStarterRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 版本id
|
||||
/// </summary>
|
||||
public string StarterId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 软件名称
|
||||
/// </summary>
|
||||
public string SoftwareName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
public string VersionNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 启动器资源
|
||||
/// </summary>
|
||||
public string LauncherResources { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新包资源
|
||||
/// </summary>
|
||||
public string UpdateResources { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue