Commit 5f246c2e authored by linruibiao's avatar linruibiao

接口编写

parent 0992c441
package com.syc.slm.slmbi.controller;
import com.syc.slm.common.core.util.R;
import com.syc.slm.slmbi.service.BusinessConfigService;
import com.syc.slm.slmbi.vo.BusinessConfigVo;
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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* slm-bi
* 系统业务配置
* @author : lin
* @date : 2021-04-20 09:23
**/
@RequestMapping("/{appId}/business")
@RestController
@Api(value = "系统业务配置接口", tags = "系统业务配置接口")
public class BusinessConfigController extends BaseRestController{
@Autowired
private BusinessConfigService businessConfigService;
@GetMapping
@ApiOperation("数据表查询")
@ApiImplicitParam(name = "appId", value = "租户id",dataTypeClass = String.class)
public R<List<BusinessConfigVo>> selectConfigList(@PathVariable String appId) {
return call(()->(businessConfigService.selectConfigList()));
}
@GetMapping("{/{id}")
@ApiOperation("数据表查询")
@ApiImplicitParams({
@ApiImplicitParam(name = "appId", value = "租户id",dataTypeClass = String.class),
@ApiImplicitParam(name = "id", value = "主键id",dataTypeClass = String.class)
})
public R<BusinessConfigVo> selectOneConfig(@PathVariable String appId,@PathVariable String id) {
return call(()->(businessConfigService.selectOneConfig(id)));
}
}
package com.syc.slm.slmbi.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.syc.slm.slmbi.entity.BusinessConfig;
import org.springframework.stereotype.Component;
/**
* slm-bi
* 系统业务表配置
* @author : lin
* @date : 2021-04-20 09:32
**/
@Component
public interface BusinessConfigMapper extends BaseMapper<BusinessConfig> {
}
package com.syc.slm.slmbi.dto;
/**
* slm-bi
*
* @author : lin
* @date : 2021-04-19 19:36
**/
public class BusinessConditionDTO {
private String key;
private String value;
private String queryType;
}
package com.syc.slm.slmbi.dto;
import lombok.Data;
import java.util.List;
/**
* slm-bi
*
* @author : lin
* @date : 2021-04-19 19:31
**/
@Data
public class BusinessDTO {
private String table;
private String filed;
List<BusinessConditionDTO> where;
//avg sum count
private String statisticsType;
}
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;
import lombok.EqualsAndHashCode;
/**
* slm-bi
* 系统业务表配置
* @author : lin
* @date : 2021-04-20 09:32
**/
@ApiModel(description = "系统业务表配置entity")
@Data
@EqualsAndHashCode(callSuper=true)
@TableName("business_config")
public class BusinessConfig extends BaseEntity<BusinessConfig>{
@ApiModelProperty(value = "表英文名称")
private String nameEn;
@ApiModelProperty(value = "表中文名称")
private String nameCn;
@ApiModelProperty(value = "表字段属性")
private String field;
@ApiModelProperty(value = "表字段时间属性")
private String fieldTime;
}
package com.syc.slm.slmbi.enums;
/**
* @author lin
* @date 2021/4/20
*/
public enum Condition {
/**
* 等于
*/
EQ("eq"),
/**
* 不等于
*/
NE("ne"),
/**
* 大于
*/
GT("gt"),
/**
* 小于
*/
LT("lt"),
/**
* 大于等于
*/
GTE("gte"),
/**
* 小于等于
*/
LTE("lte"),
/**
* 包含(模糊查询)
*/
IN("in"),
/**
* 不包含(模糊查询)
*/
NIN("nin"),
/**
* 空
*/
IS_NULL("is_null"),
/**
* 不为空
*/
NO_NULL("no_null"),
/**
* in
*/
INS("ins"),
/**
* nin
*/
NO_INS("no_ins");
private String value;
Condition(String v) {
this.value = v;
}}
......@@ -31,7 +31,12 @@ public enum StatisticsType {
/**
* 中位数
*/
MIDDLE("middle");
MIDDLE("middle"),
/**
* 原值
*/
ORIGINAL("original");
private String value;
StatisticsType(String v){
value=v;
......
package com.syc.slm.slmbi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.syc.slm.slmbi.entity.BusinessConfig;
import com.syc.slm.slmbi.vo.BusinessConfigVo;
import java.util.List;
/**
* slm-bi
* 系统业务表配置
* @author : lin
* @date : 2021-04-20 09:30
**/
public interface BusinessConfigService extends IService<BusinessConfig> {
/**
* 获取系统业务表
* @return
*/
List<BusinessConfigVo> selectConfigList();
/**
* 根据id获取表配置
* @param id
* @return
*/
BusinessConfigVo selectOneConfig(String id);
}
......@@ -100,7 +100,18 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
*/
void checkName(@NonNull String appId,String panelId,@NonNull String panelName);
/**
* 根据仪表板集合,查询仪表板
* @param panelIds
* @return
*/
List<InstrumentPanel> getByIds(Set<String> panelIds);
/**
* 根据最终的仪表板id获取仪表板树集合
* @param finalPanelIds
* @param name
* @return
*/
List<PanelTreeNodeVo> selectPanelByIds(Set<String> finalPanelIds,String name);
}
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.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.BusinessConfigMapper;
import com.syc.slm.slmbi.entity.BaseEntity;
import com.syc.slm.slmbi.entity.BusinessConfig;
import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.BusinessConfigService;
import com.syc.slm.slmbi.vo.BusinessConfigVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
* slm-bi
* 系统业务表配置
* @author : lin
* @date : 2021-04-20 09:30
**/
@Service
public class BusinessConfigServiceImpl extends ServiceImpl<BusinessConfigMapper, BusinessConfig> implements BusinessConfigService {
@Override
@Transactional(readOnly = true)
public List<BusinessConfigVo> selectConfigList() {
LambdaQueryWrapper<BusinessConfig> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
List<BusinessConfig> configs = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(configs)){
configs.forEach(x->{
try {
if(StringUtils.isNotBlank(x.getField())) {
x.setField(URLDecoder.decode(x.getField(), StandardCharsets.UTF_8.name()));
}
if(StringUtils.isNotBlank(x.getFieldTime())) {
x.setFieldTime(URLDecoder.decode(x.getFieldTime(), StandardCharsets.UTF_8.name()));
}
}catch (Exception e){
e.printStackTrace();
throw new SysException("请联系管理员,数据转化出错了");
}
});
}
return CollectionUtils.isNotEmpty(configs)?SlmConstants.gson.fromJson(SlmConstants.gson.toJson(configs),new TypeToken<List<BusinessConfigVo>>(){}.getType()):
Lists.newArrayList();
}
@Override
@Transactional(readOnly = true)
public BusinessConfigVo selectOneConfig(String id) {
BusinessConfig co = baseMapper.selectById(id);
try {
if(StringUtils.isNotBlank(co.getField())) {
co.setField(URLDecoder.decode(co.getField(), StandardCharsets.UTF_8.name()));
}
if(StringUtils.isNotBlank(co.getFieldTime())) {
co.setFieldTime(URLDecoder.decode(co.getFieldTime(), StandardCharsets.UTF_8.name()));
}
}catch (Exception e){
e.printStackTrace();
throw new SysException("请联系管理员,数据转化出错了");
}
return ObjectUtils.isNotEmpty(co)?SlmConstants.gson.fromJson(SlmConstants.gson.toJson(co), BusinessConfigVo.class):null;
}
}
......@@ -271,7 +271,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
}
@Override
@Transactional
@Transactional(readOnly = true)
public Map<String, String> getAssemblyConfig(@NotNull String panelId) {
Map<String,String> maps = Maps.newHashMap();
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
......
package com.syc.slm.slmbi.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* slm-bi
* 系统业务表配置
* @author : lin
* @date : 2021-04-20 09:30
**/
@Data
@ApiModel(value = "系统业务表配置VO",description = "系统业务表配置VO")
@EqualsAndHashCode(callSuper=false)
public class BusinessConfigVo {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "表英文名称")
private String nameEn;
@ApiModelProperty(value = "表中文名称")
private String nameCn;
@ApiModelProperty(value = "表字段属性")
private String field;
@ApiModelProperty(value = "表字段时间属性")
private String fieldTime;
}
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