use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper 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;
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project jeecg-boot by jeecgboot.
the class SysBaseApiImpl method queryAllUser.
@Override
public JSONObject queryAllUser(String userIds, Integer pageNo, Integer pageSize) {
JSONObject json = new JSONObject();
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status", 1).eq("del_flag", 0);
List<ComboModel> list = new ArrayList<ComboModel>();
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
IPage<SysUser> pageList = userMapper.selectPage(page, queryWrapper);
for (SysUser user : pageList.getRecords()) {
ComboModel model = new ComboModel();
model.setUsername(user.getUsername());
model.setTitle(user.getRealname());
model.setId(user.getId());
model.setEmail(user.getEmail());
if (oConvertUtils.isNotEmpty(userIds)) {
String[] temp = userIds.split(",");
for (int i = 0; i < temp.length; i++) {
if (temp[i].equals(user.getId())) {
model.setChecked(true);
}
}
}
list.add(model);
}
json.put("list", list);
json.put("total", pageList.getTotal());
return json;
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project jeecg-boot by jeecgboot.
the class SysDepartPermissionServiceImpl method getPermRuleListByDeptIdAndPermId.
@Override
public List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId, String permissionId) {
SysDepartPermission departPermission = this.getOne(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
if (departPermission != null && oConvertUtils.isNotEmpty(departPermission.getDataRuleIds())) {
LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
query.in(SysPermissionDataRule::getId, Arrays.asList(departPermission.getDataRuleIds().split(",")));
query.orderByDesc(SysPermissionDataRule::getCreateTime);
List<SysPermissionDataRule> permRuleList = this.ruleMapper.selectList(query);
return permRuleList;
} else {
return null;
}
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project jeecg-boot by jeecgboot.
the class SysDepartPermissionServiceImpl method saveDepartPermission.
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDepartPermission(String departId, String permissionIds, String lastPermissionIds) {
List<String> add = getDiff(lastPermissionIds, permissionIds);
if (add != null && add.size() > 0) {
List<SysDepartPermission> list = new ArrayList<SysDepartPermission>();
for (String p : add) {
if (oConvertUtils.isNotEmpty(p)) {
SysDepartPermission rolepms = new SysDepartPermission(departId, p);
list.add(rolepms);
}
}
this.saveBatch(list);
}
List<String> delete = getDiff(permissionIds, lastPermissionIds);
if (delete != null && delete.size() > 0) {
for (String permissionId : delete) {
this.remove(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
// 删除部门权限时,删除部门角色中已授权的权限
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList(new LambdaQueryWrapper<SysDepartRole>().eq(SysDepartRole::getDepartId, departId));
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList());
if (roleIds != null && roleIds.size() > 0) {
departRolePermissionMapper.delete(new LambdaQueryWrapper<SysDepartRolePermission>().eq(SysDepartRolePermission::getPermissionId, permissionId));
}
}
}
}
use of com.baomidou.mybatisplus.core.conditions.query.QueryWrapper in project jeecg-boot by jeecgboot.
the class SysDepartRolePermissionServiceImpl method saveDeptRolePermission.
@Override
public void saveDeptRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
String ip = "";
try {
// 获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
// 获取IP地址
ip = IPUtils.getIpAddr(request);
} catch (Exception e) {
ip = "127.0.0.1";
}
List<String> add = getDiff(lastPermissionIds, permissionIds);
if (add != null && add.size() > 0) {
List<SysDepartRolePermission> list = new ArrayList<SysDepartRolePermission>();
for (String p : add) {
if (oConvertUtils.isNotEmpty(p)) {
SysDepartRolePermission rolepms = new SysDepartRolePermission(roleId, p);
rolepms.setOperateDate(new Date());
rolepms.setOperateIp(ip);
list.add(rolepms);
}
}
this.saveBatch(list);
}
List<String> delete = getDiff(permissionIds, lastPermissionIds);
if (delete != null && delete.size() > 0) {
for (String permissionId : delete) {
this.remove(new QueryWrapper<SysDepartRolePermission>().lambda().eq(SysDepartRolePermission::getRoleId, roleId).eq(SysDepartRolePermission::getPermissionId, permissionId));
}
}
}
Aggregations