1.注入报错
Castle.MicroKernel.Handlers.HandlerException: Can't create component 'PaymentCore.Users.PayApiAppService' as it has dependencies to be satisfied.
'PaymentCore.Users.PayApiAppService' is waiting for the following dependencies:
- Service 'PaymentCore.Payment.WXPayApi.NativePay' which was not registered.
- Service 'PaymentCore.Payment.AliPayApi.QRCode' which was not registered.
- Service 'PaymentCore.Payment.AliPayApi.PayDataHandle' which was not registered.
- Service 'Alipay.AopSdk.AspnetCore.AlipayService' which was not registered.
解决办法:
注入的方法实现接口 ITransientDependency
2.多表查询
var query = _goodsRepository.GetAll()
.Join(
_devicegoodsRepository.GetAll().Where(p => p.DeviceNo == input.deviceNo),
top => top.Code,
art => art.GoodsNo,
(top, art) => new GoodsDto
{
GoodsNo= top.Code,
GoodsName=top.Name,
Description=top.Description,
Unit=top.Unit,
Price=art.Price,
ProductId=top.ProductId,
LastModificationTime = art.LastModificationTime,
GoodsQty=1//设置默认数量
});
var list = await query
.PageBy(input)
.ToListAsync();
3.code first 命令
add-migration <name>;
update-database;
4.前端要能访问接口
①实现接口里面定义
②方法后面要加Async
③方法名不能有Post
5.外部引用的接口eg:AlipayService 注入方法
[Abp.Modules.DependsOn(typeof(AlipayService))]
6.abp权限菜单管理备忘
(1) 菜单需要在前端routes.ts中配置,配置完后,①到系统菜单界面配置菜单②角色界面勾选添加权限菜单(对应BasRoleMenu表)
(2)admin没有tenantId的是宿主,也就是总管理员可以添加租户的,在添加租户的时候会默认添加一个admin租户角色,同时会添加除了tanant页面之外的所有菜单权限
(3)租户下面的admin不能看到租户界面
7.GroupBy使用示例
var list = _goodsRepository.GetAll()
.Where(x => x.TenantId == tenantId)
.Join(_deviceRepository.GetAll()
.Where(x => x.TenantId == tenantId),
f => 1,
s => 1,
(f, s) => new PriceDto {
goodsNo = f.Code,
goodsName = f.Name,
deviceNo = s.Code,
deviceName=s.Name
}).ToList();
var query = list.GroupBy(x => new { x.goodsNo,x.goodsName }).ToList();
goodsList= query.Select(x => new GoodsDeviceTreeDto
{
value = x.Key.goodsNo,
label = x.Key.goodsName,
children = x.Select(y => new GoodsDeviceTreeDto
{
value = y.deviceNo,
label = y.deviceName
}).ToList()
}).ToList();