jeecg-boot 2.0 模块开发版本发布

This commit is contained in:
zhangdaihao
2019-05-19 18:54:09 +08:00
parent 383c521c6d
commit 405ee3f226
770 changed files with 85014 additions and 19508 deletions

View File

@ -1,15 +1,15 @@
Jeecg-Boot 快速开发平台
===============
当前最新版本: 1.1发布日期20190415
当前最新版本: 2.0.0发布日期20190518
## 后端技术架构
- 基础框架Spring Boot 2.0.3.RELEASE
- 基础框架Spring Boot 2.1.3.RELEASE
- 持久层框架Mybatis-plus_3.0.6
- 安全框架Apache Shiro 1.4.0-RC2Jwt_3.4.1
- 安全框架Apache Shiro 1.4.0Jwt_3.7.0
- 数据库连接池阿里巴巴Druid 1.1.10
@ -34,24 +34,7 @@ Jeecg-Boot 快速开发平台
- 缓存Redis
#### 技术文档
- 官方文档 [http://jeecg-boot.mydoc.io](http://jeecg-boot.mydoc.io)
- 零基础入门 [http://jeecg-boot.mydoc.io/?t=344845](http://jeecg-boot.mydoc.io/?t=344845)
- 在线演示 [http://boot.jeecg.org](http://boot.jeecg.org)
- QQ交流群 284271917
- 视频教程 https://pan.baidu.com/s/1Il0TS50I70vH1AG1y40wtw 提取码hok5
- 常见问题 [新手入门必看,汇总了常见各种问题](http://www.jeecg.org/forum.php?mod=viewthread&tid=7816&page=1&extra=#pid21237)
## 专项文档区
## 开发文档
- 查询过滤器用法
@ -98,5 +81,177 @@ QueryWrapper<?> queryWrapper = QueryGenerator.initQueryWrapper(?, req.getParamet
[在线文档](https://github.com/zhangdaiscott/autopoi)
- **代码生成器**
** 功能说明** 一键生成的代码包括controller、service、dao、mapper、entity、vue
**模板位置** src/main/resources/jeecg/code-template
**使用方法**
【**一对一模板**】
**1.**先找到**jeecg-boot/src/resources/jeecg**下的
**jeecg_config.properties**和**jeecg_database.properties**两个文件。
**jeecg_config.properties:** 用来配置文件生成的路径,
**jeecg_database.properties:** 用来配置数据库相关配置.
**2.**配置好这些配置之后,我们需要找到**jeecg-boot/src/main/java/org/jeecg/JeecgOneGUI.java**类,也就是启动一对一代码生成器的入口;
**3.**右键运行该类,紧接着会弹出一个窗口,如下图:
![](https://static.oschina.net/uploads/img/201904/14222638_Svth.png)
**4.**然后根据窗口左侧的提示,在右侧填写对应的信息即可.
【**一对多模板**】
**1.**先找到**jeecg-boot/src/resources/jeecg**下的
**jeecg_config.properties**和**jeecg_database.properties**两个文件。
**jeecg_config.properties:** 是配置文件生成路径的,
**jeecg_database.properties:** 是配置数据库相关配置的文件。
**2.**接着我们需要找到**jeecg-boot/src/main/java/org/jeecg/JeecgOneToMainUtil.java**这个类。
该类是生成一对多模板的启动入口。
**3.**该类中需要三个步骤来配置一对多表的信息。
(1) 第一步: 配置主表信息,代码如下:
```
//第一步:设置主表配置
MainTableVo mainTable = new MainTableVo();
mainTable.setTableName("jeecg_order_main");//表名
mainTable.setEntityName("TestOrderMain"); //实体名
mainTable.setEntityPackage("test2"); //包名
mainTable.setFtlDescription("订单"); //描述
```
(2) 第二步: 配置子表信息,**有多个则配置多个**, 代码如下:
①比如: 配置子表 1:
```
//第二步:设置子表集合配置
List<SubTableVo> subTables = new ArrayList<SubTableVo>();
//[1].子表一
SubTableVo po = new SubTableVo();
po.setTableName("jeecg_order_customer");//表名
po.setEntityName("TestOrderCustom"); //实体名
po.setEntityPackage("test2"); //包名
po.setFtlDescription("客户明细"); //描述
//子表外键参数配置
/*说明:
* a) 子表引用主表主键ID作为外键外键字段必须以_ID结尾;
* b) 主表和子表的外键字段名字必须相同除主键ID外;
* c) 多个外键字段,采用逗号分隔;
*/
po.setForeignKeys(new String[]{"order_id"});
subTables.add(po);
```
②比如: 配置子表 2:
```
//[2].子表二
SubTableVo po2 = new SubTableVo();
po2.setTableName("jeecg_order_ticket"); //表名
po2.setEntityName("TestOrderTicket"); //实体名
po2.setEntityPackage("test2"); //包名
po2.setFtlDescription("产品明细"); //描述
//子表外键参数配置
/*说明:
* a) 子表引用主表主键ID作为外键外键字段必须以_ID结尾;
* b) 主表和子表的外键字段名字必须相同除主键ID外;
* c) 多个外键字段,采用逗号分隔;
*/
po2.setForeignKeys(new String[]{"order_id"});
subTables.add(po2);
```
③将整合了子表VO的subTables添加到主表对象当中去:
```
mainTable.setSubTables(subTables);
```
④需要注意如下代码,该代码的作用是,为子表设置主外键关联,当添加数据时,
主表的主键将会添加到子表的"order_id"中:
```
po2.setForeignKeys(new String[]{"order_id"});
```
(3) 第三步: 启动(run)程序,生成代码, 代码如下:
```
//第三步:一对多(父子表)数据模型,代码生成
new CodeGenerateOneToMany(mainTable,subTables).generateCodeFile();
```
[在线文档](https://github.com/zhangdaiscott/autopoi)
- **编码排重使用示例**
重复校验效果:
![输入图片说明](https://static.oschina.net/uploads/img/201904/19191836_eGkQ.png "在这里输入图片标题")
1.引入排重接口,代码如下:
```
import { duplicateCheck } from '@/api/api'
```
2.找到编码必填校验规则的前端代码,代码如下:
```
<a-input placeholder="请输入编码" v-decorator="['code', validatorRules.code ]"/>
code: {
rules: [
{ required: true, message: '请输入编码!' },
{validator: this.validateCode}
]
},
```
3.找到rules里validator对应的方法在哪里,然后使用第一步中引入的排重校验接口.
以用户online表单编码为示例,其中四个必传的参数有:
```
{tableName:表名,fieldName:字段名,fieldVal:字段值,dataId:表的主键},
```
具体使用代码如下:
```
validateCode(rule, value, callback){
let pattern = /^[a-z|A-Z][a-z|A-Z|\d|_|-]{0,}$/;
if(!pattern.test(value)){
callback('编码必须以字母开头,可包含数字、下划线、横杠');
} else {
var params = {
tableName: "onl_cgreport_head",
fieldName: "code",
fieldVal: value,
dataId: this.model.id
};
duplicateCheck(params).then((res)=>{
if(res.success){
callback();
}else{
callback(res.message);
}
})
}
},
```

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +0,0 @@
一、技术文档
http://jeecg-boot.mydoc.io
二、 零基础学习看这个
http://jeecg-boot.mydoc.io/?t=344845
三、线上部署文档
1. 修改redis、
2. 数据库配置文件
3. 修改上传文件目录
4. 修改前端API的图片访问域名
详细看这个链接http://jeecg-boot.mydoc.io/?t=344852
四、默认账号密码(需手工初始化数据库脚步)
默认账号密码: admin/123456

View File

@ -0,0 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jeecg-boot-base-common</artifactId>
<version>2.0.0</version>
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>2.0.0</version>
</parent>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun Repository</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jeecg</id>
<name>jeecg Repository</name>
<url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@ -2,6 +2,8 @@ package org.jeecg.common.api.vo;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.jeecg.common.constant.CommonConstant;
import lombok.Data;
@ -13,6 +15,7 @@ import lombok.Data;
* @date 2019年1月19日
*/
@Data
@ApiModel(value="接口返回对象", description="接口返回对象")
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L;
@ -20,21 +23,25 @@ public class Result<T> implements Serializable {
/**
* 成功标志
*/
@ApiModelProperty(value = "成功标志")
private boolean success = true;
/**
* 返回处理消息
*/
@ApiModelProperty(value = "返回处理消息")
private String message = "操作成功!";
/**
* 返回代码
*/
@ApiModelProperty(value = "返回代码")
private Integer code = 0;
/**
* 返回数据对象 data
*/
@ApiModelProperty(value = "返回数据对象")
private T result;
public Result() {
@ -44,6 +51,7 @@ public class Result<T> implements Serializable {
/**
* 时间戳
*/
@ApiModelProperty(value = "时间戳")
private long timestamp = System.currentTimeMillis();
public void error500(String message) {
@ -70,6 +78,14 @@ public class Result<T> implements Serializable {
return r;
}
public static Result<Object> ok() {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage("成功");
return r;
}
public static Result<Object> ok(String msg) {
Result<Object> r = new Result<Object>();
r.setSuccess(true);
@ -85,4 +101,4 @@ public class Result<T> implements Serializable {
r.setResult(data);
return r;
}
}
}

View File

@ -11,9 +11,9 @@ import org.jeecg.common.constant.CommonConstant;
/**
* 系统日志注解
*
* @author scott
* @Author scott
* @email jeecgos@163.com
* @date 2019年1月14日
* @Date 2019年1月14日
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)

View File

@ -8,13 +8,17 @@ import java.lang.annotation.Target;
/**
* 数据权限注解
* @author taoyan
* @date 2019年4月11日
* @Author taoyan
* @Date 2019年4月11日
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD})
@Documented
public @interface PermissionData {
/**
* 暂时没用
* @return
*/
String value() default "";

View File

@ -38,12 +38,14 @@ public interface CommonConstant {
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
public static final Integer SC_OK_200 = 200;
public static String PREFIX_USER_ROLE = "PREFIX_USER_ROLE";
public static String PREFIX_USER_PERMISSION = "PREFIX_USER_PERMISSION ";
/** 登录用户拥有角色缓存KEY前缀 */
public static String LOGIN_USER_CACHERULES_ROLE = "loginUser_cacheRules::Roles_";
/** 登录用户拥有权限缓存KEY前缀 */
public static String LOGIN_USER_CACHERULES_PERMISSION = "loginUser_cacheRules::Permissions_";
/** 登录用户令牌缓存KEY前缀 */
public static int TOKEN_EXPIRE_TIME = 3600; //3600秒即是一小时
public static String PREFIX_USER_TOKEN = "PREFIX_USER_TOKEN ";
public static String PREFIX_USER_TOKEN = "PREFIX_USER_TOKEN_";
/**
* 0一级菜单
@ -57,4 +59,22 @@ public interface CommonConstant {
* 2按钮权限
*/
public static Integer MENU_TYPE_2 = 2;
/**通告对象类型USER:指定用户ALL:全体用户)*/
public static String MSG_TYPE_UESR = "USER";
public static String MSG_TYPE_ALL = "ALL";
/**发布状态0未发布1已发布2已撤销*/
public static String NO_SEND = "0";
public static String HAS_SEND = "1";
public static String HAS_CANCLE = "2";
/**阅读状态0未读1已读*/
public static String HAS_READ_FLAG = "1";
public static String NO_READ_FLAG = "0";
/**优先级L低M中H高*/
public static String PRIORITY_L = "L";
public static String PRIORITY_M = "M ";
public static String PRIORITY_H = "H";
}

View File

@ -2,7 +2,7 @@ package org.jeecg.common.constant;
/**
* 系统通告 - 发布状态
* @author LeeShaoQing
* @Author LeeShaoQing
*
*/
public interface CommonSendStatus {

View File

@ -5,18 +5,15 @@ package org.jeecg.common.constant;
public interface DataBaseConstant {
//*********系统上下文变量****************************************
/**
* 数据-所属公司编码
*/
public static final String SYS_COMPANY_CODE = "sysCompanyCode";
/**
* 数据-所属公司编码
*/
public static final String SYS_COMPANY_CODE_TABLE = "sys_company_code";
/**
* 数据-所属机构编码
*/
public static final String SYS_ORG_CODE = "sysOrgCode";
/**
* 数据-所属机构编码
*/
public static final String SYS_MULTI_ORG_CODE = "sysMultiOrgCode";
/**
* 数据-所属机构编码
*/

View File

@ -1,8 +1,10 @@
package org.jeecg.common.exception;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.jeecg.common.api.vo.Result;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;
@ -12,8 +14,8 @@ import lombok.extern.slf4j.Slf4j;
/**
* 异常处理器
*
* @author scott
* @date 2019
* @Author scott
* @Date 2019
*/
@RestControllerAdvice
@Slf4j
@ -40,7 +42,7 @@ public class JeecgBootExceptionHandler {
return Result.error("数据库中已存在该记录");
}
@ExceptionHandler(AuthorizationException.class)
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
public Result<?> handleAuthorizationException(AuthorizationException e){
log.error(e.getMessage(), e);
return Result.error("没有权限,请联系管理员授权");
@ -51,4 +53,16 @@ public class JeecgBootExceptionHandler {
log.error(e.getMessage(), e);
return Result.error(e.getMessage());
}
/**
* @Author 政辉
* @param e
* @return
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result<?> HttpRequestMethodNotSupportedException(Exception e){
log.error(e.getMessage(), e);
return Result.error("没有权限,请联系管理员授权");
}
}

View File

@ -0,0 +1,75 @@
package org.jeecg.common.system.api;
import java.sql.SQLException;
import java.util.List;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
/**
* @Description: 底层共通业务API提供其他独立模块调用
* @Author: scott
* @Date:2019-4-20
* @Version:V1.0
*/
public interface ISysBaseAPI {
/**
* 日志添加
* @param LogContent 内容
* @param logType 日志类型(0:操作日志;1:登录日志;2:定时任务)
* @param operatetype 操作类型(1:添加;2:修改;3:删除;)
*/
void addLog(String LogContent, Integer logType, Integer operatetype);
/**
* 根据用户账号查询登录用户信息
* @param username
* @return
*/
public LoginUser getUserByName(String username);
/**
* 通过用户账号查询角色集合
* @param username
* @return
*/
public List<String> getRolesByUsername(String username);
/**
* 获取当前数据库类型
* @return
* @throws Exception
*/
public String getDatabaseType() throws SQLException;
/**
* 获取数据字典
* @param code
* @return
*/
public List<DictModel> queryDictItemsByCode(String code);
/**
* 获取表数据字典
* @param table
* @param text
* @param code
* @return
*/
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
/**
* 查询所有部门 作为字典信息 id -->value,departName -->text
* @return
*/
public List<DictModel> queryAllDepartBackDictModel();
/**
* 发送系统消息
* @param fromUser 发送人(用户登录账户)
* @param toUser 发送给(用户登录账户)
* @param title 消息主题
* @param msgContent 消息内容
*/
public void sendSysAnnouncement(String fromUser,String toUser,String title, String msgContent);
}

View File

@ -0,0 +1,101 @@
package org.jeecg.common.system.base.controller;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecg.common.system.base.service.JeecgService;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
/**
* @Description: Controller基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-21 8:13
* @Version: 1.0
*/
@Slf4j
public class JeecgController<T extends JeecgEntity, S extends JeecgService<T>> {
@Autowired
S service;
/**
* 导出excel
*
* @param request
* @param response
*/
protected ModelAndView exportXls(HttpServletRequest request,T object,Class<T> clazz,String title) {
//--------------------------------------------------------------------------------
//获取当前用户
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
//--------------------------------------------------------------------------------
// Step.1 组装查询条件
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
// Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<T> pageList = service.list(queryWrapper);
// 导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.CLASS, clazz);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(title + "报表", "导出人:"+sysUser.getRealname(), title + ""));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
protected Result<?> importExcel(HttpServletRequest request, HttpServletResponse response, Class<T> clazz) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
for (T t : list) {
service.save(t);
}
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.error("文件导入失败!");
}
}

View File

@ -0,0 +1,50 @@
package org.jeecg.common.system.base.entity;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: Entity基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-28
* @Version: 1.1
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class JeecgEntity {
/** ID */
@TableId(type = IdType.UUID)
@ApiModelProperty(value = "ID")
private java.lang.String id;
/** 创建人 */
@ApiModelProperty(value = "创建人")
@Excel(name = "创建人", width = 15)
private java.lang.String createBy;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date createTime;
/** 更新人 */
@ApiModelProperty(value = "更新人")
@Excel(name = "更新人", width = 15)
private java.lang.String updateBy;
/** 更新时间 */
@ApiModelProperty(value = "更新时间")
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date updateTime;
}

View File

@ -0,0 +1,12 @@
package org.jeecg.common.system.base.service;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: Service基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-21 8:13
* @Version: 1.0
*/
public interface JeecgService<T> extends IService<T> {
}

View File

@ -0,0 +1,19 @@
package org.jeecg.common.system.base.service.impl;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecg.common.system.base.service.JeecgService;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
/**
* @Description: ServiceImpl基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-21 8:13
* @Version: 1.0
*/
@Slf4j
public class JeecgServiceImpl<M extends BaseMapper<T>, T extends JeecgEntity> extends ServiceImpl<M, T> implements JeecgService<T> {
}

View File

@ -13,7 +13,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.FileCopyUtils;
@ -24,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ModelAndView;
import lombok.extern.slf4j.Slf4j;
@ -32,7 +32,7 @@ import lombok.extern.slf4j.Slf4j;
* 用户表 前端控制器
* </p>
*
* @author scott
* @Author scott
* @since 2018-12-20
*/
@Slf4j
@ -43,13 +43,22 @@ public class CommonController {
@Value(value = "${jeecg.path.upload}")
private String uploadpath;
/**
* @Author 政辉
* @return
*/
@GetMapping("/403")
public Result<?> noauth() {
return Result.error("没有权限,请联系管理员授权");
}
@PostMapping(value = "/upload")
public Result<SysUser> upload(HttpServletRequest request, HttpServletResponse response) {
Result<SysUser> result = new Result<>();
public Result<?> upload(HttpServletRequest request, HttpServletResponse response) {
Result<?> result = new Result<>();
try {
String ctxPath = uploadpath;
String fileName = null;
String bizPath = "user";
String bizPath = "files";
String nowday = new SimpleDateFormat("yyyyMMdd").format(new Date());
File file = new File(ctxPath + File.separator + bizPath + File.separator + nowday);
if (!file.exists()) {
@ -71,7 +80,7 @@ public class CommonController {
} catch (IOException e) {
result.setSuccess(false);
result.setMessage(e.getMessage());
e.printStackTrace();
log.error(e.getMessage(), e);
}
return result;
}
@ -107,7 +116,65 @@ public class CommonController {
}
response.flushBuffer();
} catch (IOException e) {
log.info("预览图片失败" + e.getMessage());
log.error("预览图片失败" + e.getMessage());
// e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
}
/**
* 下载文件
* 请求地址http://localhost:8080/common/download/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
*
* @param request
* @param response
* @throws Exception
*/
@GetMapping(value = "/download/**")
public void download(HttpServletRequest request, HttpServletResponse response) throws Exception {
// ISO-8859-1 ==> UTF-8 进行编码转换
String filePath = extractPathFromPattern(request);
// 其余处理略
InputStream inputStream = null;
OutputStream outputStream = null;
try {
filePath = filePath.replace("..", "");
if (filePath.endsWith(",")) {
filePath = filePath.substring(0, filePath.length() - 1);
}
String localPath = uploadpath;
String downloadFilePath = localPath + File.separator + filePath;
File file = new File(downloadFilePath);
if (file.exists()) {
response.setContentType("application/force-download");// 设置强制下载不打开            
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
inputStream = new BufferedInputStream(new FileInputStream(file));
outputStream = response.getOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
outputStream.write(buf, 0, len);
}
response.flushBuffer();
}
} catch (Exception e) {
log.info("文件下载失败" + e.getMessage());
// e.printStackTrace();
} finally {
if (inputStream != null) {
@ -127,6 +194,16 @@ public class CommonController {
}
}
/**
* @功能pdf预览Iframe
* @param modelAndView
* @return
*/
@RequestMapping("/pdf/pdfPreviewIframe")
public ModelAndView pdfPreviewIframe(ModelAndView modelAndView) {
modelAndView.setViewName("pdfPreviewIframe");
return modelAndView;
}
/**
* 把指定URL后的字符串全部截断当成参数
@ -139,5 +216,5 @@ public class CommonController {
String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
}
}

View File

@ -16,10 +16,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.beanutils.PropertyUtils;
import org.jeecg.common.system.util.JeecgDataAutorUtils;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.shiro.authc.util.JwtUtil;
import org.jeecg.modules.system.entity.SysPermissionDataRule;
import org.jeecg.modules.system.util.JeecgDataAutorUtils;
import org.springframework.util.NumberUtils;
import com.alibaba.fastjson.JSON;
@ -67,7 +67,7 @@ public class QueryGenerator {
long start = System.currentTimeMillis();
QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
installMplus(queryWrapper, searchObj, parameterMap);
log.info("---查询条件构造器初始化完成,耗时:"+(System.currentTimeMillis()-start)+"毫秒----");
log.debug("---查询条件构造器初始化完成,耗时:"+(System.currentTimeMillis()-start)+"毫秒----");
return queryWrapper;
}
@ -109,7 +109,7 @@ public class QueryGenerator {
continue;
}
//权限查询
//数据权限查询
if(ruleMap.containsKey(name)) {
addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper);
}
@ -152,7 +152,7 @@ public class QueryGenerator {
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
// 排序逻辑 处理
@ -172,7 +172,7 @@ public class QueryGenerator {
if(parameterMap!=null&& parameterMap.containsKey(ORDER_TYPE)) {
order = parameterMap.get(ORDER_TYPE)[0];
}
log.info("排序规则>>列:"+column+",排序方式:"+order);
log.debug("排序规则>>列:"+column+",排序方式:"+order);
if (oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) {
if (order.toUpperCase().indexOf(ORDER_TYPE_ASC)>=0) {
queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column));
@ -194,8 +194,7 @@ public class QueryGenerator {
try {
superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error("--高级查询参数转码失败!");
e.printStackTrace();
log.error("--高级查询参数转码失败!", e);
}
List<QueryCondition> conditions = JSON.parseArray(superQueryParams, QueryCondition.class);
log.info("---高级查询参数-->"+conditions.toString());
@ -213,7 +212,7 @@ public class QueryGenerator {
* @param value
* @return
*/
private static QueryRuleEnum convert2Rule(Object value) {
public static QueryRuleEnum convert2Rule(Object value) {
// 避免空数据
if (value == null) {
return null;
@ -222,12 +221,16 @@ public class QueryGenerator {
if (val.length() == 0) {
return null;
}
// step 1 .> <
QueryRuleEnum rule = QueryRuleEnum.getByValue(val.substring(0, 1));
QueryRuleEnum rule =null;
// step 2 .>= =<
if (rule == null && val.length() >= 2) {
rule = QueryRuleEnum.getByValue(val.substring(0, 2));
}
// step 1 .> <
if (rule == null && val.length() >= 1) {
rule = QueryRuleEnum.getByValue(val.substring(0, 1));
}
// step 3 like
if (rule == null && val.contains(STAR)) {
if (val.startsWith(STAR) && val.endsWith(STAR)) {
@ -257,7 +260,7 @@ public class QueryGenerator {
* @param value
* @return
*/
private static Object replaceValue(QueryRuleEnum rule, Object value) {
public static Object replaceValue(QueryRuleEnum rule, Object value) {
if (rule == null) {
return null;
}
@ -461,12 +464,15 @@ public class QueryGenerator {
sqlRule = sqlRule.replace("#{"+var+"}",tempValue);
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return sqlRule;
}
private static Set<String> getSqlRuleParams(String sql) {
/**
* 获取sql中的#{key} 这个key组成的set
*/
public static Set<String> getSqlRuleParams(String sql) {
if(oConvertUtils.isEmpty(sql)){
return null;
}
@ -481,4 +487,104 @@ public class QueryGenerator {
}
return varParams;
}
/**
* 获取查询条件
* @param field
* @param alias
* @param value
* @param isString
* @return
*/
public static String getSingleQueryConditionSql(String field,String alias,Object value,boolean isString) {
if (value == null) {
return "";
}
field = alias+oConvertUtils.camelToUnderline(field);
QueryRuleEnum rule = QueryGenerator.convert2Rule(value);
String res = "";
switch (rule) {
case GT:
res =field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case GE:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case LT:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case LE:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case EQ:
res = field+rule.getValue()+getFieldConditionValue(value, isString);
break;
case NE:
res = field+" <> "+getFieldConditionValue(value, isString);
break;
case IN:
res = field + " in "+getInConditionValue(value, isString);
break;
case LIKE:
res = field + " like "+getLikeConditionValue(value);
break;
case LEFT_LIKE:
res = field + " like "+getLikeConditionValue(value);
break;
case RIGHT_LIKE:
res = field + " like "+getLikeConditionValue(value);
break;
default:
res = field+" = "+getFieldConditionValue(value, isString);
break;
}
return res;
}
private static String getFieldConditionValue(Object value,boolean isString) {
String str = value.toString().trim();
if(str.startsWith("!")) {
str = str.substring(1);
}else if(str.startsWith(">=")) {
str = str.substring(2);
}else if(str.startsWith("<=")) {
str = str.substring(2);
}else if(str.startsWith(">")) {
str = str.substring(1);
}else if(str.startsWith("<")) {
str = str.substring(1);
}
if(isString) {
return " '"+str+"' ";
}else {
return value.toString();
}
}
private static String getInConditionValue(Object value,boolean isString) {
if(isString) {
String temp[] = value.toString().split(",");
String res="";
for (String string : temp) {
res+=",'"+string+"'";
}
return "("+res.substring(1)+")";
}else {
return "("+value.toString()+")";
}
}
private static String getLikeConditionValue(Object value) {
String str = value.toString().trim();
if(str.startsWith("*") && str.endsWith("*")) {
return "'%"+str.substring(1,str.length()-1)+"%'";
}else if(str.startsWith("*")) {
return "'%"+str.substring(1)+"'";
}else if(str.endsWith("*")) {
return "'"+str.substring(0,str.length()-1)+"%'";
}else {
return str;
}
}
}

View File

@ -4,8 +4,8 @@ import org.jeecg.common.util.oConvertUtils;
/**
* Query 规则 常量
* @author Scott
* @date 2019年02月14日
* @Author Scott
* @Date 2019年02月14日
*/
public enum QueryRuleEnum {

View File

@ -1,20 +1,20 @@
package org.jeecg.modules.system.util;
package org.jeecg.common.system.util;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.system.entity.SysPermissionDataRule;
import org.jeecg.modules.system.model.SysUserCacheInfo;
import org.springframework.util.StringUtils;
/**
* @ClassName: JeecgDataAutorUtils
* @Description: 数据权限查询规则容器工具类
* @author 张代浩
* @date 2012-12-15 下午11:27:39
* @Author: 张代浩
* @Date: 2012-12-15 下午11:27:39
*
*/
public class JeecgDataAutorUtils {

View File

@ -1,4 +1,4 @@
package org.jeecg.modules.shiro.authc.util;
package org.jeecg.common.system.util;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
@ -13,15 +13,14 @@ import javax.servlet.http.HttpSession;
import org.jeecg.common.constant.DataBaseConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.model.SysUserCacheInfo;
import org.jeecg.modules.system.util.JeecgDataAutorUtils;
/**
* @author Scott
* @create 2018-07-12 14:23
* @desc JWT工具类
* @Author Scott
* @Date 2018-07-12 14:23
* @Desc JWT工具类
**/
public class JwtUtil {
@ -149,16 +148,16 @@ public class JwtUtil {
returnValue = user.getSysUserName();
}
//替换为系统登录用户的公司编码
if (key.equals(DataBaseConstant.SYS_COMPANY_CODE)|| key.equals(DataBaseConstant.SYS_COMPANY_CODE_TABLE)) {
returnValue = user.getCompanyCode();
}
//替换为系统用户登录所使用的机构编码
if (key.equals(DataBaseConstant.SYS_ORG_CODE)|| key.equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
returnValue = user.getSysOrgCode();
}
//替换为系统用户所拥有的所有机构编码
if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)|| key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)) {
if(user.isOneDepart()) {
returnValue = user.getSysOrgCode().get(0);
returnValue = user.getSysMultiOrgCode().get(0);
}else {
returnValue = Joiner.on(",").join(user.getSysOrgCode());
returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
}
}
//替换为当前系统时间(年月日)

View File

@ -0,0 +1,31 @@
package org.jeecg.common.system.vo;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class DictModel implements Serializable{
private static final long serialVersionUID = 1L;
/**
* 字典value
*/
private String value;
/**
* 字典文本
*/
private String text;
/**
* 特殊用途: JgEditableTable
* @return
*/
public String getTitle() {
return this.text;
}
}

View File

@ -0,0 +1,83 @@
package org.jeecg.common.system.vo;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 在线用户信息
* </p>
*
* @Author scott
* @since 2018-12-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class LoginUser {
/**
* 登录人id
*/
private String id;
/**
* 登录人账号
*/
private String username;
/**
* 登录人名字
*/
private String realname;
/**
* 当前登录部门code
*/
private String orgCode;
/**
* 头像
*/
private String avatar;
/**
* 生日
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birthday;
/**
* 性别1男 2
*/
private Integer sex;
/**
* 电子邮件
*/
private String email;
/**
* 电话
*/
private String phone;
/**
* 状态(1正常 2冻结
*/
private Integer status;
private String delFlag;
/**
* 同步工作流引擎1同步0不同步
*/
private String activitiSync;
}

View File

@ -1,4 +1,4 @@
package org.jeecg.modules.system.model;
package org.jeecg.common.system.vo;
import java.util.List;
@ -10,13 +10,9 @@ public class SysUserCacheInfo {
private String sysUserName;
/*private String sysDate;
private String sysOrgCode;
private String sysTime;*/
private String companyCode;
private List<String> sysOrgCode;
private List<String> sysMultiOrgCode;
private boolean oneDepart;
@ -52,22 +48,20 @@ public class SysUserCacheInfo {
this.sysUserName = sysUserName;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public List<String> getSysOrgCode() {
public String getSysOrgCode() {
return sysOrgCode;
}
public void setSysOrgCode(List<String> sysOrgCode) {
public void setSysOrgCode(String sysOrgCode) {
this.sysOrgCode = sysOrgCode;
}
public List<String> getSysMultiOrgCode() {
return sysMultiOrgCode;
}
public void setSysMultiOrgCode(List<String> sysMultiOrgCode) {
this.sysMultiOrgCode = sysMultiOrgCode;
}
}

View File

@ -1,8 +1,8 @@
package org.jeecg.modules.online.cgreport.util;
package org.jeecg.common.util;
/**
*
* @author 张代浩
* @Author 张代浩
*
*/
public enum BrowserType {

View File

@ -1,4 +1,4 @@
package org.jeecg.modules.online.cgreport.util;
package org.jeecg.common.util;
import java.util.HashMap;
import java.util.Map;
@ -9,7 +9,7 @@ import javax.servlet.http.HttpServletRequest;
/**
*
* @author 张代浩
* @Author 张代浩
*
*/
public class BrowserUtils {

View File

@ -15,8 +15,9 @@ import org.springframework.util.StringUtils;
*
* 类描述时间操作定义类
*
* @author: 张代浩 @date 日期2012-12-8 时间下午12:15:03
* @version 1.0
* @Author: 张代浩
* @Date:2012-12-8 12:15:03
* @Version 1.0
*/
public class DateUtils extends PropertyEditorSupport {
// 各种时间格式

View File

@ -9,9 +9,9 @@ import javax.servlet.http.HttpServletRequest;
/**
* IP地址
*
* @author scott
* @Author scott
* @email jeecgos@163.com
* @date 2019年01月14日
* @Date 2019年01月14日
*/
public class IPUtils {
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);

View File

@ -1,7 +1,7 @@
package org.jeecg.common.util;
/**
* @author 张代浩
* @Author 张代浩
*/
public class MyClassLoader extends ClassLoader {
public static Class getClassByScn(String className) {

View File

@ -13,7 +13,7 @@ import org.springframework.util.CollectionUtils;
/**
* redis 工具类
* @author Scott
* @Author Scott
*
*/
@Component

View File

@ -5,7 +5,7 @@ import java.net.InetAddress;
/**
*
* @author 张代浩
* @Author 张代浩
*
*/
public class UUIDGenerator {

View File

@ -6,7 +6,7 @@ import io.netty.util.internal.StringUtil;
* 流水号生成规则(按默认规则递增数字从1-99开始递增数字到99递增字母;位数不够增加位数)
* A001
* A001A002
* @author zhangdaihao
* @Author zhangdaihao
*
*/
public class YouBianCodeUtil {

View File

@ -1,9 +1,11 @@
package org.jeecg.common.jsonschema;
package org.jeecg.common.util.jsonschema;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.jeecg.common.system.vo.DictModel;
import com.alibaba.fastjson.JSONObject;
/**
@ -35,7 +37,7 @@ public abstract class CommonProperty implements Serializable{
* "enum": ["1", "2", "3"] 需要的话可以通过这个include转一下
* }
*/
protected List<Map<String,Object>> include;
protected List<DictModel> include;
/**
* 对应JsonSchema的const
@ -49,6 +51,16 @@ public abstract class CommonProperty implements Serializable{
protected String title;//数据库字段备注
protected Integer order;//字段显示排序
protected boolean disabled;//是否禁用
public boolean isDisabled() {
return disabled;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
public String getView() {
return view;
}
@ -73,11 +85,11 @@ public abstract class CommonProperty implements Serializable{
this.type = type;
}
public List<Map<String, Object>> getInclude() {
public List<DictModel> getInclude() {
return include;
}
public void setInclude(List<Map<String, Object>> include) {
public void setInclude(List<DictModel> include) {
this.include = include;
}
@ -133,6 +145,11 @@ public abstract class CommonProperty implements Serializable{
}else {
json.put("view", view);
}
if(disabled) {
String str = "{\"widgetattrs\":{\"disabled\":true}}";
JSONObject ui = JSONObject.parseObject(str);
json.put("ui", ui);
}
return json;
}

View File

@ -1,4 +1,4 @@
package org.jeecg.common.jsonschema;
package org.jeecg.common.util.jsonschema;
import java.io.Serializable;
import java.util.List;

View File

@ -1,4 +1,4 @@
package org.jeecg.common.jsonschema;
package org.jeecg.common.util.jsonschema;
import java.util.ArrayList;
import java.util.List;
@ -34,7 +34,8 @@ public class JsonschemaUtil {
properties.put(map.get("key").toString(), map.get("prop"));
}
obj.put("properties", properties);
log.info("---JSONSchema--->"+obj.toString());
//鬼知道这里为什么报错 org.jeecg.modules.system.model.DictModel cannot be cast to org.jeecg.modules.system.model.DictModel
//log.info("---JSONSchema--->"+obj.toJSONString());
return obj;
}

View File

@ -1,10 +1,11 @@
package org.jeecg.common.jsonschema.validate;
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jeecg.common.jsonschema.CommonProperty;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
@ -105,7 +106,7 @@ public class NumberProperty extends CommonProperty {
* @param view list-checkbox-radio
* @param include
*/
public NumberProperty(String key,String title,String view,List<Map<String,Object>> include) {
public NumberProperty(String key,String title,String view,List<DictModel> include) {
this.type = "integer";
this.key = key;
this.view = view;

View File

@ -0,0 +1,76 @@
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
public class PopupProperty extends CommonProperty {
private static final long serialVersionUID = -3200493311633999539L;
private String code;
private String destFields;
private String orgFields;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDestFields() {
return destFields;
}
public void setDestFields(String destFields) {
this.destFields = destFields;
}
public String getOrgFields() {
return orgFields;
}
public void setOrgFields(String orgFields) {
this.orgFields = orgFields;
}
public PopupProperty() {}
public PopupProperty(String key,String title,String code,String destFields,String orgFields) {
this.view = "popup";
this.type = "string";
this.key = key;
this.title = title;
this.code = code;
this.destFields=destFields;
this.orgFields=orgFields;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
if(code!=null) {
prop.put("code",code);
}
if(destFields!=null) {
prop.put("destFields",destFields);
}
if(orgFields!=null) {
prop.put("orgFields",orgFields);
}
map.put("prop",prop);
return map;
}
}

View File

@ -1,10 +1,11 @@
package org.jeecg.common.jsonschema.validate;
package org.jeecg.common.util.jsonschema.validate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jeecg.common.jsonschema.CommonProperty;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.jsonschema.CommonProperty;
import com.alibaba.fastjson.JSONObject;
@ -71,7 +72,7 @@ public class StringProperty extends CommonProperty {
* @param maxLength 数据库字段最大长度
* @param include 数据字典
*/
public StringProperty(String key,String title,String view,Integer maxLength,List<Map<String,Object>> include) {
public StringProperty(String key,String title,String view,Integer maxLength,List<DictModel> include) {
this.maxLength = maxLength;
this.key = key;
this.view = view;

View File

@ -1,6 +1,7 @@
package org.jeecg.common.util;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
@ -8,9 +9,12 @@ import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@ -21,7 +25,7 @@ import javax.servlet.http.HttpServletRequest;
/**
*
* @author 张代浩
* @Author 张代浩
*
*/
public class oConvertUtils {
@ -519,9 +523,13 @@ public class oConvertUtils {
* @return
*/
public static String camelToUnderline(String para){
if(para.length()<3){
return para.toLowerCase();
}
StringBuilder sb=new StringBuilder(para);
int temp=0;//定位
for(int i=0;i<para.length();i++){
//从第三个字符开始 避免命名不规范
for(int i=2;i<para.length();i++){
if(Character.isUpperCase(para.charAt(i))){
sb.insert(i+temp, "_");
temp+=1;
@ -544,4 +552,21 @@ public class oConvertUtils {
return sb.toString();
}
/**
* 获取类的所有属性包括父类
*
* @param object
* @return
*/
public static Field[] getAllFields(Object object) {
Class<?> clazz = object.getClass();
List<Field> fieldList = new ArrayList<>();
while (clazz != null) {
fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields())));
clazz = clazz.getSuperclass();
}
Field[] fields = new Field[fieldList.size()];
fieldList.toArray(fields);
return fields;
}
}

View File

@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
/**
* 判断类型追加查询规则
*
* @author Scott
* @date 2019年02月14日
* @Author Scott
* @Date 2019年02月14日
*/
public class ObjectParseUtil {

View File

@ -4,8 +4,8 @@ import org.jeecg.common.util.oConvertUtils;
/**
* Query 规则 常量
* @author Scott
* @date 2019年02月14日
* @Author Scott
* @Date 2019年02月14日
*/
public enum QueryRuleEnum {

View File

@ -15,7 +15,7 @@ import lombok.experimental.Accessors;
* 菜单权限规则表
* </p>
*
* @author huangzhilin
* @Author huangzhilin
* @since 2019-03-29
*/
@Data

View File

@ -0,0 +1,39 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jeecg-boot-module-system</artifactId>
<version>2.0.0</version>
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>2.0.0</version>
</parent>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun Repository</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jeecg</id>
<name>jeecg Repository</name>
<url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-base-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,37 @@
package org.jeecg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Slf4j
@EnableSwagger2
@SpringBootApplication
@EnableAutoConfiguration
public class JeecgApplication {
public static void main(String[] args) throws UnknownHostException {
//System.setProperty("spring.devtools.restart.enabled", "true");
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
log.info("\n----------------------------------------------------------\n\t" +
"Application Jeecg-Boot is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
}

View File

@ -4,9 +4,9 @@ import org.jeecgframework.codegenerate.window.CodeWindow;
/**
* @Title: 单表代码生成器入口
* @author 张代浩
* @Author 张代浩
* @site www.jeecg.org
* @versionV1.0.1
* @Version:V1.0.1
*/
public class JeecgOneGUI {

View File

@ -9,7 +9,7 @@ import org.jeecgframework.codegenerate.generate.pojo.onetomany.SubTableVo;
/**
* 代码生成器入口一对多
* @author 张代浩
* @Author 张代浩
* @site www.jeecg.org
*
*/

View File

@ -5,8 +5,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author: Scott
* @date: 2018/2/7
* @Author: Scott
* @Date: 2018/2/7
* @description: autopoi 配置类
*/

View File

@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
/**
* 单数据源配置jeecg.datasource.open = false时生效
* @author zhoujf
* @Author zhoujf
*
*/
@Configuration

View File

@ -1,13 +1,19 @@
package org.jeecg.config;
import java.lang.reflect.Method;
import java.time.Duration;
import javax.annotation.Resource;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheWriter;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
@ -46,14 +52,6 @@ public class RedisConfig extends CachingConfigurerSupport {
};
}
// 这个注释不能放开发现自定义缓存管理器会导致实体解析失败
//TODO
// @Bean
// public CacheManager cacheManager() {
// RedisCacheManager.RedisCacheManagerBuilder builder = RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(lettuceConnectionFactory);
// return builder.build();
// }
/**
* RedisTemplate配置
*/
@ -77,4 +75,27 @@ public class RedisConfig extends CachingConfigurerSupport {
return redisTemplate;
}
/**
* 缓存配置管理器
*/
@Bean
public CacheManager cacheManager(LettuceConnectionFactory factory) {
// 以锁写入的方式创建RedisCacheWriter对象
RedisCacheWriter writer = RedisCacheWriter.lockingRedisCacheWriter(factory);
/**
* 设置CacheManager的Value序列化方式为JdkSerializationRedisSerializer,
* 但其实RedisCacheConfiguration默认就是使用 StringRedisSerializer序列化key
* JdkSerializationRedisSerializer序列化value, 所以以下注释代码就是默认实现没必要写直接注释掉
*/
// RedisSerializationContext.SerializationPair pair =
// RedisSerializationContext.SerializationPair.fromSerializer(new
// JdkSerializationRedisSerializer(this.getClass().getClassLoader()));
// RedisCacheConfiguration config =
// RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair);
// 创建默认缓存配置对象
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(1)); // 设置缓存有效期一小时;
RedisCacheManager cacheManager = new RedisCacheManager(writer, config);
return cacheManager;
}
}

View File

@ -3,7 +3,9 @@ package org.jeecg.config;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.Filter;
import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
import org.apache.shiro.mgt.DefaultSubjectDAO;
import org.apache.shiro.mgt.SecurityManager;
@ -11,9 +13,8 @@ import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.jeecg.modules.shiro.authc.MyRealm;
import org.jeecg.modules.shiro.authc.ShiroRealm;
import org.jeecg.modules.shiro.authc.aop.JwtFilter;
import org.jeecg.modules.shiro.authc.aop.ResourceCheckFilter;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -44,12 +45,12 @@ public class ShiroConfig {
// 配置不会被拦截的链接 顺序判断
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
filterChainDefinitionMap.put("/test/jeecgDemo/**", "anon"); //测试接口
filterChainDefinitionMap.put("/test/jeecgOrderMain/**", "anon"); //测试接口
filterChainDefinitionMap.put("/**/exportXls", "anon"); //导出接口
filterChainDefinitionMap.put("/**/importExcel", "anon"); //导入接口
filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
filterChainDefinitionMap.put("/", "anon");
filterChainDefinitionMap.put("/doc.html", "anon");
filterChainDefinitionMap.put("/**/*.js", "anon");
filterChainDefinitionMap.put("/**/*.css", "anon");
filterChainDefinitionMap.put("/**/*.html", "anon");
@ -66,12 +67,9 @@ public class ShiroConfig {
//性能监控
filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
filterChainDefinitionMap.put("/redis/**", "anon");
filterChainDefinitionMap.put("/actuator/redis/**", "anon");
//TODO 排除Online请求
filterChainDefinitionMap.put("/auto/cgform/**", "anon");
filterChainDefinitionMap.put("/online/cgreport/api/exportXls/**", "anon");
// 添加自己的过滤器并且取名为jwt
Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
filterMap.put("jwt", new JwtFilter());
@ -79,14 +77,15 @@ public class ShiroConfig {
// <!-- 过滤链定义从上向下顺序执行一般将/**放在最为下边
filterChainDefinitionMap.put("/**", "jwt");
// 未授权界面;
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
// 未授权界面返回JSON
shiroFilterFactoryBean.setUnauthorizedUrl("/sys/common/403");
shiroFilterFactoryBean.setLoginUrl("/sys/common/403");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
@Bean("securityManager")
public DefaultWebSecurityManager securityManager(MyRealm myRealm) {
public DefaultWebSecurityManager securityManager(ShiroRealm myRealm) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(myRealm);

View File

@ -9,6 +9,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.service.Parameter;
import lombok.extern.slf4j.Slf4j;
@ -23,11 +25,12 @@ import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author scott
* @Author scott
*/
@Slf4j
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class Swagger2Config implements WebMvcConfigurer {
/**
@ -39,6 +42,7 @@ public class Swagger2Config implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}

View File

@ -13,7 +13,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Spring Boot 2.0 解决跨域问题
*
* @author qinfeng
* @Author qinfeng
*
*/
@Configuration

View File

@ -14,6 +14,7 @@ import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.stereotype.Component;
@ -22,8 +23,8 @@ import lombok.extern.slf4j.Slf4j;
/**
* mybatis拦截器自动注入创建人创建时间修改人修改时间
* @author scott
* @date 2019-01-19
* @Author scott
* @Date 2019-01-19
*
*/
@Slf4j
@ -44,23 +45,23 @@ public class MybatisInterceptor implements Interceptor {
return invocation.proceed();
}
if (SqlCommandType.INSERT == sqlCommandType) {
Field[] fields = parameter.getClass().getDeclaredFields();
Field[] fields = oConvertUtils.getAllFields(parameter);
for (Field field : fields) {
log.debug("------field.name------" + field.getName());
try {
// 获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if ("createBy".equals(field.getName())) {
field.setAccessible(true);
Object local_createBy = field.get(parameter);
field.setAccessible(false);
if (local_createBy == null || local_createBy.equals("")) {
String createBy = "jeecg-boot";
// 获取登录用户信息
SysUser sysUser = (SysUser) SecurityUtils.getSubject().getPrincipal();
String createBy = "jeecg";
if (sysUser != null) {
// 登录账号
createBy = sysUser.getUsername();
}
if (!oConvertUtils.isEmpty(createBy)) {
if (oConvertUtils.isNotEmpty(createBy)) {
field.setAccessible(true);
field.set(parameter, createBy);
field.setAccessible(false);
@ -78,6 +79,25 @@ public class MybatisInterceptor implements Interceptor {
field.setAccessible(false);
}
}
//注入部门编码
if ("sysOrgCode".equals(field.getName())) {
field.setAccessible(true);
Object local_sysOrgCode = field.get(parameter);
field.setAccessible(false);
if (local_sysOrgCode == null || local_sysOrgCode.equals("")) {
String sysOrgCode = "";
// 获取登录用户信息
if (sysUser != null) {
// 登录账号
sysOrgCode = sysUser.getOrgCode();
}
if (oConvertUtils.isNotEmpty(sysOrgCode)) {
field.setAccessible(true);
field.set(parameter, sysOrgCode);
field.setAccessible(false);
}
}
}
} catch (Exception e) {
}
}
@ -87,9 +107,9 @@ public class MybatisInterceptor implements Interceptor {
if (parameter instanceof ParamMap) {
ParamMap<?> p = (ParamMap<?>) parameter;
parameter = p.get("param1");
fields = parameter.getClass().getDeclaredFields();
fields = oConvertUtils.getAllFields(parameter);
} else {
fields = parameter.getClass().getDeclaredFields();
fields = oConvertUtils.getAllFields(parameter);
}
for (Field field : fields) {
@ -100,14 +120,14 @@ public class MybatisInterceptor implements Interceptor {
Object local_updateBy = field.get(parameter);
field.setAccessible(false);
if (local_updateBy == null || local_updateBy.equals("")) {
String updateBy = "jeecg-boot";
String updateBy = "jeecg";
// 获取登录用户信息
SysUser sysUser = (SysUser) SecurityUtils.getSubject().getPrincipal();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
// 登录账号
updateBy = sysUser.getUsername();
}
if (!oConvertUtils.isEmpty(updateBy)) {
if (oConvertUtils.isNotEmpty(updateBy)) {
field.setAccessible(true);
field.set(parameter, updateBy);
field.setAccessible(false);

View File

@ -27,6 +27,8 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MockController {
private final String JSON_PATH = "classpath:org/jeecg/modules/demo/mock/json";
/**
* 通用json访问接口
* 格式 http://localhost:8080/jeecg-boot/api/json/{filename}
@ -39,6 +41,11 @@ public class MockController {
return readJson(jsonpath);
}
@GetMapping(value = "/asynTreeList")
public String asynTreeList(String id) {
return readJson(JSON_PATH + "/asyn_tree_list_" + id + ".json");
}
@GetMapping(value = "/user")
public String user() {
return readJson("classpath:org/jeecg/modules/demo/mock/json/user.json");
@ -189,7 +196,7 @@ public class MockController {
InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonSrc.replace("classpath:", ""));
json = IOUtils.toString(stream);
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(),e);
}
return json;
}

View File

@ -0,0 +1,29 @@
{
"status": 200,
"success": true,
"message": "ok",
"result": [
{
"id": 1,
"name": "首页",
"component": "dashboard/Analysis",
"orderNum": 1,
"hasChildren": false
},
{
"id": 2,
"name": "常见案例",
"component": "layouts/RouteView",
"orderNum": 2,
"hasChildren": true
},
{
"id": 3,
"name": "系统监控",
"component": "layouts/RouteView",
"orderNum": 3,
"hasChildren": true
}
],
"timestamp": 1554950583837
}

View File

@ -0,0 +1,29 @@
{
"status": 200,
"success": true,
"message": "ok",
"result": [
{
"id": 11,
"name": "首页",
"component": "dashboard/Analysis",
"orderNum": 1,
"hasChildren": false
},
{
"id": 12,
"name": "系统管理",
"component": "layouts/RouteView",
"orderNum": 2,
"hasChildren": true
},
{
"id": 13,
"name": "常见案例",
"component": "layouts/RouteView",
"orderNum": 3,
"hasChildren": true
}
],
"timestamp": 1554950583837
}

View File

@ -0,0 +1,29 @@
{
"status": 200,
"success": true,
"message": "ok",
"result": [
{
"id": 21,
"name": "弹框选择Demo",
"component": "jeecg/SelectDemo",
"orderNum": 1,
"hasChildren": false
},
{
"id": 22,
"name": "单表模型示例",
"component": "jeecg/JeecgDemoList",
"orderNum": 2,
"hasChildren": false
},
{
"id": 23,
"name": "一对多Tab示例",
"component": "jeecg/tablist/JeecgOrderDMainList",
"orderNum": 3,
"hasChildren": false
}
],
"timestamp": 1554950583837
}

View File

@ -0,0 +1,29 @@
{
"status": 200,
"success": true,
"message": "ok",
"result": [
{
"id": 31,
"name": "性能监控",
"component": "layouts/RouteView",
"orderNum": 1,
"hasChildren": true
},
{
"id": 32,
"name": "在线文档",
"component": "layouts/IframePageView",
"orderNum": 2,
"hasChildren": false
},
{
"id": 33,
"name": "工作台",
"component": "dashboard/Workplace",
"orderNum": 3,
"hasChildren": false
}
],
"timestamp": 1554950583837
}

View File

@ -0,0 +1,29 @@
{
"status": 200,
"success": true,
"message": "ok",
"result": [
{
"id": 311,
"name": "Redis监控",
"component": "modules/monitor/RedisInfo",
"orderNum": 1,
"hasChildren": false
},
{
"id": 312,
"name": "JVM信息",
"component": "modules/monitor/JvmInfo",
"orderNum": 2,
"hasChildren": false
},
{
"id": 313,
"name": "Tomcat信息",
"component": "modules/monitor/TomcatInfo",
"orderNum": 3,
"hasChildren": false
}
],
"timestamp": 1554950583837
}

View File

@ -0,0 +1,63 @@
{
"success": true,
"message": "查询成功",
"code": null,
"result": [
{
"resultIndex": 0,
"yearcount": 623,
"year": 2016,
"month": "四月",
"monthcount": 3255,
"classifyname": "证明类",
"cntrnocount": 24,
"cabinetname": "一号柜",
"cabinetcocunt": 12
},
{
"resultIndex": 1,
"yearcount": 243,
"year": 2017,
"month": "五月",
"monthcount": 5673,
"classifyname": "产权类",
"cntrnocount": 52,
"cabinetname": "二号柜",
"cabinetcocunt": 52
},
{
"resultIndex": 2,
"yearcount": 345,
"year": 2018,
"month": "六月",
"monthcount": 2673,
"classifyname": "知识类",
"cntrnocount": 85,
"cabinetname": "三号柜",
"cabinetcocunt": 24
},
{
"resultIndex": 3,
"yearcount": 452,
"year": 2019,
"month": "七月",
"monthcount": 2341,
"classifyname": "技术类",
"cntrnocount": 67,
"cabinetname": "四号柜",
"cabinetcocunt": 45
},
{
"resultIndex": 4,
"yearcount": 645,
"year": 2020,
"month": "八月",
"monthcount": 7473,
"classifyname": "工具类",
"cntrnocount": 93,
"cabinetname": "五号柜",
"cabinetcocunt": 94
}
],
"timestamp": 1554285003594
}

View File

@ -1,30 +1,22 @@
package org.jeecg.modules.demo.test.controller;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.test.entity.JeecgDemo;
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -36,31 +28,29 @@ 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.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
/**
* @Title: Controller
* @Description: 测试demo
* @author jeecg-boot
* @date 2018-12-29
* @versionV1.0
* @Author: jeecg-boot
* @Date:2018-12-29
* @Version:V1.0
*/
@Slf4j
@Api(tags="单表DEMO")
@RestController
@RequestMapping("/test/jeecgDemo")
@Slf4j
public class JeecgDemoController {
public class JeecgDemoController extends JeecgController<JeecgDemo,IJeecgDemoService> {
@Autowired
private IJeecgDemoService jeecgDemoService;
@ -76,52 +66,44 @@ public class JeecgDemoController {
* @param req
* @return
*/
@ApiOperation(value = "获取Demo数据列表", notes = "获取所有Demo数据列表", produces = "application/json")
@ApiOperation(value = "获取Demo数据列表", notes = "获取所有Demo数据列表")
@GetMapping(value = "/list")
@PermissionData(pageComponent="jeecg/JeecgDemoList")
public Result<IPage<JeecgDemo>> list(JeecgDemo jeecgDemo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<JeecgDemo>> result = new Result<IPage<JeecgDemo>>();
/*QueryWrapper<JeecgDemo> queryWrapper = null;
//================================================================================
//高级组合查询
try {
String superQueryParams = req.getParameter("superQueryParams");
if(oConvertUtils.isNotEmpty(superQueryParams)) {
// 解码
superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
List<QueryRuleVo> userList = JSON.parseArray(superQueryParams, QueryRuleVo.class);
log.info(superQueryParams);
queryWrapper = new QueryWrapper<JeecgDemo>();
for (QueryRuleVo rule : userList) {
if(oConvertUtils.isNotEmpty(rule.getField()) && oConvertUtils.isNotEmpty(rule.getRule()) && oConvertUtils.isNotEmpty(rule.getVal())){
ObjectParseUtil.addCriteria(queryWrapper, rule.getField(), QueryRuleEnum.getByValue(rule.getRule()), rule.getVal());
}
}
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//================================================================================
/*
* QueryWrapper<JeecgDemo> queryWrapper = null;
* //===========================================================================
* ===== //高级组合查询 try { String superQueryParams =
* req.getParameter("superQueryParams");
* if(oConvertUtils.isNotEmpty(superQueryParams)) { // 解码 superQueryParams =
* URLDecoder.decode(superQueryParams, "UTF-8"); List<QueryRuleVo> userList =
* JSON.parseArray(superQueryParams, QueryRuleVo.class);
* log.info(superQueryParams); queryWrapper = new QueryWrapper<JeecgDemo>(); for
* (QueryRuleVo rule : userList) { if(oConvertUtils.isNotEmpty(rule.getField())
* && oConvertUtils.isNotEmpty(rule.getRule()) &&
* oConvertUtils.isNotEmpty(rule.getVal())){
* ObjectParseUtil.addCriteria(queryWrapper, rule.getField(),
* QueryRuleEnum.getByValue(rule.getRule()), rule.getVal()); } } } } catch
* (UnsupportedEncodingException e) { e.printStackTrace(); }
* //===========================================================================
* =====
*
* // 手工转换实体驼峰字段为下划线分隔表字段 queryWrapper = queryWrapper==null?new
* QueryWrapper<JeecgDemo>(jeecgDemo):queryWrapper; Page<JeecgDemo> page = new
* Page<JeecgDemo>(pageNo, pageSize);
*
* // 排序逻辑 处理 String column = req.getParameter("column"); String order =
* req.getParameter("order"); if (oConvertUtils.isNotEmpty(column) &&
* oConvertUtils.isNotEmpty(order)) { if ("asc".equals(order)) {
* queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column)); } else {
* queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column)); } }
*/
// 手工转换实体驼峰字段为下划线分隔表字段
queryWrapper = queryWrapper==null?new QueryWrapper<JeecgDemo>(jeecgDemo):queryWrapper;
Page<JeecgDemo> page = new Page<JeecgDemo>(pageNo, pageSize);
// 排序逻辑 处理
String column = req.getParameter("column");
String order = req.getParameter("order");
if (oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) {
if ("asc".equals(order)) {
queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column));
} else {
queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column));
}
}*/
QueryWrapper<JeecgDemo> queryWrapper = QueryGenerator.initQueryWrapper(jeecgDemo, req.getParameterMap());
Page<JeecgDemo> page = new Page<JeecgDemo>(pageNo, pageSize);
IPage<JeecgDemo> pageList = jeecgDemoService.page(page, queryWrapper);
// log.info("查询当前页:" + pageList.getCurrent());
// log.info("查询当前页数量:" + pageList.getSize());
@ -140,14 +122,14 @@ public class JeecgDemoController {
*/
@PostMapping(value = "/add")
@AutoLog(value = "添加测试DEMO")
@ApiOperation(value = "添加DEMO", notes = "添加DEMO")
public Result<JeecgDemo> add(@RequestBody JeecgDemo jeecgDemo) {
Result<JeecgDemo> result = new Result<JeecgDemo>();
try {
jeecgDemoService.save(jeecgDemo);
result.success("添加成功!");
} catch (Exception e) {
e.printStackTrace();
log.info(e.getMessage());
log.error(e.getMessage(), e);
result.error500("操作失败");
}
return result;
@ -160,6 +142,7 @@ public class JeecgDemoController {
* @return
*/
@PutMapping(value = "/edit")
@ApiOperation(value = "编辑DEMO", notes = "编辑DEMO")
public Result<JeecgDemo> eidt(@RequestBody JeecgDemo jeecgDemo) {
Result<JeecgDemo> result = new Result<JeecgDemo>();
JeecgDemo jeecgDemoEntity = jeecgDemoService.getById(jeecgDemo.getId());
@ -184,6 +167,7 @@ public class JeecgDemoController {
*/
@AutoLog(value = "删除测试DEMO")
@DeleteMapping(value = "/delete")
@ApiOperation(value = "通过ID删除DEMO", notes = "通过ID删除DEMO")
public Result<JeecgDemo> delete(@RequestParam(name = "id", required = true) String id) {
Result<JeecgDemo> result = new Result<JeecgDemo>();
JeecgDemo jeecgDemo = jeecgDemoService.getById(id);
@ -206,6 +190,7 @@ public class JeecgDemoController {
* @return
*/
@DeleteMapping(value = "/deleteBatch")
@ApiOperation(value = "批量删除DEMO", notes = "批量删除DEMO")
public Result<JeecgDemo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
Result<JeecgDemo> result = new Result<JeecgDemo>();
if (ids == null || "".equals(ids.trim())) {
@ -223,8 +208,8 @@ public class JeecgDemoController {
* @param id
* @return
*/
@ApiOperation(value = "获取Demo信息", tags = { "获取Demo信息" }, notes = "注意问题点")
@GetMapping(value = "/queryById")
@ApiOperation(value = "通过ID查询DEMO", notes = "通过ID查询DEMO")
public Result<JeecgDemo> queryById(@ApiParam(name = "id", value = "示例id", required = true) @RequestParam(name = "id", required = true) String id) {
Result<JeecgDemo> result = new Result<JeecgDemo>();
JeecgDemo jeecgDemo = jeecgDemoService.getById(id);
@ -236,80 +221,31 @@ public class JeecgDemoController {
}
return result;
}
/**
* 导出excel
*
* @param request
* @param response
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
// Step.1 组装查询条件
QueryWrapper<JeecgDemo> queryWrapper = null;
try {
String paramsStr = request.getParameter("paramsStr");
if (oConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
JeecgDemo jeecgDemo = JSON.parseObject(deString, JeecgDemo.class);
queryWrapper = QueryGenerator.initQueryWrapper(jeecgDemo, request.getParameterMap());
log.info(paramsStr);
log.info(jeecgDemo.toString());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<JeecgDemo> pageList = jeecgDemoService.list(queryWrapper);
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME,"Excel导出文件名字");
//注解对象Class
mv.addObject(NormalExcelConstants.CLASS,JeecgDemo.class);
//自定义表格参数
mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("自定义导出Excel模板内容标题","导出人:Jeecg","导出信息"));
//导出数据列表
mv.addObject(NormalExcelConstants.DATA_LIST,pageList);
return mv;
@PermissionData(pageComponent="jeecg/JeecgDemoList")
public ModelAndView exportXls(HttpServletRequest request, JeecgDemo jeecgDemo) {
return super.exportXls(request, jeecgDemo, JeecgDemo.class, "单表模型");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<JeecgDemo> listJeecgDemos = ExcelImportUtil.importExcel(file.getInputStream(), JeecgDemo.class, params);
for (JeecgDemo jeecgDemoExcel : listJeecgDemos) {
jeecgDemoService.save(jeecgDemoExcel);
}
return Result.ok("文件导入成功!数据行数:" + listJeecgDemos.size());
} catch (Exception e) {
log.error(e.getMessage());
return Result.error("文件导入失败!");
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.ok("文件导入失败!");
return super.importExcel(request, response, JeecgDemo.class);
}
// ================================================================================================================
/**
* redis操作 -- set
@ -378,9 +314,9 @@ public class JeecgDemoController {
}
// ================================================================================================================
// ==========================================动态表单 JSON接收测试===========================================//
// ==========================================动态表单
// JSON接收测试===========================================//
@PostMapping(value = "/testOnlineAdd")
public Result<JeecgDemo> testOnlineAdd(@RequestBody JSONObject json) {
Result<JeecgDemo> result = new Result<JeecgDemo>();

View File

@ -34,9 +34,9 @@ import lombok.extern.slf4j.Slf4j;
/**
* @Title: Controller
* @Description: 订单模拟
* @author: ZhiLin
* @Author: ZhiLin
* @Date: 2019-02-20
* @version: v1.0
* @Version: v1.0
*/
@Slf4j
@RestController
@ -95,8 +95,7 @@ public class JeecgOrderDMainController {
jeecgOrderMainService.save(jeecgOrderMain);
result.success("添加成功!");
} catch (Exception e) {
e.printStackTrace();
log.info(e.getMessage());
log.error(e.getMessage(),e);
result.error500("操作失败");
}
return result;

View File

@ -50,9 +50,9 @@ import lombok.extern.slf4j.Slf4j;
/**
* @Title: Controller
* @Description: 订单
* @author jeecg-boot
* @date 2019-02-15
* @version V1.0
* @Author: jeecg-boot
* @Date:2019-02-15
* @Version: V1.0
*/
@RestController
@RequestMapping("/test/jeecgOrderMain")
@ -104,8 +104,7 @@ public class JeecgOrderMainController {
jeecgOrderMainService.saveMain(jeecgOrderMain, jeecgOrderMainPage.getJeecgOrderCustomerList(), jeecgOrderMainPage.getJeecgOrderTicketList());
result.success("添加成功!");
} catch (Exception e) {
e.printStackTrace();
log.info(e.getMessage());
log.error(e.getMessage(),e);
result.error500("操作失败");
}
return result;
@ -227,22 +226,9 @@ public class JeecgOrderMainController {
* @param response
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
public ModelAndView exportXls(HttpServletRequest request, JeecgOrderMain jeecgOrderMain) {
// Step.1 组装查询条件
QueryWrapper<JeecgOrderMain> queryWrapper = null;
try {
String paramsStr = request.getParameter("paramsStr");
if (oConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
JeecgOrderMain jeecgOrderMain = JSON.parseObject(deString, JeecgOrderMain.class);
queryWrapper = QueryGenerator.initQueryWrapper(jeecgOrderMain, request.getParameterMap());
log.info(paramsStr);
log.info(jeecgOrderMain.toString());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
QueryWrapper<JeecgOrderMain> queryWrapper = QueryGenerator.initQueryWrapper(jeecgOrderMain, request.getParameterMap());
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<JeecgOrderMainPage> pageList = new ArrayList<JeecgOrderMainPage>();
@ -297,8 +283,8 @@ public class JeecgOrderMainController {
}
return Result.ok("文件导入成功!");
} catch (Exception e) {
log.error(e.toString());
return Result.ok("文件导入失败");
log.error(e.getMessage(),e);
return Result.error("文件导入失败"+e.getMessage());
} finally {
try {
file.getInputStream().close();
@ -307,7 +293,7 @@ public class JeecgOrderMainController {
}
}
}
return Result.ok("文件导入失败!");
return Result.error("文件导入失败!");
}
}

View File

@ -1,68 +1,76 @@
package org.jeecg.modules.message.controller;
package org.jeecg.modules.demo.test.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.message.entity.SysMessage;
import org.jeecg.modules.message.service.ISysMessageService;
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 org.jeecg.modules.demo.test.entity.JoaDemo;
import org.jeecg.modules.demo.test.service.IJoaDemoService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
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.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
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;
/**
* @Title: Controller
* @Description: 消息
* @author jeecg-boot
* @date 2019-04-09
* @version V1.0
* @Description: 流程测试
* @Author: jeecg-boot
* @Date: 2019-05-14
* @Version: V1.0
*/
@RestController
@RequestMapping("/message/sysMessage")
@RequestMapping("/test/joaDemo")
@Slf4j
public class SysMessageController {
public class JoaDemoController {
@Autowired
private ISysMessageService sysMessageService;
private IJoaDemoService joaDemoService;
/**
* 分页列表查询
* @param sysMessage
* @param joaDemo
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@GetMapping(value = "/list")
public Result<IPage<SysMessage>> queryPageList(SysMessage sysMessage,
public Result<IPage<JoaDemo>> queryPageList(JoaDemo joaDemo,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<SysMessage>> result = new Result<IPage<SysMessage>>();
QueryWrapper<SysMessage> queryWrapper = QueryGenerator.initQueryWrapper(sysMessage, req.getParameterMap());
Page<SysMessage> page = new Page<SysMessage>(pageNo, pageSize);
IPage<SysMessage> pageList = sysMessageService.page(page, queryWrapper);
Result<IPage<JoaDemo>> result = new Result<IPage<JoaDemo>>();
QueryWrapper<JoaDemo> queryWrapper = QueryGenerator.initQueryWrapper(joaDemo, req.getParameterMap());
Page<JoaDemo> page = new Page<JoaDemo>(pageNo, pageSize);
IPage<JoaDemo> pageList = joaDemoService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
return result;
@ -70,18 +78,17 @@ public class SysMessageController {
/**
* 添加
* @param sysMessage
* @param joaDemo
* @return
*/
@PostMapping(value = "/add")
public Result<SysMessage> add(@RequestBody SysMessage sysMessage) {
Result<SysMessage> result = new Result<SysMessage>();
public Result<JoaDemo> add(@RequestBody JoaDemo joaDemo) {
Result<JoaDemo> result = new Result<JoaDemo>();
try {
sysMessageService.save(sysMessage);
joaDemoService.save(joaDemo);
result.success("添加成功!");
} catch (Exception e) {
e.printStackTrace();
log.info(e.getMessage());
log.error(e.getMessage(),e);
result.error500("操作失败");
}
return result;
@ -89,17 +96,17 @@ public class SysMessageController {
/**
* 编辑
* @param sysMessage
* @param joaDemo
* @return
*/
@PutMapping(value = "/edit")
public Result<SysMessage> edit(@RequestBody SysMessage sysMessage) {
Result<SysMessage> result = new Result<SysMessage>();
SysMessage sysMessageEntity = sysMessageService.getById(sysMessage.getId());
if(sysMessageEntity==null) {
public Result<JoaDemo> edit(@RequestBody JoaDemo joaDemo) {
Result<JoaDemo> result = new Result<JoaDemo>();
JoaDemo joaDemoEntity = joaDemoService.getById(joaDemo.getId());
if(joaDemoEntity==null) {
result.error500("未找到对应实体");
}else {
boolean ok = sysMessageService.updateById(sysMessage);
boolean ok = joaDemoService.updateById(joaDemo);
//TODO 返回false说明什么
if(ok) {
result.success("修改成功!");
@ -115,13 +122,13 @@ public class SysMessageController {
* @return
*/
@DeleteMapping(value = "/delete")
public Result<SysMessage> delete(@RequestParam(name="id",required=true) String id) {
Result<SysMessage> result = new Result<SysMessage>();
SysMessage sysMessage = sysMessageService.getById(id);
if(sysMessage==null) {
public Result<JoaDemo> delete(@RequestParam(name="id",required=true) String id) {
Result<JoaDemo> result = new Result<JoaDemo>();
JoaDemo joaDemo = joaDemoService.getById(id);
if(joaDemo==null) {
result.error500("未找到对应实体");
}else {
boolean ok = sysMessageService.removeById(id);
boolean ok = joaDemoService.removeById(id);
if(ok) {
result.success("删除成功!");
}
@ -136,12 +143,12 @@ public class SysMessageController {
* @return
*/
@DeleteMapping(value = "/deleteBatch")
public Result<SysMessage> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
Result<SysMessage> result = new Result<SysMessage>();
public Result<JoaDemo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
Result<JoaDemo> result = new Result<JoaDemo>();
if(ids==null || "".equals(ids.trim())) {
result.error500("参数不识别!");
}else {
this.sysMessageService.removeByIds(Arrays.asList(ids.split(",")));
this.joaDemoService.removeByIds(Arrays.asList(ids.split(",")));
result.success("删除成功!");
}
return result;
@ -153,13 +160,13 @@ public class SysMessageController {
* @return
*/
@GetMapping(value = "/queryById")
public Result<SysMessage> queryById(@RequestParam(name="id",required=true) String id) {
Result<SysMessage> result = new Result<SysMessage>();
SysMessage sysMessage = sysMessageService.getById(id);
if(sysMessage==null) {
public Result<JoaDemo> queryById(@RequestParam(name="id",required=true) String id) {
Result<JoaDemo> result = new Result<JoaDemo>();
JoaDemo joaDemo = joaDemoService.getById(id);
if(joaDemo==null) {
result.error500("未找到对应实体");
}else {
result.setResult(sysMessage);
result.setResult(joaDemo);
result.setSuccess(true);
}
return result;
@ -174,13 +181,13 @@ public class SysMessageController {
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
// Step.1 组装查询条件
QueryWrapper<SysMessage> queryWrapper = null;
QueryWrapper<JoaDemo> queryWrapper = null;
try {
String paramsStr = request.getParameter("paramsStr");
if (oConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
SysMessage sysMessage = JSON.parseObject(deString, SysMessage.class);
queryWrapper = QueryGenerator.initQueryWrapper(sysMessage, request.getParameterMap());
JoaDemo joaDemo = JSON.parseObject(deString, JoaDemo.class);
queryWrapper = QueryGenerator.initQueryWrapper(joaDemo, request.getParameterMap());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
@ -188,11 +195,11 @@ public class SysMessageController {
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<SysMessage> pageList = sysMessageService.list(queryWrapper);
List<JoaDemo> pageList = joaDemoService.list(queryWrapper);
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "消息列表");
mv.addObject(NormalExcelConstants.CLASS, SysMessage.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("消息列表数据", "导出人:Jeecg", "导出信息"));
mv.addObject(NormalExcelConstants.FILE_NAME, "流程测试列表");
mv.addObject(NormalExcelConstants.CLASS, JoaDemo.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("流程测试列表数据", "导出人:Jeecg", "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
@ -215,14 +222,14 @@ public class SysMessageController {
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<SysMessage> listSysMessages = ExcelImportUtil.importExcel(file.getInputStream(), SysMessage.class, params);
for (SysMessage sysMessageExcel : listSysMessages) {
sysMessageService.save(sysMessageExcel);
List<JoaDemo> listJoaDemos = ExcelImportUtil.importExcel(file.getInputStream(), JoaDemo.class, params);
for (JoaDemo joaDemoExcel : listJoaDemos) {
joaDemoService.save(joaDemoExcel);
}
return Result.ok("文件导入成功!数据行数" + listSysMessages.size());
return Result.ok("文件导入成功!数据行数:" + listJoaDemos.size());
} catch (Exception e) {
log.error(e.getMessage());
return Result.error("文件导入失败");
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
} finally {
try {
file.getInputStream().close();

View File

@ -1,73 +1,76 @@
package org.jeecg.modules.demo.test.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: jeecg 测试demo
* @author jeecg-boot
* @date 2018-12-29
* @versionV1.0
* @Author: jeecg-boot
* @Date: 2018-12-29
* @Version:V1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="测试DEMO对象", description="测试DEMO")
@TableName("demo")
public class JeecgDemo implements Serializable {
private static final long serialVersionUID = 1L;
public class JeecgDemo extends JeecgEntity {
/** 主键ID */
@TableId(type = IdType.UUID)
private java.lang.String id;
/** 部门编码 */
@Excel(name="部门编码",width=25)
@ApiModelProperty(value = "部门编码")
private java.lang.String sysOrgCode;
/** 姓名 */
@Excel(name="姓名",width=25)
@ApiModelProperty(value = "姓名")
private java.lang.String name;
/** 关键词 */
@ApiModelProperty(value = "关键词")
@Excel(name="关键词",width=15)
private java.lang.String keyWord;
/** 打卡时间 */
@ApiModelProperty(value = "打卡时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name="打卡时间",width=20,format="yyyy-MM-dd HH:mm:ss")
private java.util.Date punchTime;
/** 工资 */
@ApiModelProperty(value = "工资",example = "0")
@Excel(name="工资",width=15)
private java.math.BigDecimal salaryMoney;
/** 奖金 */
@ApiModelProperty(value = "奖金",example = "0")
@Excel(name="奖金",width=15)
private java.lang.Double bonusMoney;
/** 性别 {男:1,女:2} */
@ApiModelProperty(value = "性别")
@Excel(name = "性别", width = 15, dicCode = "sex")
private java.lang.String sex;
/** 年龄 */
@ApiModelProperty(value = "年龄",example = "0")
@Excel(name="年龄",width=15)
private java.lang.Integer age;
/** 生日 */
@ApiModelProperty(value = "生日")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Excel(name="生日",format="yyyy-MM-dd")
private java.util.Date birthday;
/** 邮箱 */
@ApiModelProperty(value = "邮箱")
@Excel(name="邮箱",width=30)
private java.lang.String email;
/** 个人简介 */
@ApiModelProperty(value = "个人简介")
private java.lang.String content;
/** createTime */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date createTime;
/** 创建人 */
private String createBy;
/** 更新人 */
private String updateBy;
/** 更新时间 */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}

View File

@ -12,9 +12,9 @@ import org.springframework.format.annotation.DateTimeFormat;
/**
* @Description: 订单客户
* @author jeecg-boot
* @date 2019-02-15
* @version V1.0
* @Author: jeecg-boot
* @Date: 2019-02-15
* @Version: V1.0
*/
@Data
@TableName("jeecg_order_customer")

View File

@ -11,9 +11,9 @@ import org.springframework.format.annotation.DateTimeFormat;
/**
* @Description: 订单
* @author jeecg-boot
* @date 2019-02-15
* @version V1.0
* @Author: jeecg-boot
* @Date: 2019-02-15
* @Version: V1.0
*/
@Data
@TableName("jeecg_order_main")

View File

@ -11,9 +11,9 @@ import org.springframework.format.annotation.DateTimeFormat;
/**
* @Description: 订单机票
* @author jeecg-boot
* @date 2019-02-15
* @version V1.0
* @Author: jeecg-boot
* @Date: 2019-02-15
* @Version: V1.0
*/
@Data
@TableName("jeecg_order_ticket")

View File

@ -0,0 +1,67 @@
package org.jeecg.modules.demo.test.entity;
import java.io.Serializable;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
/**
* @Description: 流程测试
* @Author: jeecg-boot
* @Date: 2019-05-14
* @Version: V1.0
*/
@Data
@TableName("joa_demo")
public class JoaDemo implements Serializable {
private static final long serialVersionUID = 1L;
/**ID*/
@TableId(type = IdType.UUID)
private java.lang.String id;
/**请假人*/
@Excel(name = "请假人", width = 15)
private java.lang.String name;
/**请假天数*/
@Excel(name = "请假天数", width = 15)
private java.lang.Integer days;
/**开始时间*/
@Excel(name = "开始时间", width = 20, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private java.util.Date beginDate;
/**请假结束时间*/
@Excel(name = "请假结束时间", width = 20, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private java.util.Date endDate;
/**请假原因*/
@Excel(name = "请假原因", width = 15)
private java.lang.String reason;
/**流程状态*/
@Excel(name = "流程状态", width = 15)
private java.lang.String bpmStatus;
/**创建人id*/
@Excel(name = "创建人id", width = 15)
private java.lang.String createBy;
/**创建时间*/
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private java.util.Date createTime;
/**修改时间*/
@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private java.util.Date updateTime;
/**修改人id*/
@Excel(name = "修改人id", width = 15)
private java.lang.String updateBy;
}

View File

@ -7,9 +7,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: jeecg 测试demo
* @author jeecg-boot
* @date 2018-12-29
* @version V1.0
* @Author: jeecg-boot
* @Date: 2018-12-29
* @Version: V1.0
*/
public interface JeecgDemoMapper extends BaseMapper<JeecgDemo> {

View File

@ -10,9 +10,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 订单客户
* @author jeecg-boot
* @date 2019-02-15
* @version V1.0
* @Author: jeecg-boot
* @Date: 2019-02-15
* @Version: V1.0
*/
public interface JeecgOrderCustomerMapper extends BaseMapper<JeecgOrderCustomer> {

View File

@ -8,9 +8,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 订单
* @author jeecg-boot
* @date 2019-02-15
* @version V1.0
* @Author: jeecg-boot
* @Date: 2019-02-15
* @Version: V1.0
*/
public interface JeecgOrderMainMapper extends BaseMapper<JeecgOrderMain> {

View File

@ -9,9 +9,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 订单机票
* @author jeecg-boot
* @date 2019-02-15
* @version V1.0
* @Author: jeecg-boot
* @Date: 2019-02-15
* @Version: V1.0
*/
public interface JeecgOrderTicketMapper extends BaseMapper<JeecgOrderTicket> {

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.demo.test.mapper;
import org.jeecg.modules.demo.test.entity.JoaDemo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 流程测试
* @Author: jeecg-boot
* @Date: 2019-05-14
* @Version: V1.0
*/
public interface JoaDemoMapper extends BaseMapper<JoaDemo> {
}

Some files were not shown because too many files have changed in this diff Show More