Commit 833afc96 authored by linruibiao's avatar linruibiao

接口编写

parent 60695fc5
......@@ -25,17 +25,14 @@ package com.syc.slm.common.core.constant;
*/
public interface CommonConstants {
/**
* 成功标记
*/
Integer SUCCESS = 0;
/**
* 失败标记
*/
Integer FAIL = 1;
/**
* 成功标记
*/
Integer SUCCESS = 0;
/**
* 失败标记
*/
Integer FAIL = 1;
}
package com.syc.slm.common.core.constant;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* slm-bi
* 业务常量
*
* @author : lin
* @date : 2021-04-06 11:14
**/
public final class SlmConstants {
public static Gson gson = new GsonBuilder().create();
/**
* 启用
*/
public static final Integer DATA_VALID = 1;
/**
* 禁用
*/
public static final Integer DATA_INVALID = 0;
/**
* 删除
*/
public static final Integer DATA_DELETED = -1;
}
package com.syc.slm.common.core.util;
import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.function.Action0;
import java.util.function.Supplier;
/**
* slm-bi
* 统一方法调用返回
*
* @author : lin
* @date : 2021-04-06 09:39
**/
public final class NetResponseUtils {
public static <T> R<T> call(Supplier<T> x) {
try {
return R.ok(x.get());
} catch (Exception ex) {
ex.printStackTrace();
if ((ex.getCause() instanceof SysException)) {
SysException e = (SysException)ex.getCause();
return R.failed(e.getMsg());
}
return R.failed(ex.getMessage());
}
}
public static R<Object> call(Action0 x) {
try {
x.call();
return R.ok();
} catch (Exception ex) {
ex.printStackTrace();
return R.failed(ex.getMessage());
}
}
}
package com.syc.slm.slmbi.controller;
import com.syc.slm.common.core.util.NetResponseUtils;
import com.syc.slm.common.core.util.R;
import com.syc.slm.slmbi.function.Action0;
import java.util.function.Supplier;
/**
* slm-bi
* 抽取公用得controller父类
*
* @author : lin
* @date : 2021-04-06 09:09
**/
public class BaseRestController {
R<Object> call(Action0 action) {
return NetResponseUtils.call(action);
}
<T> R<T> call(Supplier<T> supplier) {
return NetResponseUtils.call(supplier);
}
}
......@@ -5,6 +5,7 @@ import com.syc.slm.common.core.util.R;
import com.syc.slm.slmbi.dto.SaveInstrumentPanelDTO;
import com.syc.slm.slmbi.dto.QueryInstrumentPanelDTO;
import com.syc.slm.slmbi.service.InstrumentPanelService;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.InstrumentPanelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -25,7 +26,7 @@ import java.util.List;
@RestController
@RequestMapping("/{appId}/panels")
@Api(value = "仪表板配置接口", tags = "仪表板配置接口")
public class InstrumentPanelController {
public class InstrumentPanelController extends BaseRestController {
@Autowired
private InstrumentPanelService instrumentPanelService;
......@@ -38,65 +39,67 @@ public class InstrumentPanelController {
*/
@GetMapping
@ApiOperation("仪表板列表")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)
public R<IPage<InstrumentPanelVo>> selectInstrumentPanelList(@PathVariable String appId,
QueryInstrumentPanelDTO where) {
return R.ok(instrumentPanelService.selectInstrumentPanelList(where));
return call(() -> instrumentPanelService.selectInstrumentPanelList(appId, where));
}
@PostMapping
@ApiOperation("新增仪表板")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)
public R<String> saveInstrumentPanel(@PathVariable String appId, @RequestBody SaveInstrumentPanelDTO panel) {
return R.ok(instrumentPanelService.savePanel(panel));
return call(() -> instrumentPanelService.savePanel(appId, panel));
}
@PutMapping("/publish")
@ApiOperation("批量发布")
@ApiImplicitParams({@ApiImplicitParam(name = "ids", value = "仪表板id集合", required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)})
public R<Boolean> batchPublish(@PathVariable String appId, @RequestBody List<String> ids) {
return R.ok(instrumentPanelService.batchPublish(ids));
@ApiImplicitParams({@ApiImplicitParam(name = "ids",
value = "仪表板id集合",
required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)})
public R<Object> batchPublish(@PathVariable String appId, @RequestBody List<String> ids) {
return call(() -> instrumentPanelService.batchPublish(ids));
}
@PutMapping("/{id}/offline")
@ApiOperation("下线")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)})
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)})
public R<String> offline(@PathVariable String appId, @PathVariable("id") String id) {
return R.ok(instrumentPanelService.offline(id));
return call(() -> instrumentPanelService.offline(id));
}
@DeleteMapping("/{id}")
@ApiOperation("删除仪表板")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)})
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)})
public R<String> delInstrumentPanel(@PathVariable String appId, @PathVariable("id") String id) {
return R.ok(instrumentPanelService.delPanel(id));
return call(() -> instrumentPanelService.delPanel(id));
}
@PostMapping("/save-as")
@ApiOperation("另存为")
@ApiImplicitParam(name = "id", value = "仪表板id", required = true,dataTypeClass = String.class)
@ApiImplicitParam(name = "id", value = "仪表板id", required = true, dataTypeClass = String.class)
public R<String> saveAs(@PathVariable String appId, @RequestBody SaveInstrumentPanelDTO panelDTO) {
// FIXME 另存为需要保存配置、权限信息吗?
return R.ok(instrumentPanelService.saveAsPanel(panelDTO));
return call(() -> instrumentPanelService.saveAsPanel(appId, panelDTO));
}
@PostMapping("/{id}/show-recovery-btn")
@ApiOperation("是否显示恢复按钮")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)})
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)})
public R<Boolean> showRecoveryBtn(@PathVariable String appId, @PathVariable("id") String id) {
return R.ok(instrumentPanelService.showRecoveryBtn(id));
return call(() -> instrumentPanelService.showRecoveryBtn(id));
}
@PutMapping("/{id}/recovery")
@ApiOperation("恢复按钮操作")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)})
public R<String> recoveryInstrumentPanel(@PathVariable String appId, @PathVariable("id") String id) {
return R.ok(instrumentPanelService.recoveryPanel(id));
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "仪表板id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)})
public R<InstrumentPanelConfigVo> recoveryInstrumentPanel(@PathVariable String appId, @PathVariable("id") String id) {
return call(() -> instrumentPanelService.recoveryPanel(id));
}
}
......@@ -4,12 +4,16 @@ import com.syc.slm.common.core.util.R;
import com.syc.slm.slmbi.dto.CreateInstrumentPanelGroupDTO;
import com.syc.slm.slmbi.dto.InstrumentPanelGroupDTO;
import com.syc.slm.slmbi.service.InstrumentPanelGroupService;
import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* slm-bi
* 仪表板分组
......@@ -20,31 +24,41 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/{appId}/groups")
@Api(value = "仪表板分组", tags = "仪表板分组")
public class InstrumentPanelGroupController {
public class InstrumentPanelGroupController extends BaseRestController{
@Autowired
private InstrumentPanelGroupService instrumentPanelGroupService;
@GetMapping
@ApiOperation("仪表板列表查询,仪表板分组增删改页面的分组树")
@ApiImplicitParams({
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "name", value = "分组名称", required = true,dataTypeClass = String.class)
})
public R<List<InstrumentPanelGroupVo>> selectGroupList(@PathVariable String appId, @RequestParam(required = false,value = "name") String name) {
return call(()->instrumentPanelGroupService.selectGroupList(appId,name));
}
@PostMapping
@ApiOperation("保存仪表板分组")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
public R<String> saveGroup(@PathVariable String appId, @RequestBody CreateInstrumentPanelGroupDTO group) {
return R.ok(instrumentPanelGroupService.saveGroup(group));
return call(()->instrumentPanelGroupService.saveGroup(group));
}
@PutMapping
@ApiOperation("更新仪表板分组")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
public R<String> updateGroup(@PathVariable String appId, @RequestBody InstrumentPanelGroupDTO group) {
return R.ok(instrumentPanelGroupService.updateGroup(group));
return call(()->instrumentPanelGroupService.updateGroup(group));
}
@DeleteMapping("/{groupId}")
@ApiOperation("删除仪表板分组")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
public R<String> delGroup(@PathVariable String appId, @PathVariable String groupId) {
return R.ok(instrumentPanelGroupService.delGroup(groupId));
return call(()->instrumentPanelGroupService.delGroup(groupId));
}
}
package com.syc.slm.slmbi.dao;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.syc.slm.slmbi.entity.InstrumentPanelGroup;
import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
/**
* slm-bi
* 仪表板分组
......@@ -12,4 +19,17 @@ import org.springframework.stereotype.Component;
**/
@Component
public interface InstrumentPanelGroupMapper extends BaseMapper<InstrumentPanelGroup> {
/**
* 根据id 批量修改分组状态
* @param groupIds
* @param recordStatus
*/
void batchUpdateGroupByIds(@Param("groupIds") Set<String> groupIds,@Param("recordStatus") Integer recordStatus);
/**
* 根据分组名字匹配分组
* @param where
* @return
*/
List<InstrumentPanelGroupVo> selectGroupList(@Param("ew") LambdaQueryWrapper<InstrumentPanelGroup> where);
}
package com.syc.slm.slmbi.dao;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.vo.InstrumentPanelVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.Set;
/**
* slm-bi
* 仪表板
......@@ -12,4 +20,9 @@ import org.springframework.stereotype.Component;
**/
@Component
public interface InstrumentPanelMapper extends BaseMapper<InstrumentPanel> {
void batchUpdatePanelByIds(@Param("panelIds") Set<String> panelIds, @Param("recordStatus") Integer recordStatus);
IPage<InstrumentPanelVo> selectInstrumentPanelList(@Param("page") IPage<InstrumentPanelVo> page,
@Param("ew") Wrapper<InstrumentPanel> wrapper);
}
package com.syc.slm.slmbi.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.Set;
/**
* 仪表板树聚合表
*
......@@ -12,4 +16,5 @@ import org.springframework.stereotype.Component;
@Component
public interface InstrumentPanelTreeMapper extends BaseMapper<InstrumentPanelTree> {
void batchUpdateTreeByIds(@Param("treeIds") Set<String> treeIds, @Param("recordStatus") Integer recordStatus);
}
......@@ -13,7 +13,7 @@ import lombok.Data;
public class CustomPermissionDTO {
@ApiModelProperty(value = "自定义权限类型", required = true)
private CustomPermissionType type;
private String type;
@ApiModelProperty(value = "代表岗位、部门或个体用户id", required = true)
private String bizId;
......
package com.syc.slm.slmbi.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* slm-bi
* 仪表板组件DTO
* @author : lin
* @date : 2021-04-07 11:35
**/
@ApiModel(value = "仪表板组件DTO")
@Data
@EqualsAndHashCode(callSuper = false)
public class InstrumentPanelAssemblyDTO {
@ApiModelProperty(value = "仪表板组件key", required = true)
private String key;
@ApiModelProperty(value = "仪表板组件名称", required = true)
private String name;
}
package com.syc.slm.slmbi.dto;
import com.syc.slm.slmbi.enums.AccessType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -22,7 +23,7 @@ public class InstrumentPanelPermissionDTO {
private String id;
@ApiModelProperty(value = "访问权限类型", required = true)
private AccessType type;
private String accessType;
@ApiModelProperty(value = "描述")
private String description;
......
......@@ -31,5 +31,5 @@ public class QueryInstrumentPanelDTO extends QueryPageDTO {
@ApiModelProperty(value = "修改时间结束")
private Date updateTimeEnd;
@ApiModelProperty(value = "发布状态")
private Boolean published;
private Integer published;
}
package com.syc.slm.slmbi.dto;
import com.syc.slm.slmbi.enums.StatisticsType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......
......@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* slm-bi
* 保存仪表板DTO
......@@ -18,12 +20,16 @@ import lombok.EqualsAndHashCode;
public class SaveInstrumentPanelDTO {
@ApiModelProperty(value = "仪表板名称", required = true)
private String name;
@ApiModelProperty(value = "仪表板归属分组", required = true)
private String groupId;
@ApiModelProperty(value = "仪表板配置详情,包含了样式,数据配置", required = true)
private String configDetails;
@ApiModelProperty(value = "仪表板配置组件集合", required = true)
private List<InstrumentPanelAssemblyDTO> assemblys;
@ApiModelProperty(value = "访问权限", required = true)
private InstrumentPanelPermissionDTO permission;
}
package com.syc.slm.slmbi.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -15,6 +16,7 @@ import lombok.EqualsAndHashCode;
@ApiModel(description = "仪表板entity")
@Data
@EqualsAndHashCode(callSuper=true)
@TableName("instrument_panel")
public class InstrumentPanel extends BaseEntity<InstrumentPanel>{
@ApiModelProperty(value = "仪表板主键")
private String id ;
......@@ -27,6 +29,14 @@ public class InstrumentPanel extends BaseEntity<InstrumentPanel>{
@ApiModelProperty(value = "发布状态")
private Integer published;
public InstrumentPanel() {
}
public InstrumentPanel(String id, String name, String groupId, String accessPermission, Integer published) {
this.id = id;
this.name = name;
this.groupId = groupId;
this.accessPermission = accessPermission;
this.published = published;
}
}
package com.syc.slm.slmbi.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -15,6 +16,7 @@ import lombok.EqualsAndHashCode;
@ApiModel(description = "仪表板分组entity")
@Data
@EqualsAndHashCode(callSuper=true)
@TableName("instrument_panel_group")
public class InstrumentPanelGroup extends BaseEntity<InstrumentPanelGroup>{
@ApiModelProperty(value = "仪表板分组主键")
private String id;
......
......@@ -20,7 +20,11 @@ import lombok.EqualsAndHashCode;
@ApiModel(value = "仪表板树聚合表")
public class InstrumentPanelTree extends BaseEntity<InstrumentPanelTree> {
private static final long serialVersionUID = 1L;
/**
* 节点全路径id
*/
@ApiModelProperty(value = "节点全路径id")
private String fullId;
/**
* 节点全路径
*/
......@@ -31,4 +35,8 @@ public class InstrumentPanelTree extends BaseEntity<InstrumentPanelTree> {
*/
@ApiModelProperty(value = "节点类型")
private String nodeType;
@ApiModelProperty(value = "组件key")
private String assemblyKey;
}
package com.syc.slm.slmbi.dto;
package com.syc.slm.slmbi.enums;
/**
* 访问权限类型
*
* @author liangbin
* @date 2021/3/31
*/
public enum AccessType {
// 公开
PUBLIC,
PUBLIC("public"),
// 私有
PRIVATE,
PRIVATE("private"),
// 自定义
CUSTOM;
}
CUSTOM("custom");
public String value;
AccessType(String v) {
value = v;
}}
package com.syc.slm.slmbi.dto;
package com.syc.slm.slmbi.enums;
/**
* 自定义权限的类型
......@@ -9,11 +9,15 @@ package com.syc.slm.slmbi.dto;
public enum CustomPermissionType {
//岗位
POSITION,
POSITION("position"),
//部门
DEPARTMENT,
DEPARTMENT("department"),
//用户
USER;
USER("user");
public String value;
CustomPermissionType(String v){
value=v;
}
}
package com.syc.slm.slmbi.enums;
/**
* @author lin
* @date 2021/4/6
*/
public enum NodeType {
/**
* 仪表板
*/
PANEL("panel"),
/**
* 仪表板分组
*/
GROUP("group"),
/**
* 仪表板组件
*/
ASSEMBLY("assembly");
public String value;
NodeType(String v){
value = v;
}
}
package com.syc.slm.slmbi.enums;
/**
* @author lin
* @date 2021/4/7
*/
public enum PublishedStatus {
/**
* 发布
*/
PUBLISHED(1),
/**
* 待发布
*/
WAIT_PUBLISHED(2),
/**
* 下线
*/
OFFLINE(3),
DRAFT(4);
public Integer value;
PublishedStatus(Integer v) {
value = v;
}}
package com.syc.slm.slmbi.dto;
package com.syc.slm.slmbi.enums;
/**
* 统计类型
......@@ -19,4 +19,8 @@ public enum StatisticsType {
// 最小值
MIN;
public static void main(String[] args) {
System.out.println(StatisticsType.MAX.name());
}
}
package com.syc.slm.slmbi.exception;
import com.syc.slm.common.core.constant.CommonConstants;
import com.syc.slm.common.core.constant.SlmConstants;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
/**
* slm-bi
* 业务异常类
*
* @author : lin
* @date : 2021-04-06 09:14
**/
public class SysException extends RuntimeException {
private int code;
private String msg;
private Object data;
private String debugMsg;
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
public Object getData() {
return data;
}
public String getDebugMsg() {
return debugMsg;
}
public SysException(String msg) {
this(msg, null, null);
}
public SysException(String msg, String debugInfo) {
this.msg = msg;
this.debugMsg = debugInfo;
this.code = CommonConstants.FAIL;
}
public SysException(String msg, Exception originalException) {
this(msg, originalException, null);
}
private SysException(String msg, Exception originalException, Object pData) {
super(msg);
code = CommonConstants.FAIL;
this.msg = msg;
data = pData;
if (originalException != null) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(outputStream);
originalException.printStackTrace(writer);
debugMsg = new String(outputStream.toByteArray());
}
}
public SysException(int dwCode, String szMsg) {
this(dwCode, szMsg, null);
}
private SysException(int dwCode, String szMsg, Exception originalException) {
super(szMsg);
code = dwCode;
msg = szMsg;
if (originalException != null) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(outputStream);
originalException.printStackTrace(writer);
debugMsg = new String(outputStream.toByteArray());
}
}
@Override
public String toString() {
if (StringUtils.isNotEmpty(msg)) {
return msg;
}
if (StringUtils.isNotEmpty(debugMsg)) {
return debugMsg;
}
if (data != null) {
return SlmConstants.gson.toJson(data);
}
return code + "";
}
}
......@@ -7,10 +7,9 @@ import java.io.Serializable;
* @date 2021/4/1
*/
@FunctionalInterface
public interface Action0 extends Serializable { // supplier
public interface Action0 extends Serializable {
/**
* 调用
*/
void call();
static Action0[] of(Action0... funcs){
return funcs;
}
}
package com.syc.slm.slmbi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.syc.slm.slmbi.dto.InstrumentPanelConfigDTO;
import com.syc.slm.slmbi.entity.InstrumentPanelConfig;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import javax.validation.constraints.NotNull;
......@@ -12,7 +14,15 @@ import javax.validation.constraints.NotNull;
* @author : lin
* @date : 2021-03-25 15:10
**/
public interface InstrumentPanelConfigService {
public interface InstrumentPanelConfigService extends IService<InstrumentPanelConfig>{
/**
* 根据仪表板id获取对应已发布配置
* @param instrumentPanelId
* @return
*/
InstrumentPanelConfigVo getPublishConfigByPanelId(@NotNull String instrumentPanelId);
/**
* 根据仪表板id获取对应配置
......@@ -32,4 +42,10 @@ public interface InstrumentPanelConfigService {
* @return
*/
String saveConfig(InstrumentPanelConfigDTO config);
/**
* 根据仪表板id删除仪表板配置
* @param panelId
*/
void delConfig(@NotNull String panelId);
}
......@@ -22,7 +22,7 @@ public interface InstrumentPanelGroupService extends IService<InstrumentPanelGro
* 查询仪表板分组
* @return
*/
List<InstrumentPanelGroupVo> selectGroupList();
List<InstrumentPanelGroupVo> selectGroupList(String appId,String name);
/**
* 删除仪表板分组
......@@ -36,14 +36,14 @@ public interface InstrumentPanelGroupService extends IService<InstrumentPanelGro
* @param group
* @return
*/
String updateGroup(InstrumentPanelGroupDTO group);
String updateGroup(@NonNull InstrumentPanelGroupDTO group);
/**
* 保存仪表板分组
* @param group
* @return
*/
String saveGroup(InstrumentPanelGroupDTO group);
String saveGroup(@NonNull InstrumentPanelGroupDTO group);
/**
* 加载仪表板树
......
package com.syc.slm.slmbi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.syc.slm.slmbi.dto.InstrumentPanelPermissionDTO;
import com.syc.slm.slmbi.entity.InstrumentPanelPermission;
import com.syc.slm.slmbi.vo.CustomPermissionVo;
import com.syc.slm.slmbi.vo.InstrumentPanelPermissionVo;
import lombok.NonNull;
......@@ -12,7 +15,7 @@ import java.util.List;
* @author : lin
* @date : 2021-03-25 18:54
**/
public interface InstrumentPanelPermissionService {
public interface InstrumentPanelPermissionService extends IService<InstrumentPanelPermission> {
/**
* 保存仪表板权限
*
......@@ -45,4 +48,17 @@ public interface InstrumentPanelPermissionService {
* @return
*/
List<InstrumentPanelPermissionVo> selectPermissionByPanelId(@NonNull String instrumentPanelId);
/**
* 根据仪表板id删除仪表板权限
* @param panelId
*/
void delPermissionByPanelId(@NonNull String panelId);
/**
* 根据仪表板id获取已经发布的配置
* @param panelId
* @return
*/
List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId);
}
......@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.syc.slm.slmbi.dto.SaveInstrumentPanelDTO;
import com.syc.slm.slmbi.dto.QueryInstrumentPanelDTO;
import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.InstrumentPanelVo;
import java.util.List;
import java.util.Set;
/**
* slm-bi
......@@ -23,7 +25,7 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @param where
* @return
*/
IPage<InstrumentPanelVo> selectInstrumentPanelList(QueryInstrumentPanelDTO where);
IPage<InstrumentPanelVo> selectInstrumentPanelList(String appId,QueryInstrumentPanelDTO where);
/**
* 保存仪表板
......@@ -31,7 +33,7 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @param panel
* @return
*/
String savePanel(SaveInstrumentPanelDTO panel);
String savePanel(String appId,SaveInstrumentPanelDTO panel);
/**
* 批量推送
......@@ -39,7 +41,7 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @param ids
* @return
*/
Boolean batchPublish(List<String> ids);
void batchPublish(List<String> ids);
/**
* 删除仪表板
......@@ -55,7 +57,7 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @param instrumentPanelDTO
* @return
*/
String saveAsPanel(SaveInstrumentPanelDTO instrumentPanelDTO);
String saveAsPanel(String appId,SaveInstrumentPanelDTO instrumentPanelDTO);
/**
* 是否显示恢复按钮
......@@ -71,7 +73,7 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @param id
* @return
*/
String recoveryPanel(String id);
InstrumentPanelConfigVo recoveryPanel(String id);
/**
* 下线
......@@ -80,4 +82,11 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @return
*/
String offline(String id);
/**
* 批量更新仪表板状态
* @param panelIds
* @param recordStatus
*/
void batchUpdatePanelByIds(Set<String> panelIds, Integer recordStatus);
}
......@@ -3,6 +3,8 @@ package com.syc.slm.slmbi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import java.util.Set;
/**
* 仪表板树聚合表
*
......@@ -11,4 +13,20 @@ import com.syc.slm.slmbi.entity.InstrumentPanelTree;
*/
public interface InstrumentPanelTreeService extends IService<InstrumentPanelTree> {
void batchUpdateTreeByIds(Set<String> treeIds, Integer recordStatus);
/**
* 初始化仪表板树
* @param nodeId
* @param nodeType
* @param bizId
* @param bizName
*/
void initTree(String nodeId,String nodeType,String bizId,String bizName);
/**
* 根据仪表板id删除仪表板树
* @param panelId
*/
void delTreeByPanelId(String panelId);
}
package com.syc.slm.slmbi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.InstrumentPanelConfigMapper;
import com.syc.slm.slmbi.dto.InstrumentPanelConfigDTO;
import com.syc.slm.slmbi.entity.BaseEntity;
import com.syc.slm.slmbi.entity.InstrumentPanelConfig;
import com.syc.slm.slmbi.entity.InstrumentPanelDraft;
import com.syc.slm.slmbi.enums.PublishedStatus;
import com.syc.slm.slmbi.service.InstrumentPanelConfigService;
import com.syc.slm.slmbi.service.InstrumentPanelPermissionService;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* slm-bi
......@@ -13,8 +29,23 @@ import org.springframework.stereotype.Service;
* @date : 2021-03-25 19:11
**/
@Service
public class InstrumentPanelConfigServiceImpl implements InstrumentPanelConfigService {
public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPanelConfigMapper, InstrumentPanelConfig> implements InstrumentPanelConfigService {
@Autowired
private InstrumentPanelPermissionService permissionService;
@Override
@Transactional(readOnly = true)
public InstrumentPanelConfigVo getPublishConfigByPanelId(@NotNull String instrumentPanelId) {
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, instrumentPanelId);
where.eq(InstrumentPanelConfig::getPublished, PublishedStatus.PUBLISHED);
InstrumentPanelConfig config = baseMapper.selectOne(where);
InstrumentPanelConfigVo vo = new InstrumentPanelConfigVo();
BeanUtils.copyProperties(config,vo);
vo.setPermissions(permissionService.getPublishPermissionByPanelId(instrumentPanelId));
return vo;
}
@Override
public InstrumentPanelConfigVo getConfigByPanelId(String instrumentPanelId) {
......@@ -30,4 +61,18 @@ public class InstrumentPanelConfigServiceImpl implements InstrumentPanelConfigSe
public String saveConfig(InstrumentPanelConfigDTO config) {
return null;
}
@Override
public void delConfig(@NotNull String panelId) {
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
where.eq(InstrumentPanelConfig::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId,panelId);
List<InstrumentPanelConfig> configs = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(configs)){
configs.forEach(x->{
x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x);
});
}
}
}
package com.syc.slm.slmbi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.reflect.TypeToken;
import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.InstrumentPanelPermissionMapper;
import com.syc.slm.slmbi.dto.InstrumentPanelPermissionDTO;
import com.syc.slm.slmbi.entity.InstrumentPanelPermission;
import com.syc.slm.slmbi.enums.PublishedStatus;
import com.syc.slm.slmbi.service.InstrumentPanelPermissionService;
import com.syc.slm.slmbi.vo.CustomPermissionVo;
import com.syc.slm.slmbi.vo.InstrumentPanelPermissionVo;
import lombok.NonNull;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
......@@ -16,9 +26,11 @@ import java.util.List;
* @date : 2021-03-25 19:04
**/
@Service
public class InstrumentPanelPermissionImpl implements InstrumentPanelPermissionService {
public class InstrumentPanelPermissionImpl
extends ServiceImpl<InstrumentPanelPermissionMapper, InstrumentPanelPermission>
implements InstrumentPanelPermissionService {
@Override
public String savePermission(InstrumentPanelPermissionDTO permissions){
public String savePermission(InstrumentPanelPermissionDTO permissions) {
//判断仪表板的名称是否重复
//删除原本的权限
//插入现有的权限
......@@ -40,4 +52,32 @@ public class InstrumentPanelPermissionImpl implements InstrumentPanelPermissionS
public List<InstrumentPanelPermissionVo> selectPermissionByPanelId(@NonNull String instrumentPanelId) {
return null;
}
@Override
public void delPermissionByPanelId(@NonNull String panelId) {
LambdaQueryWrapper<InstrumentPanelPermission> where = new LambdaQueryWrapper<>();
where.eq(InstrumentPanelPermission::getPanelId, panelId);
where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID);
List<InstrumentPanelPermission> permissions = baseMapper.selectList(where);
if (CollectionUtils.isNotEmpty(permissions)) {
permissions.forEach(x -> {
x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x);
});
}
}
@Override
@Transactional(readOnly = true)
public List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId) {
LambdaQueryWrapper<InstrumentPanelPermission> where = new LambdaQueryWrapper<>();
where.eq(InstrumentPanelPermission::getPanelId, panelId);
where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelPermission::getPublished, PublishedStatus.PUBLISHED);
List<InstrumentPanelPermission> permissions = baseMapper.selectList(where);
return CollectionUtils.isNotEmpty(permissions) ?
SlmConstants.gson.fromJson(SlmConstants.gson.toJson(permissions),
new TypeToken<List<CustomPermissionVo>>() {
}.getType()) : null;
}
}
package com.syc.slm.slmbi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.InstrumentPanelTreeMapper;
import com.syc.slm.slmbi.entity.BaseEntity;
import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import com.syc.slm.slmbi.service.InstrumentPanelTreeService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
/**
* 仪表板树聚合表
*
......@@ -16,4 +23,39 @@ import org.springframework.stereotype.Service;
public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelTreeMapper, InstrumentPanelTree>
implements InstrumentPanelTreeService {
@Override
public void batchUpdateTreeByIds(Set<String> treeIds, Integer recordStatus) {
if(CollectionUtils.isNotEmpty(treeIds)){
baseMapper.batchUpdateTreeByIds(treeIds,recordStatus);
}
}
@Override
public void initTree(String nodeId, String nodeType, String bizId, String bizName) {
InstrumentPanelTree panelTree = baseMapper.selectById(nodeId);
InstrumentPanelTree tree = new InstrumentPanelTree();
tree.setId(bizId);
tree.setNodeType(nodeType);
tree.setFullName(panelTree.getFullName() + "." + bizName);
tree.setFullId(panelTree.getFullId() + "." + bizId);
baseMapper.insert(tree);
}
@Override
public void delTreeByPanelId(String panelId) {
InstrumentPanelTree tree = baseMapper.selectById(panelId);
tree.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(tree);
//#todo 仪表板组件树
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.likeRight(InstrumentPanelTree::getFullId,tree.getFullId()+".");
List<InstrumentPanelTree> list = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(list)){
list.forEach(x->{
x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x);
});
}
}
}
package com.syc.slm.slmbi.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* slm-bi
* 自定义权限Vo
* @author : lin
* @date : 2021-04-07 17:52
**/
@ApiModel(value = "自定义权限Vo")
@Data
public class CustomPermissionVo {
@ApiModelProperty(value = "自定义权限类型", required = true)
private String type;
@ApiModelProperty(value = "代表岗位、部门或个体用户id", required = true)
private String bizId;
@ApiModelProperty(value = "代表岗位,部门,个体用户名称")
private String bizName;
}
......@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
import java.util.List;
import java.util.Map;
/**
* slm-bi
* 仪表板样式,数据配置显示类
......@@ -17,7 +18,9 @@ import java.util.Map;
**/
@Data
@ApiModel(value = "仪表板样式,数据配置显示类Vo", description = "仪表板样式,数据配置显示类Vo")
@EqualsAndHashCode(callSuper=true)
@EqualsAndHashCode(callSuper = true)
public class InstrumentPanelConfigVo extends InstrumentPanelConfig {
@ApiModelProperty(value = "自定义权限类型", required = true)
List<CustomPermissionVo> permissions;
}
......@@ -20,11 +20,9 @@ import java.util.List;
public class InstrumentPanelGroupVo {
@ApiModelProperty(value = "分组主键")
private Integer id;
private String id;
@ApiModelProperty(value = "父级id")
private String parentId;
@ApiModelProperty(value = "分组名称")
private String groupName;
@ApiModelProperty(value = "分组归属下的仪表板")
List<InstrumentPanelVo> instrumentPanels;
private String name;
}
......@@ -17,5 +17,6 @@ import lombok.EqualsAndHashCode;
@ApiModel(value = "仪表板显示类vo",description = "仪表板显示类vo")
@EqualsAndHashCode(callSuper=true)
public class InstrumentPanelVo extends InstrumentPanel {
@ApiModelProperty("分组名称")
private String groupName;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment