需求:根据模板列表勾选的字段查询列表数据
FreeMarker代码:
java">/*** 分页列表查询** @param ${entityName?uncap_first}* @param pageNo* @param pageSize* @param req* @return*///@AutoLog(value = "${tableVo.ftlDescription}-分页列表查询")@ApiOperation(value="${tableVo.ftlDescription}-分页列表查询", notes="${tableVo.ftlDescription}-分页列表查询")@GetMapping(value = "/list")public Result<IPage<${entityName}>> queryPageList(${entityName} ${entityName?uncap_first},@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());queryWrapper.select(<#list columns as po><#if po?is_last>"${po.fieldName}"<#else>"${po.fieldName}",</#if></#list>);Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);return Result.OK(pageList);}
生成效果:
java"> /*** 分页列表查询** @param crmCcRedlist* @param pageNo* @param pageSize* @param req* @return*///@AutoLog(value = "crm_cc_redlist-分页列表查询")@ApiOperation(value="crm_cc_redlist-分页列表查询", notes="crm_cc_redlist-分页列表查询")@GetMapping(value = "/list")public Result<IPage<CrmCcRedlist>> queryPageList(CrmCcRedlist crmCcRedlist,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {QueryWrapper<CrmCcRedlist> queryWrapper = QueryGenerator.initQueryWrapper(crmCcRedlist, req.getParameterMap());queryWrapper.select("name","number","priority","remarks","lastDate","isAlways","createBy","createTime","updateBy","updateTime");Page<CrmCcRedlist> page = new Page<CrmCcRedlist>(pageNo, pageSize);IPage<CrmCcRedlist> pageList = crmCcRedlistService.page(page, queryWrapper);return Result.OK(pageList);}