增加主账号配置上货参数
This commit is contained in:
1 parent
34b1d39108
commit
08f8e2009f
5 files changed
+96
-3
No files matched your search
@@ -21,6 +21,32 @@ namespace KJD_Web.Controllers
|
||||
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
[HttpPost]
|
||||
public IHttpActionResult GetUserConfig(SignRequestBase request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var config = _userService.GetUserConfig(request.UserName);
|
||||
return Ok(ApiResult.Success(data: config));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(ApiResult.Fail(ex.Message));
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public IHttpActionResult SaveUserConfig(UserConfigRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var config = _userService.SaveUserConfig(request.UserName, request.Config);
|
||||
return Ok(ApiResult.Success(config));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(ApiResult.Fail(ex.Message));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
|
||||
@@ -229,6 +229,7 @@
|
||||
<Compile Include="Requests\Shops\ShopStatsRequest.cs" />
|
||||
<Compile Include="Requests\Users\CUUserInfoRequest.cs" />
|
||||
<Compile Include="Requests\Users\RebateRecordRequest.cs" />
|
||||
<Compile Include="Requests\Users\UserConfigRequest.cs" />
|
||||
<Compile Include="Responses\Shops\ShopOrderDetailResponse.cs" />
|
||||
<Compile Include="Responses\Shops\ShopStatsResponse.cs" />
|
||||
<Compile Include="Responses\Shops\ShopStatsTrendResponse.cs" />
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Store.Framework.Dtos;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace KJD_Web.Requests.Users;
|
||||
|
||||
public class UserConfigRequest:SignRequestBase
|
||||
{
|
||||
public string Config { get; set; }
|
||||
}
|
||||
@@ -15,6 +15,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ubiety.Dns.Core;
|
||||
using YourNamespace;
|
||||
|
||||
@@ -44,7 +45,19 @@ namespace KJD_Web.Services.Users
|
||||
{
|
||||
return GetOEMByUserName(userName) != null;
|
||||
}
|
||||
|
||||
public UserEntity GetMainUser(string userName)
|
||||
{
|
||||
var user = _freeSql.Select<UserEntity>().Where(u => u.UserName == userName).First();
|
||||
return user == null ? null : GetMainUser(user);
|
||||
}
|
||||
private UserEntity GetMainUser(UserEntity user)
|
||||
{
|
||||
if (user.IsMainUser) return user;
|
||||
var parent = _freeSql.Select<UserEntity>().Where(u => u.UserName == user.ParentUserName).First();
|
||||
if (parent == null || !parent.IsMainUser)
|
||||
throw new Exception("主账号不存在或账号关系无效,请联系管理员");
|
||||
return parent;
|
||||
}
|
||||
public UserEntity GetUserByUserName(string userName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userName)) return null;
|
||||
@@ -466,7 +479,29 @@ namespace KJD_Web.Services.Users
|
||||
work.Commit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户配置
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public string GetUserConfig(string userName)
|
||||
{
|
||||
var user = GetMainUser(userName);
|
||||
var item = _freeSql.Select<UserConfig>()
|
||||
.Where(a => a.UserName == user.UserName)
|
||||
.First();
|
||||
if (item != null && !string.IsNullOrEmpty(item.UserName))
|
||||
{
|
||||
return item.Config;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public bool SaveUserConfig(string userName, string config)
|
||||
{
|
||||
var affrows = _freeSql.InsertOrUpdate<UserConfig>()
|
||||
.SetSource(new UserConfig { UserName = userName, Config = config })
|
||||
.ExecuteAffrows();
|
||||
return affrows == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Contracts.User.Entitys;
|
||||
|
||||
[Table(Name = "wxxd.user_config")]
|
||||
|
||||
public class UserConfig
|
||||
{
|
||||
[Column(IsPrimary = true, Name = "user_name")]
|
||||
public string UserName { get; set; }
|
||||
[Column(Name = "config")]
|
||||
|
||||
public string Config { get; set; }
|
||||
}
|
||||
Reference in new issue
Block a user