Search in sources :

Example 1 with ServiceImpl

use of com.baomidou.mybatisplus.extension.service.impl.ServiceImpl in project jeecg-boot by jeecgboot.

the class FillRuleUtil method executeRule.

/**
 * @param ruleCode ruleCode
 * @return
 */
@SuppressWarnings("unchecked")
public static Object executeRule(String ruleCode, JSONObject formData) {
    if (!StringUtils.isEmpty(ruleCode)) {
        try {
            // 获取 Service
            ServiceImpl impl = (ServiceImpl) SpringContextUtils.getBean("sysFillRuleServiceImpl");
            // 根据 ruleCode 查询出实体
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("rule_code", ruleCode);
            JSONObject entity = JSON.parseObject(JSON.toJSONString(impl.getOne(queryWrapper)));
            if (entity == null) {
                log.warn("填值规则:" + ruleCode + " 不存在");
                return null;
            }
            // 获取必要的参数
            String ruleClass = entity.getString("ruleClass");
            JSONObject params = entity.getJSONObject("ruleParams");
            if (params == null) {
                params = new JSONObject();
            }
            if (formData == null) {
                formData = new JSONObject();
            }
            // 通过反射执行配置的类里的方法
            IFillRuleHandler ruleHandler = (IFillRuleHandler) Class.forName(ruleClass).newInstance();
            return ruleHandler.execute(params, formData);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;
}
Also used : IFillRuleHandler(org.jeecg.common.handler.IFillRuleHandler) JSONObject(com.alibaba.fastjson.JSONObject) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)

Example 2 with ServiceImpl

use of com.baomidou.mybatisplus.extension.service.impl.ServiceImpl in project kms by mahonelau.

the class FillRuleUtil method executeRule.

/**
 * @param ruleCode ruleCode
 * @return
 */
@SuppressWarnings("unchecked")
public static Object executeRule(String ruleCode, JSONObject formData) {
    if (!StringUtils.isEmpty(ruleCode)) {
        try {
            // 获取 Service
            ServiceImpl impl = (ServiceImpl) SpringContextUtils.getBean("sysFillRuleServiceImpl");
            // 根据 ruleCode 查询出实体
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("rule_code", ruleCode);
            JSONObject entity = JSON.parseObject(JSON.toJSONString(impl.getOne(queryWrapper)));
            if (entity == null) {
                log.warn("填值规则:" + ruleCode + " 不存在");
                return null;
            }
            // 获取必要的参数
            String ruleClass = entity.getString("ruleClass");
            JSONObject params = entity.getJSONObject("ruleParams");
            if (params == null) {
                params = new JSONObject();
            }
            if (formData == null) {
                formData = new JSONObject();
            }
            // 通过反射执行配置的类里的方法
            IFillRuleHandler ruleHandler = (IFillRuleHandler) Class.forName(ruleClass).newInstance();
            return ruleHandler.execute(params, formData);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;
}
Also used : IFillRuleHandler(org.jeecg.common.handler.IFillRuleHandler) JSONObject(com.alibaba.fastjson.JSONObject) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)

Example 3 with ServiceImpl

use of com.baomidou.mybatisplus.extension.service.impl.ServiceImpl in project kykms by mahonelau.

the class FillRuleUtil method executeRule.

/**
 * @param ruleCode ruleCode
 * @return
 */
@SuppressWarnings("unchecked")
public static Object executeRule(String ruleCode, JSONObject formData) {
    if (!StringUtils.isEmpty(ruleCode)) {
        try {
            // 获取 Service
            ServiceImpl impl = (ServiceImpl) SpringContextUtils.getBean("sysFillRuleServiceImpl");
            // 根据 ruleCode 查询出实体
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("rule_code", ruleCode);
            JSONObject entity = JSON.parseObject(JSON.toJSONString(impl.getOne(queryWrapper)));
            if (entity == null) {
                log.warn("填值规则:" + ruleCode + " 不存在");
                return null;
            }
            // 获取必要的参数
            String ruleClass = entity.getString("ruleClass");
            JSONObject params = entity.getJSONObject("ruleParams");
            if (params == null) {
                params = new JSONObject();
            }
            if (formData == null) {
                formData = new JSONObject();
            }
            // 通过反射执行配置的类里的方法
            IFillRuleHandler ruleHandler = (IFillRuleHandler) Class.forName(ruleClass).newInstance();
            return ruleHandler.execute(params, formData);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;
}
Also used : IFillRuleHandler(org.jeecg.common.handler.IFillRuleHandler) JSONObject(com.alibaba.fastjson.JSONObject) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)3 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)3 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)3 IFillRuleHandler (org.jeecg.common.handler.IFillRuleHandler)3