mirror of https://gitee.com/jeecg/jeecg.git
parent
d4ce14f113
commit
a522ece4df
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -0,0 +1,86 @@
|
||||
package org.jeecgframework.core.enums;
|
||||
|
||||
import org.jeecgframework.core.util.StringUtil;
|
||||
|
||||
/**
|
||||
* ACE样式类型
|
||||
*
|
||||
* @author zhoujf
|
||||
*/
|
||||
public enum SysACEIconEnum {
|
||||
|
||||
default_icon("default","icon-list-alt", "默认"),
|
||||
back_icon("back","icon-briefcase", "返回"),
|
||||
pie_icon("pie","icon-bar-chart", "小饼状图"),
|
||||
pictures_icon("pictures","icon-picture", "图片"),
|
||||
pencil_icon("pencil","icon-edit", "笔"),
|
||||
map_icon("map","icon-globe", "小地图"),
|
||||
group_add_icon("group_add","icon-group", "组"),
|
||||
calculator_icon("calculator","icon-desktop", "计算器"),
|
||||
folder_icon("folder","icon-list","文件夹");
|
||||
|
||||
|
||||
/**
|
||||
* 风格
|
||||
*/
|
||||
private String style;
|
||||
|
||||
|
||||
/**
|
||||
* 样式
|
||||
*/
|
||||
private String themes;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
private SysACEIconEnum(String style, String themes, String desc) {
|
||||
this.style = style;
|
||||
this.themes = themes;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public void setStyle(String style) {
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public String getThemes() {
|
||||
return themes;
|
||||
}
|
||||
|
||||
public void setThemes(String themes) {
|
||||
this.themes = themes;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
|
||||
public static SysACEIconEnum toEnum(String style) {
|
||||
if (StringUtil.isEmpty(style)) {
|
||||
//默认风格
|
||||
return default_icon;
|
||||
}
|
||||
for(SysACEIconEnum item : SysACEIconEnum.values()) {
|
||||
if(item.getStyle().equals(style)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
//默认风格
|
||||
return default_icon;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "{style: " + style + ", themes: " + themes + ", desc: " + desc +"}";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,152 @@
|
||||
package org.jeecgframework.web.cgform.util;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.jeecgframework.core.common.exception.BusinessException;
|
||||
import org.jeecgframework.p3.core.util.MD5Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 加签、验签工具.
|
||||
*
|
||||
* @author zhoujf
|
||||
*/
|
||||
public abstract class SignatureUtil {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SignatureUtil.class);
|
||||
|
||||
/**
|
||||
* 加签,MD5.
|
||||
* @param paramMap 参数Map,不包含商户秘钥且顺序确定
|
||||
* @param key 商户秘钥
|
||||
* @return 签名串
|
||||
*/
|
||||
public static String sign(Map<String, String> paramMap, String key) {
|
||||
if(key == null){
|
||||
throw new BusinessException("key不能为空");
|
||||
}
|
||||
String sign = createSign(paramMap,key);
|
||||
return sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。
|
||||
*/
|
||||
private static String createSign(Map<String, String> paramMap, String key) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
SortedMap<String,String> sort=new TreeMap<String,String>(paramMap);
|
||||
Set<Entry<String, String>> es = sort.entrySet();
|
||||
Iterator<Entry<String, String>> it = es.iterator();
|
||||
while (it.hasNext()) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
String k = (String) entry.getKey();
|
||||
String v = (String) entry.getValue();
|
||||
if (null != v && !"".equals(v)&& !"null".equals(v) && !"sign".equals(k) && !"key".equals(k)) {
|
||||
sb.append(k + "=" + v + "&");
|
||||
}
|
||||
}
|
||||
sb.append("key=" + key);
|
||||
LOG.info("HMAC source:{}", new Object[] { sb.toString() } );
|
||||
String sign = MD5Util.MD5Encode(sb.toString(), "UTF-8").toUpperCase();
|
||||
LOG.info("HMAC:{}", new Object[] { sign } );
|
||||
return sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验签, 仅支持MD5.
|
||||
* @param paramMap 参数Map,不包含商户秘钥且顺序确定
|
||||
* @param key 商户秘钥
|
||||
* @param sign 签名串
|
||||
* @return 验签结果
|
||||
*/
|
||||
public static boolean checkSign(Map<String, String> paramMap, String key, String sign) {
|
||||
if(key == null){
|
||||
throw new BusinessException("key不能为空");
|
||||
}
|
||||
if(sign == null){
|
||||
throw new BusinessException("需要验签的字符为空");
|
||||
}
|
||||
|
||||
return sign.equals(sign(paramMap,key));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过request获取签名Map
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> getSignMap(HttpServletRequest request){
|
||||
Map<String,String> paramMap = new HashMap<String, String>();
|
||||
Map<String, String[]> map = request.getParameterMap();
|
||||
Set<Entry<String, String[]>> es = map.entrySet();
|
||||
Iterator<Entry<String, String[]>> it = es.iterator();
|
||||
while (it.hasNext()) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
String k = (String) entry.getKey();
|
||||
Object ov = entry.getValue();
|
||||
String v="";
|
||||
if(ov instanceof String[]){
|
||||
String[] value=(String[])ov;
|
||||
v= value[0];
|
||||
}else{
|
||||
v=ov.toString();
|
||||
}
|
||||
paramMap.put(k, v);
|
||||
}
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过request获取签名Map
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> getSignMap(String url){
|
||||
Map<String,String> paramMap = new HashMap<String, String>();
|
||||
url = url.substring(url.indexOf("?")+1);
|
||||
String[] params = url.split("&");
|
||||
for(int i=0;i<params.length;i++){
|
||||
String param = params[i];
|
||||
if(param.indexOf("=")!=-1){
|
||||
String[] values = param.split("=");
|
||||
if(values!=null&&values.length==2){
|
||||
//update----begin---author:scott----date:20160115----for:昵称转码,签名问题处理----
|
||||
if ("nickname".equals(values[0])) {
|
||||
paramMap.put(values[0],URLDecoder.decode(values[1]));
|
||||
}else{
|
||||
paramMap.put(values[0], values[1]);
|
||||
}
|
||||
//update----begin---author:scott----date:20160115----for:昵称转码,签名问题处理----
|
||||
}
|
||||
}
|
||||
}
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String url = "http://www.saphao.com:9999/P3-Web/commonxrs/toIndex.do?actId=402880ee51334a520151334c3eaf0001&openid=oR0jFt_DTsAUJebWqGeq3A1VWfRw&nickname=JEFF&subscribe=1&jwid=&sign=F5E56A64B650A98E67CCCFFF871C7133";
|
||||
// Map<String,String> t = getSignMap(url);
|
||||
// for(Map.Entry<String, String> entry:t.entrySet()){
|
||||
// System.out.println(entry.getKey()+"--->"+entry.getValue());
|
||||
// }
|
||||
String key = "26F72780372E84B6CFAED6F7B19139CC47B1912B6CAED753";
|
||||
Map<String, String> paramMap = new HashMap<String, String>();
|
||||
paramMap.put("tableName", "jform_le_main");
|
||||
paramMap.put("id", "402813815398698b015398698b710000");
|
||||
paramMap.put("data", "{jform_le_main:[{id=\"402813815398698b015398698b710000\",name:\"ceshi111111\",sex:1,remark:\"java developer\"}],jform_le_subone:[{main_id=\"402813815398698b015398698b710000\",name:\"ceshi111111\",sex:1,remark:\"java developer\"}],jform_le_submany:[{main_id=\"402813815398698b015398698b710000\",name:\"ceshi111111\",sex:1,remark:\"java developer\"},{name:\"ceshi111111\",sex:1,remark:\"java developer\"}]}");
|
||||
paramMap.put("method", "updateFormInfo");
|
||||
System.out.println(createSign(paramMap,key));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package org.jeecgframework.web.cgform.util;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* $.ajax后需要接受的JSON
|
||||
*
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class TableJson {
|
||||
|
||||
private boolean success = true;// 是否成功
|
||||
private String msg = "操作成功";// 提示信息
|
||||
private Integer tableType;
|
||||
private Object tableData = null;// 单表/主表信息
|
||||
private Map<String, Object> subTableDate;// 子表信息
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public Integer getTableType() {
|
||||
return tableType;
|
||||
}
|
||||
|
||||
public void setTableType(Integer tableType) {
|
||||
this.tableType = tableType;
|
||||
}
|
||||
|
||||
public Object getTableData() {
|
||||
return tableData;
|
||||
}
|
||||
|
||||
public void setTableData(Object tableData) {
|
||||
this.tableData = tableData;
|
||||
}
|
||||
|
||||
public Map<String, Object> getSubTableDate() {
|
||||
return subTableDate;
|
||||
}
|
||||
|
||||
public void setSubTableDate(Map<String, Object> subTableDate) {
|
||||
this.subTableDate = subTableDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TableJson [success=" + success + ", msg=" + msg
|
||||
+ ", tableType=" + tableType + ", tableData=" + tableData
|
||||
+ ", subTableDate=" + subTableDate + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,350 @@
|
||||
package org.jeecgframework.web.onlinedoc.controller;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jeecgframework.core.common.controller.BaseController;
|
||||
import org.jeecgframework.core.common.exception.BusinessException;
|
||||
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
|
||||
import org.jeecgframework.core.common.model.json.AjaxJson;
|
||||
import org.jeecgframework.core.common.model.json.DataGrid;
|
||||
import org.jeecgframework.core.constant.Globals;
|
||||
import org.jeecgframework.core.util.ExceptionUtil;
|
||||
import org.jeecgframework.core.util.MyBeanUtils;
|
||||
import org.jeecgframework.core.util.ResourceUtil;
|
||||
import org.jeecgframework.core.util.StringUtil;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
|
||||
import org.jeecgframework.tag.core.easyui.TagUtil;
|
||||
import org.jeecgframework.web.onlinedoc.entity.OnlineDocEntity;
|
||||
import org.jeecgframework.web.onlinedoc.service.OnlineDocServiceI;
|
||||
import org.jeecgframework.web.system.service.SystemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Title: Controller
|
||||
* @Description: 在线文档
|
||||
* @author onlineGenerator
|
||||
* @date 2016-03-19 15:49:59
|
||||
* @version V1.0
|
||||
*
|
||||
*/
|
||||
@Scope("prototype")
|
||||
@Controller
|
||||
@RequestMapping("/onlineDocController")
|
||||
public class OnlineDocController extends BaseController {
|
||||
/**
|
||||
* Logger for this class
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger(OnlineDocController.class);
|
||||
|
||||
@Autowired
|
||||
private OnlineDocServiceI onlineDocService;
|
||||
@Autowired
|
||||
private SystemService systemService;
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在线文档列表 页面跳转
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "list")
|
||||
public ModelAndView list(HttpServletRequest request) {
|
||||
return new ModelAndView("jeecg/onlinedoc/onlineDocList");
|
||||
}
|
||||
|
||||
/**
|
||||
* easyui AJAX请求数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param dataGrid
|
||||
* @param user
|
||||
*/
|
||||
|
||||
@RequestMapping(params = "datagrid")
|
||||
public void datagrid(OnlineDocEntity onlineDoc,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
|
||||
CriteriaQuery cq = new CriteriaQuery(OnlineDocEntity.class, dataGrid);
|
||||
//查询条件组装器
|
||||
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, onlineDoc, request.getParameterMap());
|
||||
try{
|
||||
//自定义追加查询条件
|
||||
}catch (Exception e) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
cq.add();
|
||||
this.onlineDocService.getDataGridReturn(cq, true);
|
||||
TagUtil.datagrid(response, dataGrid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除在线文档
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "doDel")
|
||||
@ResponseBody
|
||||
public AjaxJson doDel(OnlineDocEntity onlineDoc, HttpServletRequest request) {
|
||||
AjaxJson j = new AjaxJson();
|
||||
onlineDoc = systemService.getEntity(OnlineDocEntity.class, onlineDoc.getId());
|
||||
message = "在线文档删除成功";
|
||||
try{
|
||||
onlineDocService.delete(onlineDoc);
|
||||
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
message = "在线文档删除失败";
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
j.setMsg(message);
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除在线文档
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "doBatchDel")
|
||||
@ResponseBody
|
||||
public AjaxJson doBatchDel(String ids,HttpServletRequest request){
|
||||
AjaxJson j = new AjaxJson();
|
||||
message = "在线文档删除成功";
|
||||
try{
|
||||
for(String id:ids.split(",")){
|
||||
OnlineDocEntity onlineDoc = systemService.getEntity(OnlineDocEntity.class,
|
||||
id
|
||||
);
|
||||
onlineDocService.delete(onlineDoc);
|
||||
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
message = "在线文档删除失败";
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
j.setMsg(message);
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加在线文档
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "doAdd")
|
||||
@ResponseBody
|
||||
public AjaxJson doAdd(OnlineDocEntity onlineDoc, HttpServletRequest request) {
|
||||
AjaxJson j = new AjaxJson();
|
||||
message = "在线文档添加成功";
|
||||
try{
|
||||
onlineDocService.save(onlineDoc);
|
||||
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
message = "在线文档添加失败";
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
j.setMsg(message);
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新在线文档
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "doUpdate")
|
||||
@ResponseBody
|
||||
public AjaxJson doUpdate(OnlineDocEntity onlineDoc, HttpServletRequest request) {
|
||||
AjaxJson j = new AjaxJson();
|
||||
message = "在线文档更新成功";
|
||||
OnlineDocEntity t = onlineDocService.get(OnlineDocEntity.class, onlineDoc.getId());
|
||||
try {
|
||||
MyBeanUtils.copyBeanNotNull2Bean(onlineDoc, t);
|
||||
onlineDocService.saveOrUpdate(t);
|
||||
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "在线文档更新失败";
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
j.setMsg(message);
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在线文档新增页面跳转
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "goAdd")
|
||||
public ModelAndView goAdd(OnlineDocEntity onlineDoc, HttpServletRequest req) {
|
||||
if (StringUtil.isNotEmpty(onlineDoc.getId())) {
|
||||
onlineDoc = onlineDocService.getEntity(OnlineDocEntity.class, onlineDoc.getId());
|
||||
req.setAttribute("onlineDocPage", onlineDoc);
|
||||
}
|
||||
return new ModelAndView("jeecg/onlinedoc/onlineDoc-add");
|
||||
}
|
||||
/**
|
||||
* 在线文档编辑页面跳转
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "goUpdate")
|
||||
public ModelAndView goUpdate(OnlineDocEntity onlineDoc, HttpServletRequest req) {
|
||||
if (StringUtil.isNotEmpty(onlineDoc.getId())) {
|
||||
onlineDoc = onlineDocService.getEntity(OnlineDocEntity.class, onlineDoc.getId());
|
||||
req.setAttribute("onlineDocPage", onlineDoc);
|
||||
}
|
||||
return new ModelAndView("jeecg/onlinedoc/onlineDoc-update");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入功能跳转
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(params = "upload")
|
||||
public ModelAndView upload(HttpServletRequest req) {
|
||||
req.setAttribute("controller_name","onlineDocController");
|
||||
return new ModelAndView("common/upload/pub_excel_upload");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(params = "exportXls")
|
||||
public String exportXls(OnlineDocEntity onlineDoc,HttpServletRequest request,HttpServletResponse response
|
||||
, DataGrid dataGrid,ModelMap modelMap) {
|
||||
CriteriaQuery cq = new CriteriaQuery(OnlineDocEntity.class, dataGrid);
|
||||
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, onlineDoc, request.getParameterMap());
|
||||
List<OnlineDocEntity> onlineDocs = this.onlineDocService.getListByCriteriaQuery(cq,false);
|
||||
modelMap.put(NormalExcelConstants.FILE_NAME,"在线文档");
|
||||
modelMap.put(NormalExcelConstants.CLASS,OnlineDocEntity.class);
|
||||
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("在线文档列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
|
||||
"导出信息"));
|
||||
modelMap.put(NormalExcelConstants.DATA_LIST,onlineDocs);
|
||||
return NormalExcelConstants.JEECG_EXCEL_VIEW;
|
||||
}
|
||||
/**
|
||||
* 导出excel 使模板
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(params = "exportXlsByT")
|
||||
public String exportXlsByT(OnlineDocEntity onlineDoc,HttpServletRequest request,HttpServletResponse response
|
||||
, DataGrid dataGrid,ModelMap modelMap) {
|
||||
modelMap.put(NormalExcelConstants.FILE_NAME,"在线文档");
|
||||
modelMap.put(NormalExcelConstants.CLASS,OnlineDocEntity.class);
|
||||
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("在线文档列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
|
||||
"导出信息"));
|
||||
modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
|
||||
return NormalExcelConstants.JEECG_EXCEL_VIEW;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(params = "importExcel", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
AjaxJson j = new AjaxJson();
|
||||
|
||||
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<OnlineDocEntity> listOnlineDocEntitys = ExcelImportUtil.importExcel(file.getInputStream(),OnlineDocEntity.class,params);
|
||||
for (OnlineDocEntity onlineDoc : listOnlineDocEntitys) {
|
||||
onlineDocService.save(onlineDoc);
|
||||
}
|
||||
j.setMsg("文件导入成功!");
|
||||
} catch (Exception e) {
|
||||
j.setMsg("文件导入失败!");
|
||||
logger.error(ExceptionUtil.getExceptionMessage(e));
|
||||
}finally{
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
//上传文件方法
|
||||
@RequestMapping(params="ajaxUpload")
|
||||
@ResponseBody
|
||||
public String ajaxUpload(HttpServletRequest request) throws IllegalStateException, IOException {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
String fileName = "";
|
||||
String uploadPath = "upload/";
|
||||
String path =request.getSession().getServletContext().getRealPath("/")+uploadPath;
|
||||
String realPath = "";
|
||||
String oldName = "";
|
||||
for (Iterator<String> it = multipartRequest.getFileNames(); it.hasNext();) {
|
||||
String key = it.next();
|
||||
MultipartFile mulfile = multipartRequest.getFile(key);
|
||||
fileName = mulfile.getOriginalFilename();
|
||||
oldName = fileName.substring(0,fileName.lastIndexOf("."));
|
||||
fileName = rewriteFileName(fileName);
|
||||
File file = new File(path + fileName);
|
||||
mulfile.transferTo(file);
|
||||
}
|
||||
realPath = "{\"path\":\""+uploadPath+fileName+"\",\"oldName\":\"" + oldName + "\",\"newName\":\"" + fileName + "\"}";
|
||||
return realPath;
|
||||
}
|
||||
|
||||
//文件名称处理
|
||||
private String rewriteFileName(String fileName) {
|
||||
int pointIndex = fileName.lastIndexOf(".");
|
||||
StringBuffer fileNameBuffer = new StringBuffer();
|
||||
fileNameBuffer.append((new Date()).getTime()+"_"+fileName.substring(0,pointIndex));
|
||||
fileNameBuffer.append(fileName.substring(pointIndex));
|
||||
return fileNameBuffer.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,293 @@
|
||||
package org.jeecgframework.web.onlinedoc.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Title: Entity
|
||||
* @Description: 在线文档
|
||||
* @author onlineGenerator
|
||||
* @date 2016-03-19 15:49:59
|
||||
* @version V1.0
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "t_s_online_doc", schema = "")
|
||||
@SuppressWarnings("serial")
|
||||
public class OnlineDocEntity implements java.io.Serializable {
|
||||
/**主键*/
|
||||
private java.lang.String id;
|
||||
/**创建人名称*/
|
||||
private java.lang.String createName;
|
||||
/**创建人登录名称*/
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
private java.util.Date createDate;
|
||||
/**更新人名称*/
|
||||
private java.lang.String updateName;
|
||||
/**更新人登录名称*/
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
private java.util.Date updateDate;
|
||||
/**所属部门*/
|
||||
private java.lang.String sysOrgCode;
|
||||
/**所属公司*/
|
||||
private java.lang.String sysCompanyCode;
|
||||
/**流程状态*/
|
||||
private java.lang.String bpmStatus;
|
||||
/**文件原名*/
|
||||
private java.lang.String oldName;
|
||||
/**文件名*/
|
||||
private java.lang.String newName;
|
||||
/**描述*/
|
||||
@Excel(name="描述")
|
||||
private java.lang.String description;
|
||||
/**分类节点*/
|
||||
@Excel(name="分类节点")
|
||||
private java.lang.String treeNode;
|
||||
/**下载地址*/
|
||||
private java.lang.String path;
|
||||
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 主键
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(generator = "paymentableGenerator")
|
||||
@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
|
||||
@Column(name ="ID",nullable=false,length=36)
|
||||
public java.lang.String getId(){
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 主键
|
||||
*/
|
||||
public void setId(java.lang.String id){
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 创建人名称
|
||||
*/
|
||||
@Column(name ="CREATE_NAME",nullable=true,length=50)
|
||||
public java.lang.String getCreateName(){
|
||||
return this.createName;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 创建人名称
|
||||
*/
|
||||
public void setCreateName(java.lang.String createName){
|
||||
this.createName = createName;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 创建人登录名称
|
||||
*/
|
||||
@Column(name ="CREATE_BY",nullable=true,length=50)
|
||||
public java.lang.String getCreateBy(){
|
||||
return this.createBy;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 创建人登录名称
|
||||
*/
|
||||
public void setCreateBy(java.lang.String createBy){
|
||||
this.createBy = createBy;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.util.Date
|
||||
*@return: java.util.Date 创建日期
|
||||
*/
|
||||
@Column(name ="CREATE_DATE",nullable=true,length=20)
|
||||
public java.util.Date getCreateDate(){
|
||||
return this.createDate;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.util.Date
|
||||
*@param: java.util.Date 创建日期
|
||||
*/
|
||||
public void setCreateDate(java.util.Date createDate){
|
||||
this.createDate = createDate;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 更新人名称
|
||||
*/
|
||||
@Column(name ="UPDATE_NAME",nullable=true,length=50)
|
||||
public java.lang.String getUpdateName(){
|
||||
return this.updateName;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 更新人名称
|
||||
*/
|
||||
public void setUpdateName(java.lang.String updateName){
|
||||
this.updateName = updateName;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 更新人登录名称
|
||||
*/
|
||||
@Column(name ="UPDATE_BY",nullable=true,length=50)
|
||||
public java.lang.String getUpdateBy(){
|
||||
return this.updateBy;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 更新人登录名称
|
||||
*/
|
||||
public void setUpdateBy(java.lang.String updateBy){
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.util.Date
|
||||
*@return: java.util.Date 更新日期
|
||||
*/
|
||||
@Column(name ="UPDATE_DATE",nullable=true,length=20)
|
||||
public java.util.Date getUpdateDate(){
|
||||
return this.updateDate;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.util.Date
|
||||
*@param: java.util.Date 更新日期
|
||||
*/
|
||||
public void setUpdateDate(java.util.Date updateDate){
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 所属部门
|
||||
*/
|
||||
@Column(name ="SYS_ORG_CODE",nullable=true,length=50)
|
||||
public java.lang.String getSysOrgCode(){
|
||||
return this.sysOrgCode;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 所属部门
|
||||
*/
|
||||
public void setSysOrgCode(java.lang.String sysOrgCode){
|
||||
this.sysOrgCode = sysOrgCode;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 所属公司
|
||||
*/
|
||||
@Column(name ="SYS_COMPANY_CODE",nullable=true,length=50)
|
||||
public java.lang.String getSysCompanyCode(){
|
||||
return this.sysCompanyCode;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 所属公司
|
||||
*/
|
||||
public void setSysCompanyCode(java.lang.String sysCompanyCode){
|
||||
this.sysCompanyCode = sysCompanyCode;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 流程状态
|
||||
*/
|
||||
@Column(name ="BPM_STATUS",nullable=true,length=32)
|
||||
public java.lang.String getBpmStatus(){
|
||||
return this.bpmStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 流程状态
|
||||
*/
|
||||
public void setBpmStatus(java.lang.String bpmStatus){
|
||||
this.bpmStatus = bpmStatus;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 文件原名
|
||||
*/
|
||||
@Column(name ="OLD_NAME",nullable=true,length=50)
|
||||
public java.lang.String getOldName(){
|
||||
return this.oldName;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 文件原名
|
||||
*/
|
||||
public void setOldName(java.lang.String oldName){
|
||||
this.oldName = oldName;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 文件名
|
||||
*/
|
||||
@Column(name ="NEW_NAME",nullable=true,length=50)
|
||||
public java.lang.String getNewName(){
|
||||
return this.newName;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 文件名
|
||||
*/
|
||||
public void setNewName(java.lang.String newName){
|
||||
this.newName = newName;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 描述
|
||||
*/
|
||||
@Column(name ="DESCRIPTION",nullable=true,length=200)
|
||||
public java.lang.String getDescription(){
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 描述
|
||||
*/
|
||||
public void setDescription(java.lang.String description){
|
||||
this.description = description;
|
||||
}
|
||||
/**
|
||||
*方法: 取得java.lang.String
|
||||
*@return: java.lang.String 下载地址
|
||||
*/
|
||||
@Column(name ="PATH",nullable=true,length=200)
|
||||
public java.lang.String getPath(){
|
||||
return this.path;
|
||||
}
|
||||
|
||||
/**
|
||||
*方法: 设置java.lang.String
|
||||
*@param: java.lang.String 下载地址
|
||||
*/
|
||||
public void setPath(java.lang.String path){
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setTreeNode(java.lang.String treeNode) {
|
||||
this.treeNode = treeNode;
|
||||
}
|
||||
|
||||
@Column(name ="TREE_NODE",nullable=true,length=200)
|
||||
public java.lang.String getTreeNode() {
|
||||
return treeNode;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package org.jeecgframework.web.onlinedoc.service;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jeecgframework.core.common.service.CommonService;
|
||||
import org.jeecgframework.web.onlinedoc.entity.OnlineDocEntity;
|
||||
|
||||
public interface OnlineDocServiceI extends CommonService{
|
||||
|
||||
public <T> void delete(T entity);
|
||||
|
||||
public <T> Serializable save(T entity);
|
||||
|
||||
public <T> void saveOrUpdate(T entity);
|
||||
|
||||
/**
|
||||
* 默认按钮-sql增强-新增操作
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean doAddSql(OnlineDocEntity t);
|
||||
/**
|
||||
* 默认按钮-sql增强-更新操作
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean doUpdateSql(OnlineDocEntity t);
|
||||
/**
|
||||
* 默认按钮-sql增强-删除操作
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean doDelSql(OnlineDocEntity t);
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package org.jeecgframework.web.onlinedoc.service.impl;
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
|
||||
import org.jeecgframework.web.onlinedoc.entity.OnlineDocEntity;
|
||||
import org.jeecgframework.web.onlinedoc.service.OnlineDocServiceI;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service("onlineDocService")
|
||||
@Transactional
|
||||
public class OnlineDocServiceImpl extends CommonServiceImpl implements OnlineDocServiceI {
|
||||
|
||||
|
||||
public <T> void delete(T entity) {
|
||||
super.delete(entity);
|
||||
//执行删除操作配置的sql增强
|
||||
this.doDelSql((OnlineDocEntity)entity);
|
||||
}
|
||||
|
||||
public <T> Serializable save(T entity) {
|
||||
Serializable t = super.save(entity);
|
||||
//执行新增操作配置的sql增强
|
||||
this.doAddSql((OnlineDocEntity)entity);
|
||||
return t;
|
||||
}
|
||||
|
||||
public <T> void saveOrUpdate(T entity) {
|
||||
super.saveOrUpdate(entity);
|
||||
//执行更新操作配置的sql增强
|
||||
this.doUpdateSql((OnlineDocEntity)entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认按钮-sql增强-新增操作
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean doAddSql(OnlineDocEntity t){
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 默认按钮-sql增强-更新操作
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean doUpdateSql(OnlineDocEntity t){
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 默认按钮-sql增强-删除操作
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean doDelSql(OnlineDocEntity t){
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换sql中的变量
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
public String replaceVal(String sql,OnlineDocEntity t){
|
||||
sql = sql.replace("#{id}",String.valueOf(t.getId()));
|
||||
sql = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
|
||||
sql = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
|
||||
sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
|
||||
sql = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
|
||||
sql = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
|
||||
sql = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
|
||||
sql = sql.replace("#{sys_org_code}",String.valueOf(t.getSysOrgCode()));
|
||||
sql = sql.replace("#{sys_company_code}",String.valueOf(t.getSysCompanyCode()));
|
||||
sql = sql.replace("#{bpm_status}",String.valueOf(t.getBpmStatus()));
|
||||
sql = sql.replace("#{old_name}",String.valueOf(t.getOldName()));
|
||||
sql = sql.replace("#{new_name}",String.valueOf(t.getNewName()));
|
||||
sql = sql.replace("#{description}",String.valueOf(t.getDescription()));
|
||||
sql = sql.replace("#{treeNode}",String.valueOf(t.getTreeNode()));
|
||||
sql = sql.replace("#{path}",String.valueOf(t.getPath()));
|
||||
sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue