|
|
|
@ -1,16 +1,23 @@ |
|
|
|
|
package org.jeecg.modules.demo.rulex.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.modules.demo.functionx.entity.Functionx; |
|
|
|
|
import org.jeecg.modules.demo.rulex.entity.Rulex; |
|
|
|
|
import org.jeecg.modules.demo.rulex.mapper.RulexMapper; |
|
|
|
|
import org.jeecg.modules.demo.rulex.service.IRulexService; |
|
|
|
|
import org.jeecg.modules.fieldx.entity.Fieldx; |
|
|
|
|
import org.jeecg.modules.fieldx.service.IFieldxService; |
|
|
|
|
import org.jeecg.modules.tablex.entity.Tablex; |
|
|
|
|
import org.jeecg.modules.tablex.service.ITablexService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -19,12 +26,20 @@ import java.util.List; |
|
|
|
|
* @Date: 2023-04-10 |
|
|
|
|
* @Version: V1.0 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
|
@Service |
|
|
|
|
public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements IRulexService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
RulexMapper rulexMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ITablexService iTablexService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IFieldxService iFieldxService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Result<?> sort(String id) { |
|
|
|
|
String sort = rulexMapper.sort(id); |
|
|
|
@ -54,4 +69,43 @@ public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements |
|
|
|
|
ruleWrapper.eq(Rulex::getFunctionId, functionx.getId()); |
|
|
|
|
return this.list(ruleWrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 功能管理新增规则操作时,如果功能类型是‘新增’和‘修改’,自动根据实体对应的字段,自动生成若干条记录(根据实体的字段生成多条规则) |
|
|
|
|
* |
|
|
|
|
* @param functionx |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void saveRulex(Functionx functionx) { |
|
|
|
|
int functionType = functionx.getFunctionType().intValue(); |
|
|
|
|
if (1 == functionType || 3 == functionType) { |
|
|
|
|
String moduleId = functionx.getModuleId(); |
|
|
|
|
Tablex tablex = iTablexService.getOne(new LambdaQueryWrapper<Tablex>().eq(Tablex::getModuleId, moduleId)); |
|
|
|
|
if (!ObjectUtils.isEmpty(tablex)) { |
|
|
|
|
List<Fieldx> fieldxList = iFieldxService.list(new LambdaQueryWrapper<Fieldx>().eq(Fieldx::getTableId, tablex.getId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(fieldxList)) { |
|
|
|
|
fieldxList.stream().forEach(o -> { |
|
|
|
|
//主键字段不创建规则
|
|
|
|
|
if (0 == o.getIsPk()) { |
|
|
|
|
Rulex rulex = new Rulex(); |
|
|
|
|
rulex.setModuleId(moduleId); |
|
|
|
|
rulex.setTableId(tablex.getId()); |
|
|
|
|
rulex.setFunctionId(functionx.getId()); |
|
|
|
|
rulex.setFieldId(o.getId()); |
|
|
|
|
rulex.setCreateTime(new Date()); |
|
|
|
|
Result<?> result = this.sort(functionx.getId()); |
|
|
|
|
String roleCodeStr = result.getResult().toString(); |
|
|
|
|
log.info("-----------------the roleCodeStr:{}", roleCodeStr); |
|
|
|
|
String ruleNo = roleCodeStr.substring(0, 3); |
|
|
|
|
String ruleCode = roleCodeStr.substring(3) + ruleNo; |
|
|
|
|
rulex.setRuleNo(ruleNo); |
|
|
|
|
rulex.setRuleCode(ruleCode); |
|
|
|
|
rulex.setPmDescribe(JSON.toJSONString(o)); |
|
|
|
|
this.save(rulex); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|