105 Star 811 Fork 273

GVPcanonical-entropy/nop-entropy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
DemoBizModel.java 2.61 KB
一键复制 编辑 原始数据 按行查看 历史
canonical-entropy 提交于 2024-06-08 23:23 . 增加aop的示例
/**
* Copyright (c) 2017-2024 Nop Platform. All rights reserved.
* Author: canonical_entropy@163.com
* Blog: https://www.zhihu.com/people/canonical-entropy
* Gitee: https://gitee.com/canonical-entropy/nop-entropy
* Github: https://github.com/entropy-cloud/nop-entropy
*/
package io.nop.demo.biz;
import io.nop.api.core.annotations.biz.BizModel;
import io.nop.api.core.annotations.biz.BizQuery;
import io.nop.api.core.annotations.biz.RequestBean;
import io.nop.api.core.annotations.core.Name;
import io.nop.api.core.util.LogLevel;
import io.nop.core.context.IServiceContext;
import io.nop.demo.annotations.SendEmail;
import io.nop.demo.domain.Material;
import io.nop.demo.domain.ProcessCard;
import io.nop.demo.domain.ProductionOrder;
import io.nop.log.core.LoggerConfigurator;
import io.nop.xlang.filter.BizValidatorHelper;
import jakarta.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
@BizModel("Demo")
public class DemoBizModel {
// @Inject
// RedisDataSource redisDataSource;
@PostConstruct
public void init() {
// Guard.notNull(redisDataSource, "redisDataSource");
}
@BizQuery
public void changeLogLevel(@Name("logLevel") LogLevel logLevel, @Name("loggerName") String loggerName) {
LoggerConfigurator.instance().changeLogLevel(loggerName, logLevel);
}
@BizQuery
public String testValidate(@Name("orderId") String orderId,
@Name("materialId") String materialId,
IServiceContext context) {
ProcessCard entity = loadProcessCard(orderId, materialId);
Map<String, Object> vars = prepareVars(entity);
BizValidatorHelper.runValidator("/nop/demo/validator/process-card.validator.xml",
vars, context);
return "Valid";
}
public ProcessCard loadProcessCard(String orderId, String materialId) {
ProcessCard entity = new ProcessCard();
ProductionOrder order = new ProductionOrder();
order.setOrderId(orderId);
entity.setProductionOrder(order);
entity.setMaterialId(materialId);
return entity;
}
private Map<String, Object> prepareVars(ProcessCard card) {
Map<String, Object> vars = new HashMap<>();
vars.put("entity", card);
vars.put("firstProductionOrder", card.getProductionOrder());
Material material = new Material();
material.setMaterialId("2");
vars.put("firstMaterial", material);
return vars;
}
@BizQuery
@SendEmail
public void testMethod1(@RequestBean MyRequest request) {
System.out.println("doSomething");
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/canonical-entropy/nop-entropy.git
git@gitee.com:canonical-entropy/nop-entropy.git
canonical-entropy
nop-entropy
nop-entropy
master

搜索帮助