文档库--分页(未完成)
This commit is contained in:
+2
-2
@@ -5,7 +5,7 @@ package com.jero.common.constant.enums;
|
||||
* @date 2022/1/21 15:22
|
||||
* @auth zhn
|
||||
*/
|
||||
public enum YesOrNo {
|
||||
public enum YesOrNoEnum {
|
||||
NO("否","0"),
|
||||
YES("是","1");
|
||||
|
||||
@@ -13,7 +13,7 @@ public enum YesOrNo {
|
||||
String name;
|
||||
String value;
|
||||
|
||||
private YesOrNo(String name,String value) {
|
||||
private YesOrNoEnum(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
+40
-46
@@ -1,26 +1,32 @@
|
||||
package com.jero.modules.document.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,6 +65,19 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @param parameter
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "分页查询")
|
||||
@ApiOperation(value="分页查询", notes="分页查询")
|
||||
@GetMapping(value = "/queryPageInfo")
|
||||
public Result<?> queryPageInfo(@RequestParam(name="parameter",required=false) Map<String,Object> parameter) {
|
||||
bussDocumentLibraryEOService.getInfoPage(parameter);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
@@ -72,33 +91,6 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param bussDocumentLibraryEO
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档库信息表-添加")
|
||||
@ApiOperation(value="文档库信息表-添加", notes="文档库信息表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@Validated @RequestBody BussDocumentLibraryEO bussDocumentLibraryEO) {
|
||||
bussDocumentLibraryEOService.add(bussDocumentLibraryEO);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param bussDocumentLibraryEO
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档库信息表-编辑")
|
||||
@ApiOperation(value="文档库信息表-编辑", notes="文档库信息表-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@Validated @RequestBody BussDocumentLibraryEO bussDocumentLibraryEO) {
|
||||
bussDocumentLibraryEOService.editById(bussDocumentLibraryEO);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
@@ -170,8 +162,8 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
||||
|
||||
|
||||
/**
|
||||
* 列表查询条件
|
||||
*
|
||||
* 列表查询条件 标识传 1-->用于查询文档库字段属性
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档库信息表-查询条件")
|
||||
@@ -181,9 +173,10 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
||||
List<Map<String,Object>> list = bussDocumentLibraryEOService.queryCondition(flag);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表表头
|
||||
*
|
||||
* @param flag 标识传 1-->用于查询文档库字段属性
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档库信息表-列表表头")
|
||||
@@ -193,9 +186,10 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
||||
List<Map<String,Object>> list = bussDocumentLibraryEOService.getHeader(flag);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增表单
|
||||
*
|
||||
* @param flag 标识传 1-->用于查询文档库字段属性
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档库信息表-新增表单")
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.jero.modules.document.enums;
|
||||
|
||||
/**
|
||||
* @description
|
||||
* @date 2022/1/21 15:22
|
||||
* @auth zhn
|
||||
*/
|
||||
public enum FieldTypeEnum {
|
||||
TEXT("输入框","text"),
|
||||
LIST("下拉单选","list"),
|
||||
LIST_MULTI("下拉多选","list_multi"),
|
||||
DATE("日期","date");
|
||||
|
||||
|
||||
String name;
|
||||
String value;
|
||||
|
||||
private FieldTypeEnum(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -1,10 +1,10 @@
|
||||
package com.jero.modules.document.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Description: 文档库信息表
|
||||
@@ -17,5 +17,8 @@ public interface BussDocumentLibraryEOMapper extends BaseMapper<BussDocumentLibr
|
||||
int insertInfo(@Param("insertField") String insertField,
|
||||
@Param("insertValue") String insertValue);
|
||||
|
||||
IPage getInfoPage(@Param("page") Page page,
|
||||
@Param("condition") String condition);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -40,4 +40,9 @@
|
||||
values (${insertValue})
|
||||
</insert>
|
||||
|
||||
<select id="getInfoPage" resultType="com.baomidou.mybatisplus.core.metadata.IPage">
|
||||
select * from buss_document_library
|
||||
${condition}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
+5
-16
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.document.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
@@ -13,22 +14,6 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibraryEO> {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param bussDocumentLibraryEO
|
||||
* @return
|
||||
*/
|
||||
void add(BussDocumentLibraryEO bussDocumentLibraryEO);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param bussDocumentLibraryEO
|
||||
* @return
|
||||
*/
|
||||
void editById(BussDocumentLibraryEO bussDocumentLibraryEO);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
@@ -99,4 +84,8 @@ public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibr
|
||||
* @param map
|
||||
*/
|
||||
void updateInfo(Map<String,Object> map);
|
||||
|
||||
void getInfoPage(Map<String,Object> parameter);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+142
-31
@@ -1,18 +1,22 @@
|
||||
package com.jero.modules.document.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.constant.enums.ModuleEnum;
|
||||
import com.jero.common.constant.enums.YesOrNo;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
|
||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
import com.jero.modules.document.mapper.BussDocumentLibraryEOMapper;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.jero.modules.tag.entity.OnlCgformArea;
|
||||
import com.jero.modules.tag.service.impl.OnlCgformAreaServiceImpl;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -43,33 +47,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
private BussDocumentLibraryEOMapper bussDocumentLibraryEOMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param bussDocumentLibraryEO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void add(BussDocumentLibraryEO bussDocumentLibraryEO) {
|
||||
Date now = new Date();
|
||||
bussDocumentLibraryEO.setCreateTime(now);
|
||||
bussDocumentLibraryEO.setUpdateTime(now);
|
||||
save(bussDocumentLibraryEO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param bussDocumentLibraryEO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void editById(BussDocumentLibraryEO bussDocumentLibraryEO) {
|
||||
Date now = new Date();
|
||||
bussDocumentLibraryEO.setUpdateTime(now);
|
||||
saveOrUpdate(bussDocumentLibraryEO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
@@ -122,7 +99,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(flag);
|
||||
if(fieldList.size() != 0){
|
||||
//过滤出搜索条件()
|
||||
fieldList = fieldList.stream().filter(e-> YesOrNo.YES.getValue().equals(String.valueOf(e.getIsQuery()))).collect(Collectors.toList());
|
||||
fieldList = fieldList.stream().filter(e-> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsQuery()))).collect(Collectors.toList());
|
||||
}
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
for (OnlCgformField onlCgformField : fieldList) {
|
||||
@@ -146,7 +123,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(flag);
|
||||
if(fieldList.size() != 0){
|
||||
//过滤列表字段(is_show_list-->列表是否显示0否 1是)
|
||||
fieldList = fieldList.stream().filter(e-> YesOrNo.YES.getValue().equals(String.valueOf(e.getIsShowList()))).collect(Collectors.toList());
|
||||
fieldList = fieldList.stream().filter(e-> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowList()))).collect(Collectors.toList());
|
||||
}
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
for (OnlCgformField onlCgformField : fieldList) {
|
||||
@@ -174,7 +151,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|
||||
if(fieldList.size() != 0){
|
||||
//过滤出表单字段(is_show_form-->表单是否显示0否 1是)
|
||||
fieldList = fieldList.stream().filter(e-> YesOrNo.YES.getValue().equals(String.valueOf(e.getIsShowForm()))).collect(Collectors.toList());
|
||||
fieldList = fieldList.stream().filter(e-> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowForm()))).collect(Collectors.toList());
|
||||
}
|
||||
List<Map<String,Object>> result = new ArrayList<>();
|
||||
for (OnlCgformArea onlCgformAreaTemp : areaList) {
|
||||
@@ -372,4 +349,138 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
+"str_to_date('" + sdf.format(new Date()) + "','%Y-%m-%d %H:%i:%s')"+ ",'"+sysUser.getOrgCode()+ "'";
|
||||
return mustValue;
|
||||
}
|
||||
|
||||
public void getInfoPage(Map<String,Object> parameter){
|
||||
//过滤查询条件字段类型使用
|
||||
List<Map<String, Object>> mapList = queryCondition("1");
|
||||
|
||||
//测试数据(查询条件, 暂时使用mapTemp, 提交代码的时候使用parameter)
|
||||
Map<String,Object> mapTemp = new HashMap<>();
|
||||
// mapTemp.put("orderByField","issue_time");//测试数据
|
||||
// mapTemp.put("orderBy","1");//测试数据
|
||||
|
||||
for (Map<String, Object> map : mapList) {
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
int a= 0;
|
||||
if("db_field_name".equals(key)){
|
||||
mapTemp.put(value,"aaa");//测试数据
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//查询条件
|
||||
StringBuilder conditionSb = new StringBuilder("where 1 = 1");
|
||||
|
||||
for (Map.Entry<String, Object> entry : mapTemp.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = (String) entry.getValue();
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
for (Map<String, Object> map : mapList) {
|
||||
String fieldName = (String)map.get("db_field_name");//字段
|
||||
if(key.equals(fieldName)){
|
||||
//字段类型(判断是输入框还是下拉,等等)
|
||||
String fieldType = (String) map.get("field_show_type");//字段类型
|
||||
|
||||
if(FieldTypeEnum.TEXT.getValue().equals(fieldType)){
|
||||
//输入框
|
||||
conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%')");
|
||||
|
||||
}else if(FieldTypeEnum.LIST.getValue().equals(fieldType)
|
||||
|| FieldTypeEnum.LIST_MULTI.getValue().equals(fieldType)){
|
||||
StringBuilder valueSb = new StringBuilder();
|
||||
for (String valueTemp : value.split(",")) {
|
||||
valueSb.append("'" + valueTemp + "',");
|
||||
}
|
||||
String substring = valueSb.substring(0, valueSb.length() - 1);
|
||||
//下拉单选或下拉多选
|
||||
conditionSb.append(" and " + key + " in("+substring+")");
|
||||
|
||||
}else if(FieldTypeEnum.DATE.getValue().equals(fieldType)){
|
||||
value = "2022-01-24";
|
||||
//日期(区分单日期还时间范围)
|
||||
if(value.contains(",")){
|
||||
conditionSb.append(" and " +"date_format("+ key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
|
||||
+ " and " +"date_format("+ key + ",'%Y-%m-%d') <= '" + value.split(",")[1] + "'");
|
||||
}else{
|
||||
conditionSb.append(" and " +"date_format("+ key + ",'%Y-%m-%d') = '" + value + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//处理列表表头排序
|
||||
if(StringUtils.isNotBlank((String) mapTemp.get("orderByField"))){
|
||||
conditionSb.append(" order by " + (String) mapTemp.get("orderByField"));
|
||||
if("1".equals((String) mapTemp.get("orderBy"))){
|
||||
conditionSb.append(" asc");//正序
|
||||
}else if("2".equals((String) mapTemp.get("orderBy"))){
|
||||
conditionSb.append(" desc");//倒序
|
||||
}
|
||||
}else{
|
||||
conditionSb.append(" order by create_time desc");
|
||||
}
|
||||
int pageNo = 1;
|
||||
int pageSize = 10;
|
||||
// int pageNo = Integer.parseInt(mapTemp.get("pageNo").toString());
|
||||
// int pageSize = Integer.parseInt(mapTemp.get("pageSize").toString());
|
||||
Page page = new Page(pageNo, pageSize);
|
||||
|
||||
IPage infoPage = bussDocumentLibraryEOMapper.getInfoPage(page, conditionSb.toString());
|
||||
int a = 0;
|
||||
|
||||
// for (Map<String, Object> map : mapList) {
|
||||
//
|
||||
//
|
||||
// String key = (String) map.get("db_field_name");//字段名
|
||||
//// String value = (String) map.get("value");//字段值
|
||||
// String value = "qqqqqq,wwww";//字段值
|
||||
// String fieldType = (String) map.get("field_show_type");//字段类型
|
||||
//
|
||||
// if(StringUtils.isNotBlank(value)){
|
||||
// if(FieldTypeEnum.TEXT.getValue().equals(fieldType)){
|
||||
// //输入框
|
||||
// conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%')");
|
||||
//// conditionSb.append(" and " + key +"='"+value+"' ");
|
||||
//
|
||||
//
|
||||
// }else if(FieldTypeEnum.LIST.getValue().equals(fieldType)
|
||||
// || FieldTypeEnum.LIST_MULTI.getValue().equals(fieldType)){
|
||||
// StringBuilder valueSb = new StringBuilder();
|
||||
// for (String valueTemp : value.split(",")) {
|
||||
// valueSb.append("'" + valueTemp + "',");
|
||||
// }
|
||||
// String substring = valueSb.substring(0, valueSb.length() - 1);
|
||||
// //下拉单选或下拉多选
|
||||
// conditionSb.append(" and " + key + " in("+substring+")");
|
||||
//
|
||||
//
|
||||
// }else if(FieldTypeEnum.DATE.getValue().equals(fieldType)){
|
||||
// value = "2022-01-24,2022-01-24";
|
||||
// //日期
|
||||
// if(value.contains(",")){
|
||||
// conditionSb.append(" and " +"date_format("+ key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
|
||||
// + " and " +"date_format("+ key + ",'%Y-%m-%d') >= '" + value.split(",")[1] + "'");
|
||||
// }else{
|
||||
// conditionSb.append(" and " +"date_format("+ key + ",'%Y-%m-%d') >= '" + value + "'");
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// bussDocumentLibraryEOMapper.getInfoPage();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user