This commit is contained in:
zpc 2025-08-04 17:15:17 +08:00
parent e782dfb3b3
commit 6efa617d52
2 changed files with 20 additions and 63 deletions

View File

@ -217,65 +217,5 @@ namespace ZR.Admin.WebApi.Controllers
string fileName = Path.GetFileName(fullPath);
return DownFile(fullPath, fileName);
}
/// <summary>
/// 初始化种子数据
/// </summary>
/// <param name="clean">是否清空数据</param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
[ActionPermissionFilter(Permission = "common")]
[Log(BusinessType = BusinessType.INSERT, Title = "初始化数据")]
public IActionResult InitSeedData(bool clean = false)
{
if (!WebHostEnvironment.IsDevelopment())
{
return ToResponse(ResultCode.CUSTOM_ERROR, "导入数据失败,请在开发模式下初始化");
}
var path = Path.Combine(WebHostEnvironment.WebRootPath, "data.xlsx");
SeedDataService seedDataService = new();
var result = seedDataService.InitSeedData(path, clean);
Console.ForegroundColor = ConsoleColor.Red;
foreach (var item in result)
{
Console.WriteLine(item);
}
Console.ForegroundColor = ConsoleColor.White;
return SUCCESS(new
{
result
});
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
[ActionPermissionFilter(Permission = "common")]
[Log(BusinessType = BusinessType.INSERT, Title = "初始化数据")]
public IActionResult UpdateSeedData()
{
if (!WebHostEnvironment.IsDevelopment())
{
return ToResponse(ResultCode.CUSTOM_ERROR, "导入数据失败,请在开发模式下初始化");
}
var path = Path.Combine(WebHostEnvironment.WebRootPath, "data.xlsx");
SeedDataService seedDataService = new();
var sysNotice = MiniExcel.Query<SysNotice>(path, sheetName: "notice").ToList();
var result = seedDataService.InitNoticeData(sysNotice);
var sysMenu = MiniExcel.Query<SysMenu>(path, sheetName: "menu").Where(f => f.MenuId >= 1104).ToList();
var result5 = seedDataService.InitMenuData(sysMenu);
return SUCCESS(new
{
result,
result5
});
}
}
}

View File

@ -29,17 +29,19 @@ namespace ZR.Admin.WebApi.Controllers
/// 微信用户表接口
/// </summary>
private readonly IGiftUserService _GiftUserService;
public WebApiController(WechatApiClient client, IGiftUserService GiftUserService, IGiftClaimService giftClaimService)
private ISysFileService SysFileService;
public WebApiController(WechatApiClient client, IGiftUserService GiftUserService, IGiftClaimService giftClaimService, ISysFileService sysFileService)
{
_client = client;
_GiftUserService = GiftUserService;
_GiftClaimService = giftClaimService;
SysFileService = sysFileService;
}
/// <summary>
/// 1
///
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
@ -108,6 +110,7 @@ namespace ZR.Admin.WebApi.Controllers
return SUCCESS(list1);
}
public static string domainUrl = AppSettings.GetConfig("ALIYUN_OSS:domainUrl");
[HttpPost()]
[Route("/addRecord")]
[AllowAnonymous]
@ -169,10 +172,24 @@ namespace ZR.Admin.WebApi.Controllers
ProductSerialNumber = giftClaim.ProductSerialNumber,
CreatedAt = DateTime.Now,
ProductImage = finalPath,
UserWxOpenId= user.Openid
UserWxOpenId = user.Openid
};
_GiftClaimService.AddGiftClaim(giftClaim1);
return SUCCESS(new { giftClaim1.Id });
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpGet()]
[Route("/getBannerList")]
[AllowAnonymous]
public async Task<IActionResult> GetBannerList()
{
var list = await SysFileService.AsQueryable().Where(it => it.ClassifyType == "banner").Select(it =>
new { it.AccessUrl, it.RealName }).ToListAsync();
return SUCCESS(list);
}
}
}