|
|
@ -1,16 +1,23 @@ |
|
|
|
package org.jeecg.modules.demo.rulex.service.impl; |
|
|
|
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.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.common.api.vo.Result; |
|
|
|
import org.jeecg.modules.demo.functionx.entity.Functionx; |
|
|
|
import org.jeecg.modules.demo.functionx.entity.Functionx; |
|
|
|
import org.jeecg.modules.demo.rulex.entity.Rulex; |
|
|
|
import org.jeecg.modules.demo.rulex.entity.Rulex; |
|
|
|
import org.jeecg.modules.demo.rulex.mapper.RulexMapper; |
|
|
|
import org.jeecg.modules.demo.rulex.mapper.RulexMapper; |
|
|
|
import org.jeecg.modules.demo.rulex.service.IRulexService; |
|
|
|
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.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
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; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -19,39 +26,86 @@ import java.util.List; |
|
|
|
* @Date: 2023-04-10 |
|
|
|
* @Date: 2023-04-10 |
|
|
|
* @Version: V1.0 |
|
|
|
* @Version: V1.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements IRulexService { |
|
|
|
public class RulexServiceImpl extends ServiceImpl<RulexMapper, Rulex> implements IRulexService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
RulexMapper rulexMapper; |
|
|
|
RulexMapper rulexMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Autowired |
|
|
|
public Result<?> sort(String id) { |
|
|
|
private ITablexService iTablexService; |
|
|
|
String sort = rulexMapper.sort(id); |
|
|
|
|
|
|
|
String functioncode = rulexMapper.find(id); |
|
|
|
@Autowired |
|
|
|
if (sort == null) { |
|
|
|
private IFieldxService iFieldxService; |
|
|
|
return Result.OK("001" + functioncode); |
|
|
|
|
|
|
|
} else { |
|
|
|
@Override |
|
|
|
int i = Integer.parseInt(sort); |
|
|
|
public Result<?> sort(String id) { |
|
|
|
i++; |
|
|
|
String sort = rulexMapper.sort(id); |
|
|
|
String s = Integer.toString(i); |
|
|
|
String functioncode = rulexMapper.find(id); |
|
|
|
while (s.length() < 3) { |
|
|
|
if (sort == null) { |
|
|
|
s = "0" + s; |
|
|
|
return Result.OK("001" + functioncode); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return Result.OK(s + functioncode); |
|
|
|
int i = Integer.parseInt(sort); |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
String s = Integer.toString(i); |
|
|
|
|
|
|
|
while (s.length() < 3) { |
|
|
|
|
|
|
|
s = "0" + s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Result.OK(s + functioncode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据功能id查询对应的规则 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param functionx functionx |
|
|
|
|
|
|
|
* @return {@link List}<{@link Rulex}> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<Rulex> queryRuleListByFunctionId(Functionx functionx) { |
|
|
|
|
|
|
|
LambdaQueryWrapper<Rulex> ruleWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据功能id查询对应的规则 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param functionx functionx |
|
|
|
|
|
|
|
* @return {@link List}<{@link Rulex}> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<Rulex> queryRuleListByFunctionId(Functionx functionx) { |
|
|
|
|
|
|
|
LambdaQueryWrapper<Rulex> ruleWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
ruleWrapper.eq(Rulex::getFunctionId, functionx.getId()); |
|
|
|
|
|
|
|
return this.list(ruleWrapper); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|