我在车上写代码+w-
This commit is contained in:
		
							parent
							
								
									c032925127
								
							
						
					
					
						commit
						eab867e85a
					
				
							
								
								
									
										93
									
								
								asg_form/Controllers/Budget/BgCountController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								asg_form/Controllers/Budget/BgCountController.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,93 @@
 | 
				
			|||||||
 | 
					using asg_form.Controllers.Teamregistration;
 | 
				
			||||||
 | 
					using Microsoft.AspNetCore.Authorization;
 | 
				
			||||||
 | 
					using Microsoft.AspNetCore.Identity;
 | 
				
			||||||
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
 | 
					using System.Security.Claims;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace asg_form.Controllers.Budget
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class BgDB
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public long id { get; set; }
 | 
				
			||||||
 | 
					        public string budget_year { get; set; }
 | 
				
			||||||
 | 
					        public long budget_money { get; set; }
 | 
				
			||||||
 | 
					        public string budget_type { get; set; }
 | 
				
			||||||
 | 
					        public string budget_name { get; set; }
 | 
				
			||||||
 | 
					        public string budget_used { get; set; }
 | 
				
			||||||
 | 
					        public string source_event_name { get; set; }
 | 
				
			||||||
 | 
					        public long source_event_id { get; set; }
 | 
				
			||||||
 | 
					        public string used_event_name { get; set; }
 | 
				
			||||||
 | 
					        public long used_event_id { get; set; }
 | 
				
			||||||
 | 
					        //public string use_person {} 
 | 
				
			||||||
 | 
					        //public long use_person_id { get; set; }
 | 
				
			||||||
 | 
					        public string change_time { get; set; }
 | 
				
			||||||
 | 
					        public string use_status { get; set; }
 | 
				
			||||||
 | 
					        public string? update_person { get; set; }//设置默认
 | 
				
			||||||
 | 
					        public string? update_time { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class BgCountController : ControllerBase
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private readonly RoleManager<Role> roleManager;
 | 
				
			||||||
 | 
					        private readonly UserManager<User> userManager;
 | 
				
			||||||
 | 
					        public BgCountController(
 | 
				
			||||||
 | 
					            RoleManager<Role> roleManager, UserManager<User> userManager)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            this.roleManager = roleManager;
 | 
				
			||||||
 | 
					            this.userManager = userManager;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        private class bgMsg
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public string budgetYear { get; set; }
 | 
				
			||||||
 | 
					            public int budgetMoney { get; set;}
 | 
				
			||||||
 | 
					            public string budgetType { get; set; }
 | 
				
			||||||
 | 
					            public string budgetName { get; set; }
 | 
				
			||||||
 | 
					            public string sourceEventName { get; set; }
 | 
				
			||||||
 | 
					            public long sourceEventId { get; set; }
 | 
				
			||||||
 | 
					            public string budgetUsed {  get; set; }
 | 
				
			||||||
 | 
					            public string usedEventName { get;set; }
 | 
				
			||||||
 | 
					            public long usedEventId { get; set; }
 | 
				
			||||||
 | 
					            public string updatePerson { get; set; }
 | 
				
			||||||
 | 
					            public string updateTime { get; set; }//自动生成时间
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        [Route("api/v1/admin/insertBg")]
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        [Authorize]
 | 
				
			||||||
 | 
					        public async Task<ActionResult<object>> InBg([FromBody] bgMsg msg)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return Ok(new error_mb { code = 401, message = "无权访问" });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (msg == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return Ok(new error_mb { code = 500, message = "请插入必要字段" });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            var dateString = DateTime.Now.ToString(); ;
 | 
				
			||||||
 | 
					            using(TestDbContext sub =  new TestDbContext())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var budget = new BgDB
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    budget_year = msg.budgetYear,
 | 
				
			||||||
 | 
					                    budget_money = msg.budgetMoney,
 | 
				
			||||||
 | 
					                    budget_type = msg.budgetType,
 | 
				
			||||||
 | 
					                    budget_name = msg.budgetName,
 | 
				
			||||||
 | 
					                    budget_used = msg.budgetUsed,
 | 
				
			||||||
 | 
					                    source_event_name = msg.sourceEventName,
 | 
				
			||||||
 | 
					                    source_event_id = msg.sourceEventId,
 | 
				
			||||||
 | 
					                    change_time = dateString,
 | 
				
			||||||
 | 
					                    used_event_name = msg.usedEventName,
 | 
				
			||||||
 | 
					                    used_event_id = msg.usedEventId,
 | 
				
			||||||
 | 
					                    use_status = "0",
 | 
				
			||||||
 | 
					                    update_person = null,
 | 
				
			||||||
 | 
					                    update_time = null,
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					            sub.budgetDetails.Add(budget);
 | 
				
			||||||
 | 
					            await sub.SaveChangesAsync();
 | 
				
			||||||
 | 
					            return Ok(new error_mb { code = 200, message = "新增预算成功" });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					using asg_form.Controllers.Budget;
 | 
				
			||||||
using asg_form.Controllers.Store;
 | 
					using asg_form.Controllers.Store;
 | 
				
			||||||
using asg_form.Controllers.Team;
 | 
					using asg_form.Controllers.Team;
 | 
				
			||||||
using asg_form.Controllers.Teamregistration;
 | 
					using asg_form.Controllers.Teamregistration;
 | 
				
			||||||
@ -239,6 +240,7 @@ namespace asg_form.Controllers
 | 
				
			|||||||
        public DbSet<T_config> T_config { get; set; }
 | 
					        public DbSet<T_config> T_config { get; set; }
 | 
				
			||||||
        public DbSet<TaskDB> T_Task { get; set; }
 | 
					        public DbSet<TaskDB> T_Task { get; set; }
 | 
				
			||||||
        public DbSet<ComformDB> T_Comform { get; set; }
 | 
					        public DbSet<ComformDB> T_Comform { get; set; }
 | 
				
			||||||
 | 
					        public DbSet<BgDB> budgetDetails { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 | 
					        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user