提交 ed8c4ff1 authored 作者: zhoushaopan's avatar zhoushaopan

新增页面和实体的绑定

上级 fd198f07
...@@ -18,8 +18,8 @@ public class ResultUtil<T> { ...@@ -18,8 +18,8 @@ public class ResultUtil<T> {
* *
* @param data 获取的数据 * @param data 获取的数据
*/ */
public static <T> ResponseEntity<ResultObj<T>> success(T data) { public static <T> ResponseEntity<ResultObj<T>> success(T data,String message) {
return ResponseEntity.ok(new ResultObj<>(data)); return ResponseEntity.ok(new ResultObj<>(data,message));
} }
/** /**
......
...@@ -84,9 +84,9 @@ public class FlowsInfoController { ...@@ -84,9 +84,9 @@ public class FlowsInfoController {
// return xml; // return xml;
// } // }
@GetMapping("/deploy/{id}") @GetMapping("/deploy")
@ApiOperation(value = "部署流程",notes = "0 部署成功") @ApiOperation(value = "部署流程",notes = "0 部署成功")
public Integer deploy(@PathVariable("id") Long id) throws FileNotFoundException { public Integer deploy(Long id) throws FileNotFoundException {
//根据id 查询出flowsInfo //根据id 查询出flowsInfo
FlowsInfo flowsInfo = flowInfoService.findById(id); FlowsInfo flowsInfo = flowInfoService.findById(id);
if (flowsInfo.getState() == 0){ if (flowsInfo.getState() == 0){
......
package com.tykj.workflowcore.workflow_editer.controller; package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.base.result.ResultObj;
import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage; import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity; //import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import com.tykj.workflowcore.workflow_editer.service.FormPageService; import com.tykj.workflowcore.workflow_editer.service.FormPageService;
import com.tykj.workflowcore.workflow_editer.service.PageEntityService; //import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo; import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo;
import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo; import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -28,26 +32,25 @@ public class FormPageController { ...@@ -28,26 +32,25 @@ public class FormPageController {
@Autowired @Autowired
private FormPageService formPageService; private FormPageService formPageService;
@Autowired // @Autowired
private PageEntityService pageEntityService; // private PageEntityService pageEntityService;
@ApiOperation("保存页面") @ApiOperation("保存页面")
@PostMapping("/savePage") @PostMapping("/savePage")
public Long savePage(@RequestBody InFormPageVo inFormPageVo){ public ResponseEntity savePage(@RequestBody InFormPageVo inFormPageVo){
List<String> entityIds = inFormPageVo.getEntityIds(); if (inFormPageVo.getId() == null){
for (String entityId : entityIds) { Long pageId = formPageService.savePage(inFormPageVo);
PageEntity pageEntity = new PageEntity(); return ResultUtil.success(pageId,"页面保存成功");
pageEntity.setEntityId(entityId); }else {
pageEntity.setPageId(formPageService.savePage(inFormPageVo)); //修改
pageEntityService.savePageEntity(pageEntity); FormPage formPage = inFormPageVo.toEntity();
formPageService.update(formPage);
return ResultUtil.success(inFormPageVo.getId(),"页面保存成功");
} }
return formPageService.savePage(inFormPageVo);
} }
@ApiOperation("回显页面") @ApiOperation("回显页面")
@GetMapping("/EchoPage/{id}") @GetMapping("/EchoPage")
public FormPage EchoPage(@PathVariable("id") Long id){ public FormPage EchoPage(Long id){
return formPageService.getPage(id); return formPageService.getPage(id);
} }
...@@ -58,9 +61,14 @@ public class FormPageController { ...@@ -58,9 +61,14 @@ public class FormPageController {
} }
@ApiOperation("删除页面") @ApiOperation("删除页面")
@DeleteMapping("deletePage/{id}") @DeleteMapping("deletePage")
public void deletePage(@PathVariable("id") Long id){ public void deletePage(Long id){
formPageService.deletePage(id); formPageService.deletePage(id);
} }
@PostMapping("/findByPages")
public List<TableInfo> findByPages(@RequestBody List<Long> pageIds){
return formPageService.findByPageIds(pageIds);
}
} }
package com.tykj.workflowcore.workflow_editer.controller; //package com.tykj.workflowcore.workflow_editer.controller;
//
import com.tykj.workflowcore.model_layer.model.TableInfo; //import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity; //import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import com.tykj.workflowcore.workflow_editer.service.PageEntityService; //import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; //import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; //import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
//
import java.util.List; //import java.util.List;
//
/** ///**
* ClassName: PageEntityController // * ClassName: PageEntityController
* Package: com.tykj.controller // * Package: com.tykj.controller
* Description: // * Description:
* Datetime: 2021/3/4 9:50 // * Datetime: 2021/3/4 9:50
* // *
* @Author: zsp // * @Author: zsp
*/ // */
@RestController //@RestController
@RequestMapping("/pageEntity") //@RequestMapping("/pageEntity")
@Api("页面跟实体的管理") //@Api("页面跟实体的管理")
//
public class PageEntityController { //public class PageEntityController {
//
@Autowired // @Autowired
private PageEntityService pageEntityService; // private PageEntityService pageEntityService;
//
@PostMapping("/savePageEntity") // @PostMapping("/savePageEntity")
public void savePageEntity(@RequestBody PageEntity pageEntity){ // public void savePageEntity(@RequestBody PageEntity pageEntity){
pageEntityService.savePageEntity(pageEntity); // pageEntityService.savePageEntity(pageEntity);
} // }
//
@PostMapping("/findByPages") // @PostMapping("/findByPages")
public List<TableInfo> findByPages(List<Integer> pageIds){ // public List<TableInfo> findByPages(List<Integer> pageIds){
//
return pageEntityService.findByPageIds(pageIds); // return pageEntityService.findByPageIds(pageIds);
} // }
} //}
...@@ -91,9 +91,9 @@ public class WorkFlowController { ...@@ -91,9 +91,9 @@ public class WorkFlowController {
workFlowService.suspendOrActivateProcessDefinitionByKey(suspendVo); workFlowService.suspendOrActivateProcessDefinitionByKey(suspendVo);
} }
@DeleteMapping("/deleteFlow/{deployId}") @DeleteMapping("/deleteFlow")
@ApiOperation("是否删除") @ApiOperation("是否删除")
public void deleteFlow(@PathVariable("deployId") String deployId){ public void deleteFlow(String deployId){
//根据流程id查询出flowsInfo //根据流程id查询出flowsInfo
FlowsInfo flowsInfo = flowInfoService.findByDeployId(deployId); FlowsInfo flowsInfo = flowInfoService.findByDeployId(deployId);
//删除flowsInfo //删除flowsInfo
......
...@@ -59,6 +59,9 @@ public class FormPage { ...@@ -59,6 +59,9 @@ public class FormPage {
@ApiModelProperty("json描述文件") @ApiModelProperty("json描述文件")
private String descFile; private String descFile;
@ApiModelProperty("实体类id")
private String entityId;
public OutFormPageVo toEntityVo(){ public OutFormPageVo toEntityVo(){
OutFormPageVo outFormPageVo = new OutFormPageVo(); OutFormPageVo outFormPageVo = new OutFormPageVo();
BeanUtils.copyProperties(this,outFormPageVo); BeanUtils.copyProperties(this,outFormPageVo);
......
package com.tykj.workflowcore.workflow_editer.entity; //package com.tykj.workflowcore.workflow_editer.entity;
//
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; //import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; //import lombok.AllArgsConstructor;
import lombok.Data; //import lombok.Data;
import lombok.NoArgsConstructor; //import lombok.NoArgsConstructor;
//
import javax.persistence.Entity; //import javax.persistence.Entity;
import javax.persistence.GeneratedValue; //import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; //import javax.persistence.GenerationType;
import javax.persistence.Id; //import javax.persistence.Id;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.List; //import java.util.List;
//
/** ///**
* ClassName: PageEntity // * ClassName: PageEntity
* Package: com.tykj.entity // * Package: com.tykj.entity
* Description: // * Description:
* Datetime: 2021/3/3 10:51 // * Datetime: 2021/3/3 10:51
* // *
* @Author: zsp // * @Author: zsp
*/ // */
@Data //@Data
@AllArgsConstructor //@AllArgsConstructor
@NoArgsConstructor //@NoArgsConstructor
@Entity //@Entity
@Api("页面实体关系") //@Api("页面实体关系")
public class PageEntity { //public class PageEntity {
//
@Id // @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) // @GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty("主键id") // @ApiModelProperty("主键id")
private Long id; // private Long id;
//
@ApiModelProperty("页面Id") // @ApiModelProperty("页面Id")
private Long pageId; // private Long pageId;
//
@ApiModelProperty("实体类Id") // @ApiModelProperty("实体类Id")
private String entityId; // private String entityId;
} //}
package com.tykj.workflowcore.workflow_editer.entity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ClassName: Result
* Package: com.tykj.entity
* Description: 返回类型
* Datetime: 2021/2/23 10:18
*
* @Author: zsp
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Api("统一返回结果集")
public class Result {
@ApiModelProperty("返回状态")
private Integer status;
@ApiModelProperty("返回信息")
private String message;
}
package com.tykj.workflowcore.workflow_editer.service; package com.tykj.workflowcore.workflow_editer.service;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage; import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo; import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo;
import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo; import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo;
...@@ -25,6 +26,12 @@ public interface FormPageService { ...@@ -25,6 +26,12 @@ public interface FormPageService {
*/ */
Long savePage(@RequestBody InFormPageVo inFormPageVo); Long savePage(@RequestBody InFormPageVo inFormPageVo);
/**
* 保存页面
* @param formPage 页面实体
* @return 主键id
*/
void update(FormPage formPage);
/** /**
* 根据页面id来进行回显 * 根据页面id来进行回显
* @param id 页面id * @param id 页面id
...@@ -44,4 +51,10 @@ public interface FormPageService { ...@@ -44,4 +51,10 @@ public interface FormPageService {
*/ */
List<OutFormPageVo> getAllPages(); List<OutFormPageVo> getAllPages();
/**
* 根据页面id查询tableInfo
* @param pageIds 页面id
* @return
*/
List<TableInfo> findByPageIds(List<Long> pageIds);
} }
package com.tykj.workflowcore.workflow_editer.service; //package com.tykj.workflowcore.workflow_editer.service;
//
import com.tykj.workflowcore.model_layer.model.TableInfo; //import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity; //import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
//
import java.util.List; //import java.util.List;
//
/** ///**
* ClassName: PageEntityService // * ClassName: PageEntityService
* Package: com.tykj.service // * Package: com.tykj.service
* Description: // * Description:
* Datetime: 2021/3/4 9:52 // * Datetime: 2021/3/4 9:52
* // *
* @Author: zsp // * @Author: zsp
*/ // */
public interface PageEntityService { //public interface PageEntityService {
//
/** // /**
* 保存 // * 保存
* @param pageEntity 页面实体之间关系 // * @param pageEntity 页面实体之间关系
*/ // */
void savePageEntity(PageEntity pageEntity); // void savePageEntity(PageEntity pageEntity);
//
/** // /**
* 根据页面id查询tableInfo // * 根据页面id查询tableInfo
* @param pageIds 页面id // * @param pageIds 页面id
* @return // * @return
*/ // */
List<TableInfo> findByPageIds(List<Integer> pageIds); // List<TableInfo> findByPageIds(List<Integer> pageIds);
//
//
} //}
package com.tykj.workflowcore.workflow_editer.service.impl; package com.tykj.workflowcore.workflow_editer.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage; import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.mapper.FormPageMapper; import com.tykj.workflowcore.workflow_editer.mapper.FormPageMapper;
import com.tykj.workflowcore.workflow_editer.service.FormPageService; import com.tykj.workflowcore.workflow_editer.service.FormPageService;
...@@ -28,7 +32,8 @@ public class FormPageServiceImpl implements FormPageService { ...@@ -28,7 +32,8 @@ public class FormPageServiceImpl implements FormPageService {
@Autowired @Autowired
private FormPageMapper formPageMapper; private FormPageMapper formPageMapper;
@Autowired
private TableInfoDao tableInfoDao;
@Override @Override
public Long savePage(@RequestBody InFormPageVo inFormPageVo) { public Long savePage(@RequestBody InFormPageVo inFormPageVo) {
inFormPageVo.setCreateTime(new Date()); inFormPageVo.setCreateTime(new Date());
...@@ -38,6 +43,11 @@ public class FormPageServiceImpl implements FormPageService { ...@@ -38,6 +43,11 @@ public class FormPageServiceImpl implements FormPageService {
return id; return id;
} }
@Override
public void update(FormPage formPage) {
formPageMapper.save(formPage);
}
@Override @Override
public FormPage getPage(@PathVariable("id") Long id) { public FormPage getPage(@PathVariable("id") Long id) {
...@@ -66,5 +76,19 @@ public class FormPageServiceImpl implements FormPageService { ...@@ -66,5 +76,19 @@ public class FormPageServiceImpl implements FormPageService {
return formPageVos; return formPageVos;
} }
@Override
public List<TableInfo> findByPageIds(List<Long> pageIds) {
ArrayList<TableInfo> list = new ArrayList<>();
for (Long pageId : pageIds) {
//通过pageId 查询出表id
String entityId = formPageMapper.findById(pageId).get().getEntityId();
//根据entityId查询出表
PredicateBuilder<TableInfo> builder = Specifications.and();
builder.eq("id",entityId);
List<TableInfo> tableInfoList = tableInfoDao.findAll(builder.build());
list.addAll(tableInfoList);
}
return list;
}
} }
package com.tykj.workflowcore.workflow_editer.service.impl; //package com.tykj.workflowcore.workflow_editer.service.impl;
//
import com.tykj.workflowcore.model_layer.dao.TableInfoDao; //import com.github.wenhao.jpa.PredicateBuilder;
import com.tykj.workflowcore.model_layer.model.TableInfo; //import com.github.wenhao.jpa.Specifications;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity; //import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.workflow_editer.mapper.PageEntityMapper; //import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.service.PageEntityService; //import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import org.springframework.beans.factory.annotation.Autowired; //import com.tykj.workflowcore.workflow_editer.mapper.PageEntityMapper;
import org.springframework.stereotype.Service; //import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
//import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList; //import org.springframework.stereotype.Service;
import java.util.List; //import java.util.ArrayList;
//import java.util.List;
/** //
* ClassName: PageEntityServiceImpl ///**
* Package: com.tykj.service.impl // * ClassName: PageEntityServiceImpl
* Description: // * Package: com.tykj.service.impl
* Datetime: 2021/3/4 9:55 // * Description:
* // * Datetime: 2021/3/4 9:55
* @Author: zsp // *
*/ // * @Author: zsp
@Service // */
public class PageEntityServiceImpl implements PageEntityService { //@Service
//public class PageEntityServiceImpl implements PageEntityService {
@Autowired //
private PageEntityMapper pageEntityMapper; // @Autowired
@Autowired // private PageEntityMapper pageEntityMapper;
private TableInfoDao tableInfoDao; // @Autowired
@Override // private TableInfoDao tableInfoDao;
public void savePageEntity(PageEntity pageEntity) { // @Override
pageEntityMapper.save(pageEntity); // public void savePageEntity(PageEntity pageEntity) {
} // pageEntityMapper.save(pageEntity);
// }
@Override //
public List<TableInfo> findByPageIds(List<Integer> pageIds) { // @Override
ArrayList<TableInfo> list = new ArrayList<>(); // public List<TableInfo> findByPageIds(List<Integer> pageIds) {
for (Integer pageId : pageIds) { // ArrayList<TableInfo> list = new ArrayList<>();
Long entityId = pageEntityMapper.findByPageId(pageId).getEntityId(); // for (Integer pageId : pageIds) {
//根据entityId查询出实体类 // String entityId = pageEntityMapper.findByPageId(pageId).getEntityId();
TableInfo tableInfo = tableInfoDao.findById(entityId).get(); // //根据entityId查询出表
list.add(tableInfo); // PredicateBuilder<TableInfo> builder = Specifications.and();
} // builder.eq("id",entityId);
return list; // List<TableInfo> tableInfoList = tableInfoDao.findAll(builder.build());
} // list.addAll(tableInfoList);
} // }
// return list;
// }
//}
...@@ -24,6 +24,8 @@ import java.util.List; ...@@ -24,6 +24,8 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
public class InFormPageVo { public class InFormPageVo {
@ApiModelProperty("页面id")
private Long id;
@ApiModelProperty("页面名称") @ApiModelProperty("页面名称")
private String pageName; private String pageName;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论