提交 79d5f090 编写于 作者: sq3536's avatar sq3536

代码表支持参数

上级 c6fa8e3e
...@@ -7,11 +7,23 @@ import cn.ibizlab.core.ou.extensions.domain.*; ...@@ -7,11 +7,23 @@ import cn.ibizlab.core.ou.extensions.domain.*;
import cn.ibizlab.core.ou.extensions.mapping.SysDept2NodeMapping; import cn.ibizlab.core.ou.extensions.mapping.SysDept2NodeMapping;
import cn.ibizlab.core.ou.extensions.mapping.SysEmp2NodeMapping; import cn.ibizlab.core.ou.extensions.mapping.SysEmp2NodeMapping;
import cn.ibizlab.core.ou.extensions.mapping.SysOrg2NodeMapping; import cn.ibizlab.core.ou.extensions.mapping.SysOrg2NodeMapping;
import cn.ibizlab.core.ou.filter.SysDepartmentSearchContext;
import cn.ibizlab.core.ou.filter.SysEmployeeSearchContext;
import cn.ibizlab.core.ou.filter.SysOrganizationSearchContext;
import cn.ibizlab.core.ou.service.ISysDepartmentService;
import cn.ibizlab.core.ou.service.ISysEmployeeService; import cn.ibizlab.core.ou.service.ISysEmployeeService;
import cn.ibizlab.core.ou.service.ISysOrganizationService;
import cn.ibizlab.util.filter.QueryWrapperContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
...@@ -333,4 +345,70 @@ public class OUCoreService ...@@ -333,4 +345,70 @@ public class OUCoreService
} }
} }
@Autowired
private ISysOrganizationService iibzOrganizationService;
@Autowired
private ISysDepartmentService iibzDepartmentService;
@Cacheable( value="ibzou-model",key = "'catalog:'+#p0")
public JSONObject getItems(String catalog) {
return getItems(catalog,null);
}
public JSONObject getItems(String catalog, QueryWrapperContext context) {
JSONObject jo=new JSONObject();
jo.put("srfkey",catalog);
jo.put("emptytext","");
List<JSONObject> list=new ArrayList<>();
if("IbzouOrg".equalsIgnoreCase(catalog))
{
QueryWrapper<SysOrganization> queryWrapper = context==null? Wrappers.query():context.getSelectCond();
queryWrapper.orderByAsc("showorder");
iibzOrganizationService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getOrgid());
option.put("value",item.getOrgid());
option.put("label",item.getOrgname());
option.put("text",item.getOrgname());
list.add(option);
});
}
else if("IbzouDept".equalsIgnoreCase(catalog)||"IbzouOrgSector".equalsIgnoreCase(catalog))
{
QueryWrapper<SysDepartment> queryWrapper = context==null? Wrappers.query():context.getSelectCond();
queryWrapper.orderByAsc("showorder");
iibzDepartmentService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getDeptid());
option.put("value",item.getDeptid());
option.put("label",item.getDeptname());
option.put("text",item.getDeptname());
option.put("filter",item.getOrgid());
list.add(option);
});
}
else if("IbzouUser".equalsIgnoreCase(catalog)||"IbzouOperator".equalsIgnoreCase(catalog)||"IbzouEmp".equalsIgnoreCase(catalog)||"IbzouPerson".equalsIgnoreCase(catalog))
{
QueryWrapper<SysEmployee> queryWrapper = context==null? Wrappers.query():context.getSelectCond();
queryWrapper.orderByAsc("showorder");
iibzEmployeeService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getUserid());
option.put("value",item.getUserid());
option.put("label",item.getPersonname());
option.put("text",item.getPersonname());
option.put("code", item.getUsercode());
option.put("name", item.getUsername());
option.put("filter",item.getOrgid());
list.add(option);
});
}
jo.put("items",list);
return jo;
}
} }
...@@ -5,11 +5,22 @@ import cn.ibizlab.core.ou.domain.SysEmployee; ...@@ -5,11 +5,22 @@ import cn.ibizlab.core.ou.domain.SysEmployee;
import cn.ibizlab.core.ou.domain.SysOrganization; import cn.ibizlab.core.ou.domain.SysOrganization;
import cn.ibizlab.core.ou.extensions.domain.*; import cn.ibizlab.core.ou.extensions.domain.*;
import cn.ibizlab.core.ou.extensions.service.OUCoreService; import cn.ibizlab.core.ou.extensions.service.OUCoreService;
import cn.ibizlab.core.ou.filter.SysDepartmentSearchContext;
import cn.ibizlab.core.ou.filter.SysEmployeeSearchContext;
import cn.ibizlab.core.ou.filter.SysOrganizationSearchContext;
import cn.ibizlab.core.ou.service.ISysDepartmentService; import cn.ibizlab.core.ou.service.ISysDepartmentService;
import cn.ibizlab.core.ou.service.ISysEmployeeService; import cn.ibizlab.core.ou.service.ISysEmployeeService;
import cn.ibizlab.core.ou.service.ISysOrganizationService; import cn.ibizlab.core.ou.service.ISysOrganizationService;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.filter.QueryWrapperContext;
import cn.ibizlab.util.filter.SearchContextBase;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
...@@ -187,99 +198,57 @@ public class OUCoreResource ...@@ -187,99 +198,57 @@ public class OUCoreResource
@Cacheable( value="ibzou-model",key = "'catalog:'+#p0") @RequestMapping(method = {RequestMethod.GET}, value = {"/dictionarys/catalogs/Ibzou{catalog}","/dictionarys/codelist/Ibzou{catalog}"})
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/catalogs/Ibzou{catalog}") public ResponseEntity<JSONObject> getCodeList(@PathVariable("catalog") String catalog, SearchContextBase context) {
public ResponseEntity<JSONObject> getCatalog(@PathVariable("catalog") String catalog) { return ResponseEntity.status(HttpStatus.OK).body(getItems("Ibzou"+catalog,context));
return ResponseEntity.status(HttpStatus.OK).body(getItems("Ibzou"+catalog));
} }
@Cacheable( value="ibzou-model",key = "'codelist:'+#p0")
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/codelist/Ibzou{catalog}")
public ResponseEntity<JSONObject> getCodeList(@PathVariable("catalog") String catalog) {
return ResponseEntity.status(HttpStatus.OK).body(getItems("Ibzou"+catalog));
}
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/catalogs/Ibzou{code}/options") @RequestMapping(method = {RequestMethod.GET}, value = {"/dictionarys/catalogs/Ibzou{code}/options","/dictionarys/codelist/Ibzou{code}/items"})
public ResponseEntity<List> getOptions(@PathVariable("code") String code) { public ResponseEntity<List> getCodeItems(@PathVariable("code") String code, SearchContextBase context) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code).get("items")); return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code,context).get("items"));
} }
@RequestMapping(method = RequestMethod.GET, value = "/dictionarys/codelist/Ibzou{code}/items")
public ResponseEntity<List> getCodeItems(@PathVariable("code") String code) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code).get("items"));
}
@RequestMapping(method = RequestMethod.POST, value = "/dictionarys/catalogs/Ibzou{code}/options") @RequestMapping(method = {RequestMethod.POST}, value = {"/dictionarys/catalogs/Ibzou{catalog}","/dictionarys/codelist/Ibzou{catalog}"})
public ResponseEntity<List> getOptions(@PathVariable("code") String code,@RequestBody List<String> values) { public ResponseEntity<JSONObject> codeList(@PathVariable("catalog") String catalog,@RequestBody(required = false) SearchContextBase context) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code,values).get("items")); return ResponseEntity.status(HttpStatus.OK).body(getItems("Ibzou"+catalog,context));
} }
@RequestMapping(method = RequestMethod.POST, value = "/dictionarys/codelist/Ibzou{code}/items")
public ResponseEntity<List> getCodeItems(@PathVariable("code") String code, @RequestBody List<String> values) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code,values).get("items"));
}
public JSONObject getItems(String catalog) { @RequestMapping(method = {RequestMethod.POST}, value = {"/dictionarys/catalogs/Ibzou{code}/options","/dictionarys/codelist/Ibzou{code}/items"})
return getItems(catalog,null); public ResponseEntity<List> codeItems(@PathVariable("code") String code,@RequestBody(required = false) SearchContextBase context) {
return ResponseEntity.status(HttpStatus.OK).body((List) getItems("Ibzou"+code,context).get("items"));
} }
public JSONObject getItems(String catalog,List<String> values) {
JSONObject jo=new JSONObject();
jo.put("srfkey",catalog);
jo.put("emptytext","");
List<JSONObject> list=new ArrayList<>();
public JSONObject getItems(String catalog, SearchContextBase context) {
QueryWrapperContext searchContext=null;
if("IbzouOrg".equalsIgnoreCase(catalog)) if("IbzouOrg".equalsIgnoreCase(catalog))
{ {
LambdaQueryWrapper<SysOrganization> queryWrapper = Wrappers.<SysOrganization>lambdaQuery(); if(context!=null)
if(!ObjectUtils.isEmpty(values)) searchContext=JSON.toJavaObject((JSONObject)JSON.toJSON(context.getParams()),SysOrganizationSearchContext.class);
queryWrapper.in(SysOrganization::getOrgid,values);
queryWrapper.orderByAsc(SysOrganization::getShoworder);
iibzOrganizationService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getOrgid());
option.put("value",item.getOrgid());
option.put("label",item.getOrgname());
option.put("text",item.getOrgname());
list.add(option);
});
} }
else if("IbzouDept".equalsIgnoreCase(catalog)||"IbzouOrgSector".equalsIgnoreCase(catalog)) else if("IbzouDept".equalsIgnoreCase(catalog)||"IbzouOrgSector".equalsIgnoreCase(catalog))
{ {
LambdaQueryWrapper<SysDepartment> queryWrapper = Wrappers.<SysDepartment>lambdaQuery(); if(context!=null)
if(!ObjectUtils.isEmpty(values)) searchContext=JSON.toJavaObject((JSONObject)JSON.toJSON(context),SysDepartmentSearchContext.class);
queryWrapper.in(SysDepartment::getDeptid,values);
queryWrapper.orderByAsc(SysDepartment::getShoworder);
iibzDepartmentService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getDeptid());
option.put("value",item.getDeptid());
option.put("label",item.getDeptname());
option.put("text",item.getDeptname());
list.add(option);
});
} }
else if("IbzouUser".equalsIgnoreCase(catalog)||"IbzouOperator".equalsIgnoreCase(catalog)||"IbzouEmp".equalsIgnoreCase(catalog)||"IbzouPerson".equalsIgnoreCase(catalog)) else if("IbzouUser".equalsIgnoreCase(catalog)||"IbzouOperator".equalsIgnoreCase(catalog)||"IbzouEmp".equalsIgnoreCase(catalog)||"IbzouPerson".equalsIgnoreCase(catalog))
{ {
LambdaQueryWrapper<SysEmployee> queryWrapper = Wrappers.<SysEmployee>lambdaQuery(); if(context!=null)
if(!ObjectUtils.isEmpty(values)) searchContext=JSON.toJavaObject((JSONObject)JSON.toJSON(context),SysEmployeeSearchContext.class);
queryWrapper.in(SysEmployee::getUserid,values);
queryWrapper.orderByAsc(SysEmployee::getShoworder);
iibzEmployeeService.list(queryWrapper).forEach(item -> {
JSONObject option=new JSONObject();
option.put("id",item.getUserid());
option.put("value",item.getUserid());
option.put("label",item.getPersonname());
option.put("text",item.getPersonname());
list.add(option);
});
} }
if(searchContext==null||StringUtils.isEmpty(searchContext.getSelectCond().getSqlSegment()))
return ouCoreService.getItems(catalog);
else
return ouCoreService.getItems(catalog,searchContext);
jo.put("items",list);
return jo;
} }
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册