Admin.net框架
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

5 days ago
namespace Admin.NET.Core.Service;
/// <summary>
/// 微信账号服务
/// </summary>
[ApiDescriptionSettings(Order = 220)]
public class SysWechatUserService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<SysWechatUser> _sysWechatUserRep;
public SysWechatUserService(SqlSugarRepository<SysWechatUser> sysWechatUserRep)
{
_sysWechatUserRep = sysWechatUserRep;
}
/// <summary>
/// 获取微信用户列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[DisplayName("获取微信用户列表")]
public async Task<SqlSugarPagedList<SysWechatUser>> Page(WechatUserInput input)
{
return await _sysWechatUserRep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.NickName), u => u.NickName.Contains(input.NickName))
.WhereIF(!string.IsNullOrWhiteSpace(input.PhoneNumber), u => u.Mobile.Contains(input.PhoneNumber))
.OrderBy(u => u.Id, OrderByType.Desc)
.ToPagedListAsync(input.Page, input.PageSize);
}
/// <summary>
/// 增加微信用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "Add"), HttpPost]
[DisplayName("增加微信用户")]
public async Task AddWechatUser(SysWechatUser input)
{
await _sysWechatUserRep.InsertAsync(input.Adapt<SysWechatUser>());
}
/// <summary>
/// 更新微信用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "Update"), HttpPost]
[DisplayName("更新微信用户")]
public async Task UpdateWechatUser(SysWechatUser input)
{
var weChatUser = input.Adapt<SysWechatUser>();
await _sysWechatUserRep.AsUpdateable(weChatUser).IgnoreColumns(true).ExecuteCommandAsync();
}
/// <summary>
/// 删除微信用户
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "Delete"), HttpPost]
[DisplayName("删除微信用户")]
public async Task DeleteWechatUser(DeleteWechatUserInput input)
{
await _sysWechatUserRep.DeleteAsync(u => u.Id == input.Id);
}
}