diff --git a/asg_form/Controllers/Store/Storehttp.cs b/asg_form/Controllers/Store/Storehttp.cs
index b1eef7b..86eb0b4 100644
--- a/asg_form/Controllers/Store/Storehttp.cs
+++ b/asg_form/Controllers/Store/Storehttp.cs
@@ -115,6 +115,9 @@ namespace asg_form.Controllers.Store
}
}
+
+
+
///
///
///
@@ -138,23 +141,24 @@ namespace asg_form.Controllers.Store
IQueryable b;
if (showVerification)
{
- b = sb.T_Storeinfo;
+ b = sb.T_Storeinfo.Include(a=>a.Store);
}
else
{
- b = sb.T_Storeinfo.Where(a=>a.isVerification==false);
+ b = sb.T_Storeinfo.Include(a => a.Store).Where(a => a.isVerification == false);
}
if (search_id == null)
{
a.cout = b.Count();
- a.msg = await b.Paginate(pageindex, pagesize).ToListAsync();
+ a.msg = await b.Paginate(pageindex, pagesize).Select(a => new { a.id, a.buyerid, a.Store.Price, a.Store.description, a.isVerification, a.Store.information, a.Store.Name }).ToListAsync();
}
else
{
a.cout = b.Where(a => a.buyerid == search_id).Count();
- a.msg = await b.Where(a => a.buyerid == search_id).Paginate(pageindex, pagesize).ToListAsync();
+ a.msg = await b.Where(a => a.buyerid == search_id).Paginate(pageindex, pagesize).Select(a => new { a.id, a.buyerid, a.Store.Price, a.Store.description, a.isVerification, a.Store.information, a.Store.Name }).ToListAsync();
}
+
return Ok(a);
}
}
@@ -185,7 +189,7 @@ namespace asg_form.Controllers.Store
List bureq = new List();
foreach (var item in storeid)
{
- var stort = await sb.T_Store.FindAsync(storeid);
+ var stort = await sb.T_Store.FindAsync(item);
try
{
user.Integral = cut_value((long)user.Integral, stort.Price);
diff --git a/asg_form/Controllers/admin.cs b/asg_form/Controllers/admin.cs
index 841fffd..b0d3372 100644
--- a/asg_form/Controllers/admin.cs
+++ b/asg_form/Controllers/admin.cs
@@ -218,11 +218,24 @@ else{
}
-
+ [Route("api/v1/admin/userfind/{userid}")]
+ [HttpGet]
+ [Authorize]
+ public async Task> getuser(long userid)
+ {
+
+ if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
+ {
+ return BadRequest(new error_mb { code = 400, message = "无权访问" });
+ }
+ return await userManager.Users.Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium }).FirstAsync(a=>a.Id==userid);
+ }
+
+
///
/// 获取所有用户-支持分页(整合api:allperson_c)
@@ -242,14 +255,14 @@ else{
if (keyword == null)
{
a.cout = userManager.Users.Count();
- a.msg = await userManager.Users.Paginate(pageindex, pagesize).ToListAsync();
+ a.msg = await userManager.Users.Paginate(pageindex, pagesize).Select(a => new {a.Id,a.Email,a.chinaname,a.UserName,a.Integral,a.officium}).ToListAsync();
}
else
{
a.cout = userManager.Users.Where(a=>a.chinaname==keyword||a.UserName==keyword||a.Email==keyword).Count();
- a.msg = await userManager.Users.Where(a => a.chinaname == keyword || a.UserName == keyword || a.Email == keyword).Paginate(pageindex, pagesize).ToListAsync();
+ a.msg = await userManager.Users.Where(a => a.chinaname == keyword || a.UserName == keyword || a.Email == keyword).Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium }).ToListAsync();
}
return Ok(a);
diff --git a/asg_form/Controllers/config.cs b/asg_form/Controllers/config.cs
index 2b1fbd3..3dee4fc 100644
--- a/asg_form/Controllers/config.cs
+++ b/asg_form/Controllers/config.cs
@@ -66,10 +66,8 @@ using(TestDbContext db=new TestDbContext()){
public async Task> config_get_title([FromBody] string title)
{
- if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
- {
- return BadRequest(new error_mb { code = 400, message = "无权访问" });
- }
+
+
using (TestDbContext db = new TestDbContext())
{
var config = db.T_config.FirstOrDefault(a => a.Title == title);
diff --git a/asg_form/Controllers/form_cs.cs b/asg_form/Controllers/form_cs.cs
index ebdf086..77f2e9b 100644
--- a/asg_form/Controllers/form_cs.cs
+++ b/asg_form/Controllers/form_cs.cs
@@ -1,4 +1,6 @@
+using System.Security.Cryptography;
+using System.Runtime.InteropServices.ComTypes;
using asg_form.Controllers.Hubs;
using Manganese.Text;
using Masuit.Tools;
@@ -20,6 +22,7 @@ using System.Text;
using System.Web;
using static asg_form.Controllers.excel;
using static ж;
+using Manganese.Array;
namespace asg_form.Controllers
{
@@ -161,7 +164,7 @@ namespace asg_form.Controllers
}
- ///
+ ///
/// ύ
///
/// Ϣ
@@ -243,6 +246,81 @@ namespace asg_form.Controllers
+ ///
+ /// ύ
+ ///
+ ///
+ /// Ϣ
+ /// ȸ˻֤֤
+ ///
+ [Route("api/v2/form/")]
+ [HttpPost]
+ public async Task> PostAsync(IFormFile imageFile,[FromForm] form_get_new for1)
+ {
+
+ TestDbContext ctx = new TestDbContext();
+
+
+ if (ctx.Forms.Include(a=>a.events).Where(a=>a.events.name==for1.events_name).Any(e => e.team_name == for1.team_name))
+ {
+ return BadRequest(new error_mb { code = 400, message = "" });
+ }
+ else
+ {
+ if (imageFile == null || imageFile.Length == 0)
+ return BadRequest("Invalid image file.");
+ // ļ浽
+ var filePath = Path.Combine(Directory.GetCurrentDirectory(), $"loge/{for1.events_name}/", $"{imageFile.FileName}");
+ using (var stream = new FileStream(filePath, FileMode.Create))
+ {
+ await imageFile.CopyToAsync(stream);
+ } // سɹӦ
+ // base64toimg(for1.logo_base64, $@"{AppDomain.CurrentDomain.BaseDirectory}loge\{for1.events_name}\{for1.team_name}.png");
+ var events= await ctx.events.FirstAsync(ctx => ctx.name == for1.events_name);
+
+
+ form form1 = new form();
+ form1.logo_uri = $"https://124.223.35.239/loge/{for1.events_name}/{for1.team_name}.png";
+ form1.team_name = for1.team_name;
+ form1.team_password = for1.team_password;
+ form1.team_tel = for1.team_tel;
+ form1.events = events;
+
+ List role = new List();
+ foreach (role_get a in for1.role_get)
+ {
+ role.Add(new role { role_id = a.role_id, role_lin = a.role_lin, role_name = a.role_name,Common_Roles=a.Common_Roles,Historical_Ranks=a.Historical_Ranks,Id_Card=a.Id_Card,Game_Name=a.Game_Name,Phone_Number=a.Phone_Number,Id_Card_Name=a.Id_Card_Name });
+ }
+ form1.role = role;
+
+ ctx.Forms.Add(form1);
+ await ctx.SaveChangesAsync();
+ int nownumber = ctx.Forms.Count();
+ //ChatRoomHub chat = new ChatRoomHub();
+ // await chat.formok(nownumber, for1.team_name);
+ try
+ {
+ await hubContext.Clients.All.SendAsync("formok", $"{for1.team_name}Ѿɹʣ{ctx.Forms.Count()}/32");
+
+ }
+ catch
+ {
+
+
+ }
+ logger.Info($"¶鱨ƣ{for1.team_name} ");
+ }
+
+
+ return "ok!";
+
+
+
+ }
+
+
+
+
public void base64toimg(string base64,string path)
{
@@ -393,6 +471,7 @@ namespace asg_form.Controllers
public async Task>> search_name(string team_name,string events_name)
{
var ctx = new TestDbContext();
+
var data = ctx.Forms.Where(a => a.team_name.IndexOf(team_name) >= 0&&a.events.name==events_name).Select(a => a.team_name).ToList();
return data;
}
@@ -440,6 +519,7 @@ namespace asg_form.Controllers
public string team_tel { get; set; }
public string logo_uri { get; set; }
public Events.T_events events { get; set; }
+
// public string? belong { get; set; }
public List role { get; set; } = new List();
}
@@ -447,11 +527,24 @@ namespace asg_form.Controllers
public class form_get
{
+ // public DateTime time { get; set; } = DateTime.Now;
+ public string team_name { get; set; }
+ public string team_password { get; set; }
+ public string team_tel { get; set; }
+ public string logo_base64 { get; set; }
+ public string events_name { get; set; }
+ // public string? belong { get; set; }
+ public List role_get { get; set; }
+ }
+
+ public class form_get_new
+ {
+
public DateTime time { get; set; } = DateTime.Now;
public string team_name { get; set; }
public string team_password { get; set; }
public string team_tel { get; set; }
- public string logo_base64 { get; set; }
+ // public string logo_base64 { get; set; }
public string events_name { get; set; }
// public string? belong { get; set; }
public List role_get { get; set; }
@@ -464,7 +557,7 @@ namespace asg_form.Controllers
{
public long Id { get; set; }
- public string team_name { get; set; }
+ public string Team_name { get; set; }
public string team_password { get; set; }
public string team_tel { get; set; }
diff --git a/asg_form/Controllers/login.cs b/asg_form/Controllers/login.cs
index ee6797d..82beb8f 100644
--- a/asg_form/Controllers/login.cs
+++ b/asg_form/Controllers/login.cs
@@ -259,13 +259,20 @@ namespace asg_form.Controllers
[Authorize]
[Route("api/v1/user/")]
[HttpGet]
- public async Task> getuser()
+ public async Task> getuser(bool showbase64=true)
{
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
var user = await userManager.FindByIdAsync(id);
var isadmin = await userManager.IsInRoleAsync(user, "admin");
List roles = (List)await userManager.GetRolesAsync(user);
- return new post_user { id = id.ToInt64(), Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
+ if (showbase64) {
+ return new post_user { id = id.ToInt64(), money = user.Integral, Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
+ }
+ else
+ {
+ return new post_user { id = id.ToInt64(), money = user.Integral, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
+
+ }
}
@@ -279,6 +286,7 @@ namespace asg_form.Controllers
public string? email { get; set; }
public bool isadmin { get; set; }
public string? officium { get; set; }
+ public long? money { get; set; }
public List? Roles { get; set; }
diff --git a/asg_form/Controllers/news.cs b/asg_form/Controllers/news.cs
index a60da7c..a421958 100644
--- a/asg_form/Controllers/news.cs
+++ b/asg_form/Controllers/news.cs
@@ -120,9 +120,51 @@ namespace asg_form.Controllers
}
+ ///
+ /// 修改新闻
+ ///
+ /// 新闻内容
+ ///
+ [Authorize]
+ [Route("api/v1/admin/news/")]
+ [HttpPut]
+ public async Task> Put([FromBody] req_news req_News,long newsid)
+ {
+ string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
+ var user = await userManager.FindByIdAsync(id);
+
+
+
+ bool a = await userManager.IsInRoleAsync(user, "admin");
+ if (a)
+ {
+ using (TestDbContext ctx = new TestDbContext())
+ {
+ var qwq= await ctx.news.FindAsync(newsid);
+ qwq.msg=req_News.msg;
+ qwq.Title=req_News.Title;
+ qwq.FormName = user.UserName;
+ await ctx.SaveChangesAsync();
+
+ }
+
+ return "ok!";
+ }
+ else
+ {
+ return "无权访问";
+ }
+
+ }
+
}
- public class T_news
+
+}
+
+
+
+public class T_news
{
public long Id { get; set; }
public string Title { get; set; }
@@ -144,4 +186,3 @@ namespace asg_form.Controllers
}
-}
\ No newline at end of file