server/aspnetapp/Controllers/WebApi/AuthController.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using aspnetapp.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using RestSharp;
using System.Text.Json;

namespace aspnetapp.Controllers.WebApi
{
    [Route("api/[controller]")]
    [ApiController]
    public class AuthController : ControllerBase
    {
        private readonly CounterContext _context;

        public AuthController(CounterContext context)
        {
            _context = context;
        }

        // GET: api/<AuthController>
        [HttpGet]
        public async Task<ActionResult> GetAsync(string APP_ID, string js_code)
        {
            string APP_SECRET = Environment.GetEnvironmentVariable("APP_SECRET") ?? "";
            string WX_LOGIN_API = "https://api.weixin.qq.com/sns/jscode2session?appid=" + APP_ID + "&secret=" + APP_SECRET + "&js_code=" + js_code + "&grant_type=authorization_code";
            RestClient? client = new RestClient(WX_LOGIN_API);
            RestRequest? request = new RestRequest();
            RestResponse? response = await client.ExecuteGetAsync(request);
            Console.WriteLine(response.Content);

            if (response.IsSuccessful)
            {
                WXj2s? wxj2s =
                    JsonSerializer.Deserialize<WXj2s>(response.Content);
                BuyrUserEntity thisu = await _context.BuyrUsers.FirstOrDefaultAsync(s => s.WeChatOpenid == wxj2s.openid).ConfigureAwait(false);
                if (thisu != null)
                {
                    if (thisu.Nation == (int)EnumCode.Mz.维吾尔族)
                    {
                        thisu.Nation = (int)EnumCode.Mz.回族;
                    }

                    if (thisu.Nation == (int)EnumCode.Mz.蒙古族)
                    {
                        thisu.Nation = (int)EnumCode.Mz.回族;
                    }
                    DateTime now = DateTime.Now;
                    DateTime today = new DateTime(now.Year, now.Month, now.Day);
                    DateTime tomorrow = new DateTime(now.Year, now.Month, now.Day).AddDays(1);
                    SysSettings? syssettings = await _context.Settings.FirstOrDefaultAsync().ConfigureAwait(false);
                    List<OrderEntity> hasOrderList = await _context.Orders.Where(s => s.OrderStatus != (int)EnumCode.OrderStatus.已取消 && s.BuyUserWxId == thisu.WeChatOpenid && (s.OrderForDate == today || s.OrderForDate == tomorrow)).ToListAsync().ConfigureAwait(false);

                    List<bool> canbookCategories = new List<bool>();
                    List<bool> hasorderCategories = new List<bool>();

                    canbookCategories.Clear();
                    List<CategoryEntity>? cagList = await _context.Categories.Where(s => s.IsDeleted == (int)EnumCode.yesno.否).ToListAsync().ConfigureAwait(false);
                    #region 订餐页面
                    foreach (CategoryEntity category in cagList)
                    {
后面还有 107 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。