2024-08-03 20:40:34 +08:00
|
|
|
|
using Manganese.Text;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System.Security.Claims;
|
2024-09-08 16:35:39 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
|
|
|
|
namespace asg_form.Controllers
|
|
|
|
|
{
|
2025-01-27 20:32:23 +08:00
|
|
|
|
|
|
|
|
|
|
2025-02-09 19:17:34 +08:00
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
public class comform : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly RoleManager<Role> roleManager;
|
|
|
|
|
private readonly UserManager<User> userManager;
|
|
|
|
|
|
|
|
|
|
public comform(
|
|
|
|
|
RoleManager<Role> roleManager, UserManager<User> userManager)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.roleManager = roleManager;
|
|
|
|
|
this.userManager = userManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Route("api/v1/comform")]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public async Task<ActionResult<string>> getschedle_c([FromBody]req_com_form req)
|
|
|
|
|
{
|
|
|
|
|
int id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value.ToInt32();
|
2024-09-08 16:35:39 +08:00
|
|
|
|
// var user = await userManager.Users.FirstAsync(a=>a.Id==id);
|
|
|
|
|
var dateString = DateTime.Now;
|
2024-08-03 20:40:34 +08:00
|
|
|
|
TestDbContext testDb = new TestDbContext();
|
|
|
|
|
var result = new com_form
|
|
|
|
|
{
|
2024-09-08 16:35:39 +08:00
|
|
|
|
comSex = req.sex,
|
2024-08-03 20:40:34 +08:00
|
|
|
|
Com_Cocial_media = req.Com_Cocial_media,
|
|
|
|
|
Com_qq = req.Com_qq,
|
|
|
|
|
UserId=id,
|
2024-09-08 19:07:33 +08:00
|
|
|
|
Status = "0",
|
2024-08-03 20:40:34 +08:00
|
|
|
|
introduction = req.introduction,
|
2024-09-08 16:35:39 +08:00
|
|
|
|
idv_id=req.idv_id,
|
|
|
|
|
createTime = dateString.ToString(),
|
2024-08-03 20:40:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
testDb.com_Forms.Add(result);
|
|
|
|
|
await testDb.SaveChangesAsync();
|
|
|
|
|
return Ok("成功!");
|
|
|
|
|
}
|
|
|
|
|
[Route("api/v1/admin/comform")]
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Authorize]
|
2024-09-08 16:35:39 +08:00
|
|
|
|
public async Task<ActionResult<string>> getschedle_c(short page, short limit)
|
2024-08-03 20:40:34 +08:00
|
|
|
|
{
|
|
|
|
|
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
|
|
|
|
{
|
2024-09-08 16:35:39 +08:00
|
|
|
|
using (TestDbContext sub = new TestDbContext())
|
2024-08-03 20:40:34 +08:00
|
|
|
|
{
|
2024-09-08 16:35:39 +08:00
|
|
|
|
var query = sub.com_Forms.AsQueryable();
|
|
|
|
|
|
|
|
|
|
var TotalRecords = await query.CountAsync();
|
|
|
|
|
|
|
|
|
|
var signData = await query
|
|
|
|
|
.OrderByDescending(a => a.Status)
|
|
|
|
|
.Skip((page - 1) * limit)
|
|
|
|
|
.Take(limit)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var result = new
|
|
|
|
|
{
|
|
|
|
|
rows = signData,
|
|
|
|
|
total = TotalRecords,
|
|
|
|
|
};
|
|
|
|
|
return Ok(result);
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
2024-09-08 16:35:39 +08:00
|
|
|
|
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
2024-09-08 16:35:39 +08:00
|
|
|
|
return Ok(new error_mb { code = 400, message = "没有管理员,无法获取" });
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
[Route("api/v1/admin/user")]
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public async Task<ActionResult<User>> getschedle_c(long userid)
|
|
|
|
|
{
|
|
|
|
|
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
|
|
|
|
{
|
|
|
|
|
return await userManager.FindByIdAsync(userid.ToString());
|
|
|
|
|
}
|
|
|
|
|
return BadRequest(new error_mb { code = 400, message = "没有管理员,无法获取" });
|
|
|
|
|
}
|
|
|
|
|
[Route("api/v1/admin/comform_ok")]
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public async Task<ActionResult<string>> ok_comform(long comform_id)
|
|
|
|
|
{
|
|
|
|
|
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TestDbContext testDb = new TestDbContext();
|
|
|
|
|
|
|
|
|
|
var comform = await testDb.com_Forms.FirstAsync(a=>a.Id == comform_id);
|
2024-09-08 19:07:33 +08:00
|
|
|
|
comform.Status = "1";
|
2024-08-03 20:40:34 +08:00
|
|
|
|
await testDb.SaveChangesAsync();
|
|
|
|
|
var ouser = await userManager.FindByIdAsync(comform.UserId.ToString());
|
|
|
|
|
ouser.officium = "Commentator";
|
|
|
|
|
|
|
|
|
|
await userManager.UpdateAsync(ouser);
|
|
|
|
|
admin.SendEmail(ouser.Email, "ASG赛事组", $@"<div>
|
|
|
|
|
<includetail>
|
|
|
|
|
<table style=""font-family: Segoe UI, SegoeUIWF, Arial, sans-serif; font-size: 12px; color: #333333; border-spacing: 0px; border-collapse: collapse; padding: 0px; width: 580px; direction: ltr"">
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style=""font-size: 10px; padding: 0px 0px 7px 0px; text-align: right"">
|
|
|
|
|
{ouser.chinaname} ,欢迎加入ASG赛事组。
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr style=""background-color: #0078D4"">
|
|
|
|
|
<td style=""padding: 0px"">
|
|
|
|
|
<table style=""font-family: Segoe UI, SegoeUIWF, Arial, sans-serif; border-spacing: 0px; border-collapse: collapse; width: 100%"">
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style=""font-size: 38px; color: #FFFFFF; padding: 12px 22px 4px 22px"" colspan=""3"">
|
|
|
|
|
欢迎
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style=""font-size: 20px; color: #FFFFFF; padding: 0px 22px 18px 22px"" colspan=""3"">
|
|
|
|
|
欢迎{ouser.chinaname}加入ASG赛事组。
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style=""padding: 30px 20px; border-bottom-style: solid; border-bottom-color: #0078D4; border-bottom-width: 4px"">
|
|
|
|
|
<table style=""font-family: Segoe UI, SegoeUIWF, Arial, sans-serif; font-size: 12px; color: #333333; border-spacing: 0px; border-collapse: collapse; width: 100%"">
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style=""font-size: 12px; padding: 0px 0px 5px 0px"">
|
|
|
|
|
你的职位已经被设置为Commentator。
|
|
|
|
|
<ul style=""font-size: 14px"">
|
|
|
|
|
<li style=""padding-top: 10px"">
|
|
|
|
|
对此次执行有疑问请联系我们的QQ:2667210109。
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
请不要回复此邮件。如果你需要帮助,请联系我们。
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
请加入对应职位的群聊。
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style=""padding: 0px 0px 10px 0px; color: #B2B2B2; font-size: 12px"">
|
|
|
|
|
版权所有 ASG赛事官网
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</includetail>
|
|
|
|
|
</div>
|
|
|
|
|
");
|
|
|
|
|
return "成功!";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return BadRequest(new error_mb { code = 400, message = "没有管理员,无法设置" });
|
|
|
|
|
}
|
|
|
|
|
[Route("api/v1/admin/comform_no")]
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public async Task<ActionResult<string>> no_comform(long comform_id)
|
|
|
|
|
{
|
|
|
|
|
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TestDbContext testDb = new TestDbContext();
|
|
|
|
|
|
|
|
|
|
var comform = await testDb.com_Forms.FirstAsync(a => a.Id == comform_id);
|
2024-09-08 19:07:33 +08:00
|
|
|
|
comform.Status ="2";
|
2024-08-03 20:40:34 +08:00
|
|
|
|
var ouser =await userManager.FindByIdAsync(comform.UserId.ToString());
|
|
|
|
|
await testDb.SaveChangesAsync();
|
|
|
|
|
admin.SendEmail(ouser.Email, "ASG赛事组", $@"很抱歉,你的解说申请未通过");
|
|
|
|
|
return "成功!";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return BadRequest(new error_mb { code = 400, message = "没有管理员,无法设置" });
|
|
|
|
|
}
|
|
|
|
|
public class req_com_form
|
|
|
|
|
{
|
|
|
|
|
|
2024-09-08 16:35:39 +08:00
|
|
|
|
public string sex { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
public string? Com_Cocial_media { get; set; }
|
|
|
|
|
public string idv_id { get; set; }
|
|
|
|
|
public string introduction { get; set; }
|
|
|
|
|
public string Com_qq { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public class com_form
|
|
|
|
|
{
|
|
|
|
|
public long Id { get; set; }
|
|
|
|
|
public int UserId { get; set; }
|
2024-09-08 16:35:39 +08:00
|
|
|
|
public string comSex { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
public string? Com_Cocial_media { get; set; }
|
|
|
|
|
public string idv_id { get; set; }
|
|
|
|
|
public string introduction { get; set; }
|
|
|
|
|
public string Com_qq { get; set; }
|
2024-09-08 19:07:33 +08:00
|
|
|
|
public string Status { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|
2024-09-08 16:35:39 +08:00
|
|
|
|
public string createTime { get; set; }
|
2024-08-03 20:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-09 19:48:48 +08:00
|
|
|
|
|
2024-10-09 13:39:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-08-03 20:40:34 +08:00
|
|
|
|
|