mirror of
https://gitee.com/jamen/slife.git
synced 2026-11-23 17:03:38 +00:00
model page
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
.idea
|
||||
*.iml
|
||||
@@ -1,19 +1,27 @@
|
||||
package com.slife.controller;
|
||||
|
||||
import com.slife.base.entity.ReturnDTO;
|
||||
import com.slife.base.vo.DataTable;
|
||||
import com.slife.enums.HttpCodeEnum;
|
||||
import com.slife.exception.SlifeException;
|
||||
import com.slife.service.ModelService;
|
||||
import com.slife.util.ReturnDTOUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: felixu.
|
||||
* @createTime: 2017/11/26.
|
||||
*/
|
||||
@RestController
|
||||
@Controller
|
||||
@RequestMapping("/model")
|
||||
@Api(description = "流程模型前端控制器")
|
||||
public class ModelController {
|
||||
@@ -23,6 +31,7 @@ public class ModelController {
|
||||
|
||||
@ApiOperation(value = "添加流程模型", notes = "添加流程模型")
|
||||
@PostMapping("")
|
||||
@ResponseBody
|
||||
public String createModel(@RequestParam String name, @RequestParam String key,
|
||||
@RequestParam String desc, @RequestParam String category) {
|
||||
if (null == name || null == key || null == category) {
|
||||
@@ -31,4 +40,33 @@ public class ModelController {
|
||||
Model model = modelService.create(name, key, desc, category);
|
||||
return model.getId();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "进入模型管理页面", notes = "进入模型管理页面")
|
||||
@GetMapping(value = "")
|
||||
public String list(org.springframework.ui.Model model, HttpServletRequest request) {
|
||||
model.addAttribute("url", request.getContextPath()+"/model/");
|
||||
return "model/list";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取模型列表数据", notes = "获取模型列表数据:使用约定的DataTable")
|
||||
@PostMapping(value = "/list")
|
||||
@ResponseBody
|
||||
public DataTable<Model> list(@RequestBody DataTable dt) {
|
||||
if (null == dt) {
|
||||
return null;
|
||||
}
|
||||
return modelService.getMadelByPage(dt);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量删除日志记录", notes = "批量删除日志记录传入日志ids")
|
||||
@PostMapping(value = "/delete")
|
||||
@ResponseBody
|
||||
public ReturnDTO delete(@RequestParam("ids") List<String> ids) {
|
||||
if (null == ids) {
|
||||
return ReturnDTOUtil.fail();
|
||||
}
|
||||
modelService.delete(ids);
|
||||
return ReturnDTOUtil.success();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class EditorController {
|
||||
|
||||
@ApiOperation(value = "根据modelId获取model", notes = "根据modelId获取model")
|
||||
@GetMapping(value = "/model/{modelId}/json")
|
||||
public ObjectNode getEditorJson(@PathVariable(value ="modelId" ) String modelId) {
|
||||
public Object getEditorJson(@PathVariable(value ="modelId" ) String modelId) {
|
||||
Optional.ofNullable(modelId).orElseThrow(() -> new SlifeException(HttpCodeEnum.INVALID_REQUEST));
|
||||
return editorService.getEditorJson(modelId);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class EditorService {
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectNode getEditorJson(String modelId) {
|
||||
public Object getEditorJson(String modelId) {
|
||||
ObjectNode modelNode = null;
|
||||
Model model = repositoryService.getModel(modelId);
|
||||
if (model != null) {
|
||||
@@ -54,15 +54,16 @@ public class EditorService {
|
||||
modelNode = objectMapper.createObjectNode();
|
||||
modelNode.put(MODEL_NAME, model.getName());
|
||||
}
|
||||
byte[] source = repositoryService.getModelEditorSource(model.getId());
|
||||
modelNode.put(MODEL_ID, model.getId());
|
||||
ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree(
|
||||
new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
|
||||
ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree(new String(source, "utf-8"));
|
||||
modelNode.put("model", editorJsonNode);
|
||||
return JSON.parse(modelNode.toString());
|
||||
} catch (Exception e) {
|
||||
throw new ActivitiException("Error creating model JSON", e);
|
||||
}
|
||||
}
|
||||
return modelNode;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveModel(String modelId, String name, String description,
|
||||
@@ -78,12 +79,13 @@ public class EditorService {
|
||||
repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("utf-8"));
|
||||
InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8"));
|
||||
TranscoderInput input = new TranscoderInput(svgStream);
|
||||
PNGTranscoder transcoder = new PNGTranscoder();
|
||||
|
||||
// Setup output
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
TranscoderOutput output = new TranscoderOutput(outStream);
|
||||
// PNGTranscoder transcoder = new PNGTranscoder();
|
||||
// Do the transformation
|
||||
transcoder.transcode(input, output);
|
||||
// transcoder.transcode(input, output);
|
||||
final byte[] result = outStream.toByteArray();
|
||||
repositoryService.addModelEditorSourceExtra(model.getId(), result);
|
||||
outStream.close();
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.slife.service;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.Condition;
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.slife.base.vo.DataTable;
|
||||
import com.slife.enums.HttpCodeEnum;
|
||||
import com.slife.exception.SlifeException;
|
||||
import org.activiti.editor.constants.ModelDataJsonConstants;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.activiti.engine.repository.ModelQuery;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: felixu.
|
||||
@@ -59,4 +65,19 @@ public class ModelService {
|
||||
throw new SlifeException(HttpCodeEnum.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public DataTable<Model> getMadelByPage(DataTable dt) {
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery().latestVersion().orderByLastUpdateTime().desc();
|
||||
String category = (String) dt.getSearchParams().get("category");
|
||||
if (StringUtils.isNotBlank(category)) {
|
||||
modelQuery.modelCategory(category);
|
||||
}
|
||||
dt.setTotal(((Long)modelQuery.count()).intValue());
|
||||
dt.setRows(modelQuery.listPage((dt.getPageNumber() - 1) * dt.getPageSize(), dt.getPageSize()));
|
||||
return dt;
|
||||
}
|
||||
|
||||
public void delete(List<String> ids) {
|
||||
ids.stream().forEach(id -> repositoryService.deleteModel(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>模型管理</title>
|
||||
<link href="${base}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
|
||||
<link href="${base}/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
|
||||
<link href="${base}/css/animate.css" rel="stylesheet">
|
||||
<script>
|
||||
var url = "${url}";
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
||||
<body class="gray-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight">
|
||||
<div class="col-sm-12">
|
||||
<div class="ibox">
|
||||
<div class="ibox-body">
|
||||
|
||||
<div id="exampleToolbar" role="group">
|
||||
|
||||
<label style="margin-left: 10px;">
|
||||
登录名:
|
||||
<input type="text" class="form-filter input-sm _search" name="search_eq_login_name">
|
||||
</label>
|
||||
<label style="margin-left: 10px;">
|
||||
动作:
|
||||
<input type="text" class="form-filter input-sm _search" name="search_eq_msg">
|
||||
</label>
|
||||
<label style="margin-left: 10px;">
|
||||
参数:
|
||||
<input type="text" class="form-filter input-sm _search" name="search_like_params">
|
||||
</label>
|
||||
|
||||
<label style="margin-left: 10px;">
|
||||
<button class="btn btn-success" onclick="re_load()">
|
||||
<i class="fa fa-search" aria-hidden="true"></i>查询
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary" onclick="reset()">
|
||||
<i class="fa fa-circle-thin" aria-hidden="true"></i>重置
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" onclick="batch_remove()">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i>删除
|
||||
</button>
|
||||
</label>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<table id="exampleTable" data-mobile-responsive="true">
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap table -->
|
||||
<script src="${base}/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
|
||||
<script src="${base}/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
|
||||
<script src="${base}/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
|
||||
|
||||
<script src="${base}/js/slife/datatable.js"></script>
|
||||
<script type="text/javascript">
|
||||
function getcolumns() {
|
||||
var c = [
|
||||
{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'category',
|
||||
title: '流程分类'
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: '模型ID'
|
||||
},
|
||||
{
|
||||
field: 'key',
|
||||
title: '模型标识'
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '模型名称'
|
||||
},
|
||||
{
|
||||
field: 'version',
|
||||
title: '版本号'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间'
|
||||
},
|
||||
{
|
||||
field: 'lastUpdateTime',
|
||||
title: '最后更新时间'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
field: 'id',
|
||||
align: 'center',
|
||||
formatter: function (value, row, index) {
|
||||
return dt_delete_button(row);
|
||||
}
|
||||
}];
|
||||
return c;
|
||||
}
|
||||
load_data( getcolumns(), {"createDate": "desc"});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,7 +15,7 @@ public class WebSiteMeshFilter extends ConfigurableSiteMeshFilter {
|
||||
/** 需要装饰的访问路径 */
|
||||
|
||||
private String contentPath="/sys/user,/sys/menu,/sys/dict,/sys/role,/sys/office,/sys/,/index,/monitor/*," +
|
||||
"/blog/content**,/404";
|
||||
"/blog/content**,/404,/model";
|
||||
|
||||
/** 装饰器页面路径 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user