Commit a7d3c72e by 胡懿

对接平台数据

parent ac9a3783
......@@ -79,7 +79,10 @@
<version>2.4.2-jdk8-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
</dependencies>
......
......@@ -12,4 +12,22 @@ public class ErrorInfo {
public static ErrorCode IMPORTANT_FILE_NOT_EXISTS = new ErrorCode(7, "重要文件不存在");
public static ErrorCode CONNET_RULE_NOT_EXISTS = new ErrorCode(8, "设备连接规则不存在");
public static ErrorCode CONNET_RULE_INFO_NOT_EXISTS = new ErrorCode(9, "设备规则配置细则不存在");
public static ErrorCode SYS_ABBRE_NOT_EXISTS = new ErrorCode(10, "系统简称不存在");
public static ErrorCode WEB_REQ_CONF_NOT_EXISTS = new ErrorCode(11, "web请求配置不存在");
public static ErrorCode WEB_REQ_CONF_EXITS_CHILDREN = new ErrorCode(12, "存在存在子web请求配置,无法删除");
public static ErrorCode WEB_REQ_CONF_PARENT_NOT_EXITS = new ErrorCode(13,"父级web请求配置不存在");
public static ErrorCode WEB_REQ_CONF_PARENT_ERROR = new ErrorCode(14, "不能设置自己为父web请求配置");
public static ErrorCode WEB_REQ_CONF_API_NAME_DUPLICATE = new ErrorCode(15, "已经存在该api名称的web请求配置");
public static ErrorCode WEB_REQ_CONF_PARENT_IS_CHILD = new ErrorCode(16, "不能设置自己的子WebReqConf为父WebReqConf");
public static ErrorCode DEVICE_REQ_CONF_NOT_EXISTS = new ErrorCode(17, "物联网设备请求配置不存在");
public static ErrorCode DEVICE_REQ_CONF_EXITS_CHILDREN = new ErrorCode(18, "存在存在子物联网设备请求配置,无法删除");
public static ErrorCode DEVICE_REQ_CONF_PARENT_NOT_EXITS = new ErrorCode(19,"父级物联网设备请求配置不存在");
public static ErrorCode DEVICE_REQ_CONF_PARENT_ERROR = new ErrorCode(20, "不能设置自己为父物联网设备请求配置");
public static ErrorCode DEVICE_REQ_CONF_DEVICE_NAME_DUPLICATE = new ErrorCode(21, "已经存在该设备名称的物联网设备请求配置");
public static ErrorCode DEVICE_REQ_CONF_PARENT_IS_CHILD = new ErrorCode(22, "不能设置自己的子DeviceReqConf为父DeviceReqConf");
public static ErrorCode PT_DEPT_INFO_NOT_EXISTS = new ErrorCode(23, "平台部门不存在");
}
package cn.gintone.config;
import cn.gintone.dto.DeviceLogInfo;
import cn.gintone.dto.WebLogInfo;
import cn.gintone.iotdbUtils.MyIotDbUtils;
import cn.gintone.service.DeviceConnetRuleInfoService;
import cn.gintone.service.VisitInfoService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
@Component
public class KafkaConsumer {
@Autowired
private IotDbConfig iotDbConfig;
@Autowired
private VisitInfoService visitInfoService;
@Autowired
private DeviceConnetRuleInfoService deviceConnetRuleInfoService;
@KafkaListener(topics = "weblog.save", groupId = "weblog_consumer_group")
public void consume(String message){
WebLogInfo webLogInfo = JSON.parseObject(JSON.parse(message).toString(), WebLogInfo.class);
if (webLogInfo.getReqType().contains("req")) {
MyIotDbUtils.inserOne(iotDbConfig, webLogInfo);
visitInfoService.checkWebLogInfo(webLogInfo);
} else {
DeviceLogInfo deviceLogInfo = new DeviceLogInfo();
deviceLogInfo.setUserId(webLogInfo.getUserId());
deviceLogInfo.setUsername(webLogInfo.getUsername());
deviceLogInfo.setDeviceId(webLogInfo.getDeviceTypeId());
deviceLogInfo.setDeviceName(webLogInfo.getDeviceTypeName());
deviceLogInfo.setAccessed(webLogInfo.getAccessed());
deviceLogInfo.setType(webLogInfo.getType());
deviceLogInfo.setClientIp(webLogInfo.getClientIp());
deviceLogInfo.setRemark(webLogInfo.getRemark());
MyIotDbUtils.inserOneDeviceLogInfo(iotDbConfig, deviceLogInfo);
deviceConnetRuleInfoService.checkDeviceLogInfo(deviceLogInfo);
}
/*if (webLogInfo.getReqType().contains("dev")) {
DeviceLogInfo deviceLogInfo = JSON.parseObject(JSON.parse(jsonStr).toString(), DeviceLogInfo.class);
MyIotDbUtils.inserOneDeviceLogInfo(iotDbConfig, deviceLogInfo);
deviceConnetRuleInfoService.checkDeviceLogInfo(deviceLogInfo);
}*/
}
@KafkaListener(topics = "devicelog.save", groupId = "weblog_consumer_group")
public void consume2(String message){
DeviceLogInfo deviceLogInfo = JSON.parseObject(JSON.parse(message).toString(), DeviceLogInfo.class);
MyIotDbUtils.inserOneDeviceLogInfo(iotDbConfig, deviceLogInfo);
deviceConnetRuleInfoService.checkDeviceLogInfo(deviceLogInfo);
}
}
package cn.gintone.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
@Service
public class KafkaProducer {
private final KafkaTemplate<String, String> kafkaTemplate;
private static final String TOPIC = "weblog.save"; // 与消费者中配置的topic一致
private static final String GROUP_ID = "weblog_consumer_group"; // 与消费者中配置的group一致,但不是必须的,除非你需要用它来做额外的配置或验证。通常在@KafkaListener中指定。
@Autowired // 自动注入KafkaTemplate实例。默认的泛型参数是Key和Value的类型。这里都是String类型。根据需要可以更改。
public KafkaProducer(KafkaTemplate<String, String> kafkaTemplate) {
this.kafkaTemplate = kafkaTemplate;
}
public void sendMessage(String message) {
kafkaTemplate.send(TOPIC, message); // 发送消息到指定的topic。这里用的是默认分区器,可以根据需要传递key来指定分区。例如:kafkaTemplate.send(TOPIC, "key", message);。 默认分区器会根据key的哈希值来决定分区。如果不需要key,则可以省略它。 例如:kafkaTemplate.send(TOPIC, null, message); 或者直接使用上面的方法。 需要注意的是,如果使用了key,那么最好在整个系统中保持key的一致性,以便于消息的顺序处理和分区策略的正确执行。如果不确定key的使用场景,可以先省略它,之后再根据需要添加。例如: kafkaTemplate.send(TOPIC, message); 这样发送的消息会被均匀地分配到各个分区上,而没有特定的顺序保证。这对于大多数场景来说是足够的,特别是当不需要保证消息顺序时。如果要保证消息的顺序,可以考虑使用同一个key发送消息到同一个分区。例如: kafkaTemplate.send(TOPIC, "someKey", message); 这样发送的消息都会被分配到同一个分区上,保证了消息的顺序。但是要注意,这可能会影响消息的并行处理能力
}
}
\ No newline at end of file
package cn.gintone.config;
import cn.gintone.dto.DeviceLogInfo;
import cn.gintone.dto.WebLogInfo;
import cn.gintone.entity.DeviceConnetRuleInfoDO;
import cn.gintone.iotdbUtils.MyIotDbUtils;
import cn.gintone.service.DeviceConnetRuleInfoService;
import cn.gintone.service.VisitInfoService;
import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* 消费者类
*/
@Component
public class MyConsumer {
@Autowired
private IotDbConfig iotDbConfig;
@Autowired
private VisitInfoService visitInfoService;
@Autowired
private DeviceConnetRuleInfoService deviceConnetRuleInfoService;
/**
* 监听队列---当队列中有消息,则监听器工作,处理接受到的消息
*/
@RabbitListener(queues = "my_boot_fanout_queue1")
public void receive1(Message message) {
byte[] body = message.getBody();
System.out.printf("receive1接受到的消息" + new String(body));
}
@RabbitListener(queues = "my_boot_topic_queue")
public void receive2(Message message, Channel channel) throws IOException {
byte[] body = message.getBody();
String receivedRoutingKey = message.getMessageProperties().getReceivedRoutingKey();
if (receivedRoutingKey.contains("weblog")) {
String jsonStr = new String(body);
WebLogInfo webLogInfo = null;
try {
webLogInfo = JSON.parseObject(JSON.parse(jsonStr).toString(), WebLogInfo.class);
MyIotDbUtils.inserOne(iotDbConfig, webLogInfo);
visitInfoService.checkWebLogInfo(webLogInfo);
} catch (Exception e) {
e.printStackTrace();
}finally {
return;
}
} else if (receivedRoutingKey.contains("devicelog")) {
String jsonStr = new String(body);
DeviceLogInfo deviceLogInfo = null;
deviceLogInfo = JSON.parseObject(JSON.parse(jsonStr).toString(), DeviceLogInfo.class);
MyIotDbUtils.inserOneDeviceLogInfo(iotDbConfig, deviceLogInfo);
deviceConnetRuleInfoService.checkDeviceLogInfo(deviceLogInfo);
}
// 手动ack,告知broker要签收的消息的id(deliveryTag)
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
}
}
package cn.gintone.config;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 消费者的配置类
*/
@Configuration
public class MyRabbitConfig {
/*
*//**
* 不使用topic的模式
*//*
private static String EXCHANGE_NAME = "my_boot_fanout_exchange"; // 交换机
private static String QUEUE_NAME = "my_boot_fanout_queue1"; // 队列名称
*//**
* 声明交换机
*//*
@Bean
public FanoutExchange fanoutExchange() {
return new FanoutExchange(EXCHANGE_NAME, true, false); // 设置交换机,设置是持久化的,设置不自动删除
}
*//**
* 声明队列
*//*
@Bean
public Queue queue() {
return new Queue(QUEUE_NAME, true,false, false); // 队列名称,是否持久化。是否自动删除
}
*//**
* 创建绑定关系
*//*
@Bean
public Binding binding(FanoutExchange fanoutExchange, Queue queue) {
return BindingBuilder.bind(queue).to(fanoutExchange); // 把队列绑定到交换机上
}
*/
@Autowired
private IotDbConfig iotDbConfig;
/**
* 声明队列、交换机、绑定关系(routing-key)
*/
private static String QUEUE_NAME = "my_boot_topic_queue";
private static String EXCHANGE_NAME = "my_boot_topic_exchange";
/**
* 申明队列
* @return
*/
@Bean
public Queue queue() {
return new Queue(QUEUE_NAME, true,false, false); // 队列名称,是否持久化。是否自动删除
}
/**
* 申明交换机
* @return
*/
@Bean
public TopicExchange topicExchange() {
return new TopicExchange(EXCHANGE_NAME, true, false);
}
/**
* 申明绑定关系
*/
@Bean
public Binding queueBinding(Queue queue, TopicExchange topicExchange) {
return BindingBuilder.bind(queue).to(topicExchange).with("weblog.*");
}
}
......@@ -10,8 +10,10 @@ import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.Date;
import java.util.List;
......@@ -20,9 +22,9 @@ import java.util.List;
@RequestMapping("/admin-api/gintone/deviceLogInfo")
public class DeviceLogInfoController {
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private IotDbConfig iotDbConfig;
@Resource
private KafkaTemplate<String,String> kafkaTemplate;
@PermitAll
@PostMapping("/saveDeviceLogInfo")
......@@ -32,7 +34,8 @@ public class DeviceLogInfoController {
deviceLogInfo.setAccessed(MyDateUtils.longToString(new Date().getTime()));
}
String deviceLogInfoStr = JSON.toJSONString(deviceLogInfo);
rabbitTemplate.convertAndSend("my_boot_topic_exchange", "devicelog.save", deviceLogInfoStr);
// rabbitTemplate.convertAndSend("my_boot_topic_exchange", "devicelog.save", deviceLogInfoStr);
kafkaTemplate.send("devicelog.save",deviceLogInfoStr);
return CommonResult.success("保存成功");
}
......@@ -46,7 +49,7 @@ public class DeviceLogInfoController {
deviceLogInfo.setAccessed(MyDateUtils.longToString(new Date().getTime()));
}
String deviceLogInfoStr = JSON.toJSONString(deviceLogInfo);
rabbitTemplate.convertAndSend("my_boot_topic_exchange", "devicelog.save", deviceLogInfoStr);
kafkaTemplate.send("devicelog.save",deviceLogInfoStr);
}
return CommonResult.success("保存成功");
......
package cn.gintone.controller;
import cn.gintone.controller.vo.DeviceReqConfListReqVO;
import cn.gintone.controller.vo.DeviceReqConfRespVO;
import cn.gintone.controller.vo.DeviceReqConfSaveReqVO;
import cn.gintone.entity.DeviceReqConfDO;
import cn.gintone.service.DeviceReqConfService;
import cn.iocoder.yudao.module.system.controller.admin.myUtils.MyHttpUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 物联网设备请求配置")
@RestController
@RequestMapping("/admin-api/sec/device-req-conf")
@Validated
public class DeviceReqConfController {
@Resource
private DeviceReqConfService deviceReqConfService;
@PostMapping("/create")
@Operation(summary = "创建物联网设备请求配置")
@PreAuthorize("@ss.hasPermission('sec:device-req-conf:create')")
public CommonResult<Long> createDeviceReqConf(@Valid @RequestBody DeviceReqConfSaveReqVO createReqVO) {
return success(deviceReqConfService.createDeviceReqConf(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新物联网设备请求配置")
@PreAuthorize("@ss.hasPermission('sec:device-req-conf:update')")
public CommonResult<Boolean> updateDeviceReqConf(@Valid @RequestBody DeviceReqConfSaveReqVO updateReqVO) {
deviceReqConfService.updateDeviceReqConf(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除物联网设备请求配置")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('sec:device-req-conf:delete')")
public CommonResult<Boolean> deleteDeviceReqConf(@RequestParam("id") Long id) {
deviceReqConfService.deleteDeviceReqConf(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得物联网设备请求配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('sec:device-req-conf:query')")
public CommonResult<DeviceReqConfRespVO> getDeviceReqConf(@RequestParam("id") Long id) {
DeviceReqConfDO deviceReqConf = deviceReqConfService.getDeviceReqConf(id);
return success(BeanUtils.toBean(deviceReqConf, DeviceReqConfRespVO.class));
}
@GetMapping("/list")
@Operation(summary = "获得物联网设备请求配置列表")
@PreAuthorize("@ss.hasPermission('sec:device-req-conf:query')")
public CommonResult<List<DeviceReqConfRespVO>> getDeviceReqConfList(@Valid DeviceReqConfListReqVO listReqVO) {
List<DeviceReqConfDO> list = deviceReqConfService.getDeviceReqConfList(listReqVO);
return success(BeanUtils.toBean(list, DeviceReqConfRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出物联网设备请求配置 Excel")
@PreAuthorize("@ss.hasPermission('sec:device-req-conf:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportDeviceReqConfExcel(@Valid DeviceReqConfListReqVO listReqVO,
HttpServletResponse response) throws IOException {
List<DeviceReqConfDO> list = deviceReqConfService.getDeviceReqConfList(listReqVO);
// 导出 Excel
ExcelUtils.write(response, "物联网设备请求配置.xls", "数据", DeviceReqConfRespVO.class,
BeanUtils.toBean(list, DeviceReqConfRespVO.class));
}
}
\ No newline at end of file
package cn.gintone.controller;
import cn.gintone.controller.vo.PtDeptInfoPageReqVO;
import cn.gintone.controller.vo.PtDeptInfoRespVO;
import cn.gintone.controller.vo.PtDeptInfoSaveReqVO;
import cn.gintone.entity.PtDeptInfoDO;
import cn.gintone.service.PtDeptInfoService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 平台部门")
@RestController
@RequestMapping("/ptinfo/pt-dept-info")
@Validated
public class PtDeptInfoController {
@Resource
private PtDeptInfoService ptDeptInfoService;
@PostMapping("/create")
@Operation(summary = "创建平台部门")
@PreAuthorize("@ss.hasPermission('ptinfo:pt-dept-info:create')")
public CommonResult<Long> createPtDeptInfo(@Valid @RequestBody PtDeptInfoSaveReqVO createReqVO) {
return success(ptDeptInfoService.createPtDeptInfo(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新平台部门")
@PreAuthorize("@ss.hasPermission('ptinfo:pt-dept-info:update')")
public CommonResult<Boolean> updatePtDeptInfo(@Valid @RequestBody PtDeptInfoSaveReqVO updateReqVO) {
ptDeptInfoService.updatePtDeptInfo(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除平台部门")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('ptinfo:pt-dept-info:delete')")
public CommonResult<Boolean> deletePtDeptInfo(@RequestParam("id") Long id) {
ptDeptInfoService.deletePtDeptInfo(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得平台部门")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('ptinfo:pt-dept-info:query')")
public CommonResult<PtDeptInfoRespVO> getPtDeptInfo(@RequestParam("id") Long id) {
PtDeptInfoDO ptDeptInfo = ptDeptInfoService.getPtDeptInfo(id);
return success(BeanUtils.toBean(ptDeptInfo, PtDeptInfoRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得平台部门分页")
@PreAuthorize("@ss.hasPermission('ptinfo:pt-dept-info:query')")
public CommonResult<PageResult<PtDeptInfoRespVO>> getPtDeptInfoPage(@Valid PtDeptInfoPageReqVO pageReqVO) {
PageResult<PtDeptInfoDO> pageResult = ptDeptInfoService.getPtDeptInfoPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PtDeptInfoRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出平台部门 Excel")
@PreAuthorize("@ss.hasPermission('ptinfo:pt-dept-info:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportPtDeptInfoExcel(@Valid PtDeptInfoPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PtDeptInfoDO> list = ptDeptInfoService.getPtDeptInfoPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "平台部门.xls", "数据", PtDeptInfoRespVO.class,
BeanUtils.toBean(list, PtDeptInfoRespVO.class));
}
}
\ No newline at end of file
package cn.gintone.controller;
import cn.gintone.controller.vo.SysAbbrePageReqVO;
import cn.gintone.controller.vo.SysAbbreRespVO;
import cn.gintone.controller.vo.SysAbbreSaveReqVO;
import cn.gintone.entity.SysAbbreDO;
import cn.gintone.service.SysAbbreService;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.List;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 系统简称")
@RestController
@RequestMapping("/admin-api/gintone/sys-abbre")
@Validated
public class SysAbbreController {
@Resource
private SysAbbreService sysAbbreService;
@PostMapping("/create")
@Operation(summary = "创建系统简称")
@PreAuthorize("@ss.hasPermission('gintone:sys-abbre:create')")
public CommonResult<Long> createSysAbbre(@Valid @RequestBody SysAbbreSaveReqVO createReqVO) {
return success(sysAbbreService.createSysAbbre(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新系统简称")
@PreAuthorize("@ss.hasPermission('gintone:sys-abbre:update')")
public CommonResult<Boolean> updateSysAbbre(@Valid @RequestBody SysAbbreSaveReqVO updateReqVO) {
sysAbbreService.updateSysAbbre(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除系统简称")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('gintone:sys-abbre:delete')")
public CommonResult<Boolean> deleteSysAbbre(@RequestParam("id") Long id) {
sysAbbreService.deleteSysAbbre(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得系统简称")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('gintone:sys-abbre:query')")
public CommonResult<SysAbbreRespVO> getSysAbbre(@RequestParam("id") Long id) {
SysAbbreDO sysAbbre = sysAbbreService.getSysAbbre(id);
return success(BeanUtils.toBean(sysAbbre, SysAbbreRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得系统简称分页")
@PreAuthorize("@ss.hasPermission('gintone:sys-abbre:query')")
public CommonResult<PageResult<SysAbbreRespVO>> getSysAbbrePage(@Valid SysAbbrePageReqVO pageReqVO) {
PageResult<SysAbbreDO> pageResult = sysAbbreService.getSysAbbrePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, SysAbbreRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出系统简称 Excel")
@PreAuthorize("@ss.hasPermission('gintone:sys-abbre:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportSysAbbreExcel(@Valid SysAbbrePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<SysAbbreDO> list = sysAbbreService.getSysAbbrePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "系统简称.xls", "数据", SysAbbreRespVO.class,
BeanUtils.toBean(list, SysAbbreRespVO.class));
}
}
\ No newline at end of file
......@@ -3,23 +3,26 @@ package cn.gintone.controller;
import cn.gintone.iotdbUtils.IotDBUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/testCon")
@RequestMapping("/admin-api/sec/device-req-test")
public class TestController {
@Autowired
private RabbitTemplate rabbitTemplate;
@GetMapping("/testRabbit")
public void testRabbit() {
String message = "hellow spring boot topic message";
rabbitTemplate.convertAndSend("my_boot_fanout_exchange", "product.delete", message);
// String message = "hellow spring boot topic message";
// rabbitTemplate.convertAndSend("my_boot_fanout_exchange", "product.delete", message);
}
......
......@@ -10,8 +10,11 @@ import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.Date;
import java.util.List;
......@@ -19,12 +22,16 @@ import java.util.List;
@RestController
@RequestMapping("/admin-api/gintone/webLogInfo")
public class WebLogInfoController {
@Autowired
private RabbitTemplate rabbitTemplate;
@Resource
private KafkaTemplate<String,String> kafkaTemplate;
@Autowired
private IotDbConfig iotDbConfig;
@Resource
private StringRedisTemplate stringRedisTemplate;
@PostMapping("/initIotDBDatabase")
@Operation(summary = "初始化数据库")
public CommonResult<String> initIotDBDatabase() {
......@@ -79,7 +86,8 @@ public class WebLogInfoController {
webLogInfo.setAccessed(MyDateUtils.longToString(new Date().getTime()));
}
String webLogInfoStr = JSON.toJSONString(webLogInfo);
rabbitTemplate.convertAndSend("my_boot_topic_exchange", "weblog.save", webLogInfoStr);
// rabbitTemplate.convertAndSend("my_boot_topic_exchange", "weblog.save", webLogInfoStr);
kafkaTemplate.send("weblog.save",webLogInfoStr);
return CommonResult.success("保存成功");
}
......@@ -116,6 +124,11 @@ public class WebLogInfoController {
@GetMapping("/countWebIllLogInfo")
@Operation(summary = "统计非法日志条数接口")
public CommonResult<Long> countWebIllLogInfo(WebLogInfoVo webLogInfoVo) {
String s = stringRedisTemplate.opsForValue().get("pdToken");
System.out.println(s);
System.out.println(123);
long pageCount = MyIotDbUtils.countWebIllInfo(iotDbConfig, webLogInfoVo);
return CommonResult.success(pageCount);
}
......
package cn.gintone.controller;
import cn.gintone.entity.WebReqConfDO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.gintone.controller.vo.*;
import cn.gintone.service.WebReqConfService;
@Tag(name = "管理后台 - web请求配置")
@RestController
@RequestMapping("/admin-api/sec/web-req-conf")
@Validated
public class WebReqConfController {
@Resource
private WebReqConfService webReqConfService;
@PostMapping("/create")
@Operation(summary = "创建web请求配置")
@PreAuthorize("@ss.hasPermission('sec:web-req-conf:create')")
public CommonResult<Long> createWebReqConf(@Valid @RequestBody WebReqConfSaveReqVO createReqVO) {
return success(webReqConfService.createWebReqConf(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新web请求配置")
@PreAuthorize("@ss.hasPermission('sec:web-req-conf:update')")
public CommonResult<Boolean> updateWebReqConf(@Valid @RequestBody WebReqConfSaveReqVO updateReqVO) {
webReqConfService.updateWebReqConf(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除web请求配置")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('sec:web-req-conf:delete')")
public CommonResult<Boolean> deleteWebReqConf(@RequestParam("id") Long id) {
webReqConfService.deleteWebReqConf(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得web请求配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('sec:web-req-conf:query')")
public CommonResult<WebReqConfRespVO> getWebReqConf(@RequestParam("id") Long id) {
WebReqConfDO webReqConf = webReqConfService.getWebReqConf(id);
return success(BeanUtils.toBean(webReqConf, WebReqConfRespVO.class));
}
@GetMapping("/list")
@Operation(summary = "获得web请求配置列表")
@PreAuthorize("@ss.hasPermission('sec:web-req-conf:query')")
public CommonResult<List<WebReqConfRespVO>> getWebReqConfList(@Valid WebReqConfListReqVO listReqVO) {
List<WebReqConfDO> list = webReqConfService.getWebReqConfList(listReqVO);
return success(BeanUtils.toBean(list, WebReqConfRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出web请求配置 Excel")
@PreAuthorize("@ss.hasPermission('sec:web-req-conf:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportWebReqConfExcel(@Valid WebReqConfListReqVO listReqVO,
HttpServletResponse response) throws IOException {
List<WebReqConfDO> list = webReqConfService.getWebReqConfList(listReqVO);
// 导出 Excel
ExcelUtils.write(response, "web请求配置.xls", "数据", WebReqConfRespVO.class,
BeanUtils.toBean(list, WebReqConfRespVO.class));
}
}
\ No newline at end of file
package cn.gintone.controller.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 物联网设备请求配置列表 Request VO")
@Data
public class DeviceReqConfListReqVO {
@Schema(description = "设备名称", example = "张三")
private String deviceName;
@Schema(description = "设备id", example = "21048")
private String deviceId;
@Schema(description = "设备类型id", example = "24373")
private String deviceTypeId;
@Schema(description = "父级id", example = "31343")
private Long parentId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 物联网设备请求配置 Response VO")
@Data
@ExcelIgnoreUnannotated
public class DeviceReqConfRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9080")
@ExcelProperty("id")
private Long id;
@Schema(description = "设备名称", example = "张三")
@ExcelProperty("设备名称")
private String deviceName;
@Schema(description = "设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21048")
@ExcelProperty("设备id")
private String deviceId;
@Schema(description = "设备类型id", example = "24373")
@ExcelProperty("设备类型id")
private String deviceTypeId;
@Schema(description = "父级id", example = "31343")
@ExcelProperty("父级id")
private Long parentId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 物联网设备请求配置新增/修改 Request VO")
@Data
public class DeviceReqConfSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9080")
private Long id;
@Schema(description = "设备名称", example = "张三")
private String deviceName;
@Schema(description = "设备id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21048")
@NotEmpty(message = "设备id不能为空")
private String deviceId;
@Schema(description = "设备类型id", example = "24373")
private String deviceTypeId;
@Schema(description = "父级id", example = "31343")
private Long parentId;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 平台部门分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PtDeptInfoPageReqVO extends PageParam {
@Schema(description = "部门id", example = "16712")
private Integer orgId;
@Schema(description = "部门编码")
private String orgCode;
@Schema(description = "部门名称", example = "芋艿")
private String orgName;
@Schema(description = "部门类型", example = "2")
private String orgType;
@Schema(description = "父部门id", example = "16885")
private Integer parentOrgId;
@Schema(description = "父部门名称", example = "芋艿")
private String parentOrgName;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 平台部门 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PtDeptInfoRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11535")
@ExcelProperty("id")
private Long id;
@Schema(description = "部门id", example = "16712")
@ExcelProperty("部门id")
private Integer orgId;
@Schema(description = "部门编码")
@ExcelProperty("部门编码")
private String orgCode;
@Schema(description = "部门名称", example = "芋艿")
@ExcelProperty("部门名称")
private String orgName;
@Schema(description = "部门类型", example = "2")
@ExcelProperty("部门类型")
private String orgType;
@Schema(description = "父部门id", example = "16885")
@ExcelProperty("父部门id")
private Integer parentOrgId;
@Schema(description = "父部门名称", example = "芋艿")
@ExcelProperty("父部门名称")
private String parentOrgName;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 平台部门新增/修改 Request VO")
@Data
public class PtDeptInfoSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11535")
private Long id;
@Schema(description = "部门id", example = "16712")
private Integer orgId;
@Schema(description = "部门编码")
private String orgCode;
@Schema(description = "部门名称", example = "芋艿")
private String orgName;
@Schema(description = "部门类型", example = "2")
private String orgType;
@Schema(description = "父部门id", example = "16885")
private Integer parentOrgId;
@Schema(description = "父部门名称", example = "芋艿")
private String parentOrgName;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 系统简称分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SysAbbrePageReqVO extends PageParam {
@Schema(description = "系统简称中文")
private String abbreCn;
@Schema(description = "系统简称英文")
private String abbreEn;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 系统简称 Response VO")
@Data
@ExcelIgnoreUnannotated
public class SysAbbreRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31439")
@ExcelProperty("id")
private Long id;
@Schema(description = "系统简称中文")
@ExcelProperty("系统简称中文")
private String abbreCn;
@Schema(description = "系统简称英文")
@ExcelProperty("系统简称英文")
private String abbreEn;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 系统简称新增/修改 Request VO")
@Data
public class SysAbbreSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31439")
private Long id;
@Schema(description = "系统简称中文")
private String abbreCn;
@Schema(description = "系统简称英文")
private String abbreEn;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - web请求配置列表 Request VO")
@Data
public class WebReqConfListReqVO {
@Schema(description = "系统简称中文")
private String abbreCn;
@Schema(description = "系统简称外键", example = "19731")
private Long abbreId;
@Schema(description = "api地址", example = "https://www.iocoder.cn")
private String apiUrl;
@Schema(description = "api名称", example = "李四")
private String apiName;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "父级id", example = "28717")
private Long parentId;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - web请求配置 Response VO")
@Data
@ExcelIgnoreUnannotated
public class WebReqConfRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30098")
@ExcelProperty("id")
private Long id;
@Schema(description = "系统简称中文")
@ExcelProperty("系统简称中文")
private String abbreCn;
@Schema(description = "系统简称外键", requiredMode = Schema.RequiredMode.REQUIRED, example = "19731")
@ExcelProperty("系统简称外键")
private Long abbreId;
@Schema(description = "api地址", example = "https://www.iocoder.cn")
@ExcelProperty("api地址")
private String apiUrl;
@Schema(description = "api名称", example = "李四")
@ExcelProperty("api名称")
private String apiName;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "父级id", example = "28717")
@ExcelProperty("父级id")
private Long parentId;
}
\ No newline at end of file
package cn.gintone.controller.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - web请求配置新增/修改 Request VO")
@Data
public class WebReqConfSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30098")
private Long id;
@Schema(description = "系统简称中文")
private String abbreCn;
@Schema(description = "系统简称外键", requiredMode = Schema.RequiredMode.REQUIRED, example = "19731")
@NotNull(message = "系统简称外键不能为空")
private Long abbreId;
@Schema(description = "api地址", example = "https://www.iocoder.cn")
private String apiUrl;
@Schema(description = "api名称", example = "李四")
private String apiName;
@Schema(description = "父级id", example = "28717")
private Long parentId;
}
\ No newline at end of file
package cn.gintone.dal;
import java.util.*;
import cn.gintone.controller.vo.DeviceReqConfListReqVO;
import cn.gintone.entity.DeviceReqConfDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
/**
* 物联网设备请求配置 Mapper
*
* @author 安全系统管理
*/
@Mapper
public interface DeviceReqConfMapper extends BaseMapperX<DeviceReqConfDO> {
default List<DeviceReqConfDO> selectList(DeviceReqConfListReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<DeviceReqConfDO>()
.likeIfPresent(DeviceReqConfDO::getDeviceName, reqVO.getDeviceName())
.eqIfPresent(DeviceReqConfDO::getDeviceId, reqVO.getDeviceId())
.eqIfPresent(DeviceReqConfDO::getDeviceTypeId, reqVO.getDeviceTypeId())
.eqIfPresent(DeviceReqConfDO::getParentId, reqVO.getParentId())
.betweenIfPresent(DeviceReqConfDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(DeviceReqConfDO::getId));
}
default DeviceReqConfDO selectByParentIdAndDeviceName(Long parentId, String deviceName) {
return selectOne(DeviceReqConfDO::getParentId, parentId, DeviceReqConfDO::getDeviceName, deviceName);
}
default Long selectCountByParentId(Long parentId) {
return selectCount(DeviceReqConfDO::getParentId, parentId);
}
}
\ No newline at end of file
package cn.gintone.dal;
import java.util.*;
import cn.gintone.controller.vo.PtDeptInfoPageReqVO;
import cn.gintone.entity.PtDeptInfoDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
/**
* 平台部门 Mapper
*
* @author 安全系统管理
*/
@Mapper
public interface PtDeptInfoMapper extends BaseMapperX<PtDeptInfoDO> {
default PageResult<PtDeptInfoDO> selectPage(PtDeptInfoPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PtDeptInfoDO>()
.eqIfPresent(PtDeptInfoDO::getOrgId, reqVO.getOrgId())
.eqIfPresent(PtDeptInfoDO::getOrgCode, reqVO.getOrgCode())
.likeIfPresent(PtDeptInfoDO::getOrgName, reqVO.getOrgName())
.eqIfPresent(PtDeptInfoDO::getOrgType, reqVO.getOrgType())
.eqIfPresent(PtDeptInfoDO::getParentOrgId, reqVO.getParentOrgId())
.likeIfPresent(PtDeptInfoDO::getParentOrgName, reqVO.getParentOrgName())
.betweenIfPresent(PtDeptInfoDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(PtDeptInfoDO::getId));
}
}
\ No newline at end of file
package cn.gintone.dal;
import java.util.*;
import cn.gintone.controller.vo.SysAbbrePageReqVO;
import cn.gintone.entity.SysAbbreDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统简称 Mapper
*
* @author 安全系统管理
*/
@Mapper
public interface SysAbbreMapper extends BaseMapperX<SysAbbreDO> {
default PageResult<SysAbbreDO> selectPage(SysAbbrePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<SysAbbreDO>()
.eqIfPresent(SysAbbreDO::getAbbreCn, reqVO.getAbbreCn())
.eqIfPresent(SysAbbreDO::getAbbreEn, reqVO.getAbbreEn())
.betweenIfPresent(SysAbbreDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(SysAbbreDO::getId));
}
}
\ No newline at end of file
package cn.gintone.dal;
import java.util.*;
import cn.gintone.controller.vo.WebReqConfListReqVO;
import cn.gintone.entity.WebReqConfDO;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
/**
* web请求配置 Mapper
*
* @author 安全系统管理
*/
@Mapper
public interface WebReqConfMapper extends BaseMapperX<WebReqConfDO> {
default List<WebReqConfDO> selectList(WebReqConfListReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<WebReqConfDO>()
.eqIfPresent(WebReqConfDO::getAbbreCn, reqVO.getAbbreCn())
.eqIfPresent(WebReqConfDO::getAbbreId, reqVO.getAbbreId())
.eqIfPresent(WebReqConfDO::getApiUrl, reqVO.getApiUrl())
.likeIfPresent(WebReqConfDO::getApiName, reqVO.getApiName())
.betweenIfPresent(WebReqConfDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(WebReqConfDO::getParentId, reqVO.getParentId())
.orderByDesc(WebReqConfDO::getId));
}
default WebReqConfDO selectByParentIdAndApiName(Long parentId, String apiName) {
return selectOne(WebReqConfDO::getParentId, parentId, WebReqConfDO::getApiName, apiName);
}
default Long selectCountByParentId(Long parentId) {
return selectCount(WebReqConfDO::getParentId, parentId);
}
}
\ No newline at end of file
......@@ -19,6 +19,9 @@ public class WebLogInfo {
private String type; // 日志类型(url, info, warning, error)
private String clientIp; // 访问端ip
private String remark; // 备注
private String reqType; // 访问链接类型 dev:设备数据,req:系统访问
private String deviceTypeName; // 设备类型名称
private String deviceTypeId; // 设备类型ID
public Long getTimesta() {
return timesta;
......@@ -100,6 +103,30 @@ public class WebLogInfo {
this.remark = remark;
}
public String getReqType() {
return reqType;
}
public void setReqType(String reqType) {
this.reqType = reqType;
}
public String getDeviceTypeName() {
return deviceTypeName;
}
public void setDeviceTypeName(String deviceTypeName) {
this.deviceTypeName = deviceTypeName;
}
public String getDeviceTypeId() {
return deviceTypeId;
}
public void setDeviceTypeId(String deviceTypeId) {
this.deviceTypeId = deviceTypeId;
}
@Override
public String toString() {
return "WebLogInfo{" +
......@@ -113,6 +140,9 @@ public class WebLogInfo {
", type='" + type + '\'' +
", clientIp='" + clientIp + '\'' +
", remark='" + remark + '\'' +
", reqType='" + reqType + '\'' +
", deviceTypeName='" + deviceTypeName + '\'' +
", deviceTypeId='" + deviceTypeId + '\'' +
'}';
}
}
package cn.gintone.dtoPt;
public class PtBzInfo {
private int id; // id
private String sbcode; // 编码
private String name; // 名称
private String bztype; // 类型
private String bgq; // 区域
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSbcode() {
return sbcode;
}
public void setSbcode(String sbcode) {
this.sbcode = sbcode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBztype() {
return bztype;
}
public void setBztype(String bztype) {
this.bztype = bztype;
}
public String getBgq() {
return bgq;
}
public void setBgq(String bgq) {
this.bgq = bgq;
}
}
package cn.gintone.dtoPt;
public class PtCarInfo {
private Integer id; // id
private String cphm; // 车牌号码
private String cllxbm; // 车辆类型代码
private String cllx; // 车辆类型
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCphm() {
return cphm;
}
public void setCphm(String cphm) {
this.cphm = cphm;
}
public String getCllxbm() {
return cllxbm;
}
public void setCllxbm(String cllxbm) {
this.cllxbm = cllxbm;
}
public String getCllx() {
return cllx;
}
public void setCllx(String cllx) {
this.cllx = cllx;
}
}
package cn.gintone.dtoPt;
import java.util.List;
public class PtData<T> {
private Boolean ifQuery;
private Integer time;
private Integer total;
private Boolean success;
private String errorMsg;
private List<T> rowData;
public Boolean getIfQuery() {
return ifQuery;
}
public void setIfQuery(Boolean ifQuery) {
this.ifQuery = ifQuery;
}
public Integer getTime() {
return time;
}
public void setTime(Integer time) {
this.time = time;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public List<T> getRowData() {
return rowData;
}
public void setRowData(List<T> rowData) {
this.rowData = rowData;
}
}
package cn.gintone.dtoPt;
public class PtDeptInfo {
private Integer org_id; // 部门id
private String org_code; // 部门编码
private String org_name; // 部门名称
private String org_type; // 部门类型
private Integer PARENT_ORG_ID; // 父部门id
private String PARENT_ORG_NAME; // 父部门名称
public Integer getOrg_id() {
return org_id;
}
public void setOrg_id(Integer org_id) {
this.org_id = org_id;
}
public String getOrg_code() {
return org_code;
}
public void setOrg_code(String org_code) {
this.org_code = org_code;
}
public String getOrg_name() {
return org_name;
}
public void setOrg_name(String org_name) {
this.org_name = org_name;
}
public String getOrg_type() {
return org_type;
}
public void setOrg_type(String org_type) {
this.org_type = org_type;
}
public Integer getPARENT_ORG_ID() {
return PARENT_ORG_ID;
}
public void setPARENT_ORG_ID(Integer PARENT_ORG_ID) {
this.PARENT_ORG_ID = PARENT_ORG_ID;
}
public String getPARENT_ORG_NAME() {
return PARENT_ORG_NAME;
}
public void setPARENT_ORG_NAME(String PARENT_ORG_NAME) {
this.PARENT_ORG_NAME = PARENT_ORG_NAME;
}
}
package cn.gintone.dtoPt;
public class PtGdInfo {
private String sbcode; // 设备编码
private String sbname; // 名称
private String category_id; // 类别编码
private String category; // 类别
private String sstype_id; // 所属点位类型编码
private String sstype; // 所属点位类型
private String address; // 位置
public String getSbcode() {
return sbcode;
}
public void setSbcode(String sbcode) {
this.sbcode = sbcode;
}
public String getSbname() {
return sbname;
}
public void setSbname(String sbname) {
this.sbname = sbname;
}
public String getCategory_id() {
return category_id;
}
public void setCategory_id(String category_id) {
this.category_id = category_id;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getSstype_id() {
return sstype_id;
}
public void setSstype_id(String sstype_id) {
this.sstype_id = sstype_id;
}
public String getSstype() {
return sstype;
}
public void setSstype(String sstype) {
this.sstype = sstype;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
package cn.gintone.dtoPt;
public class PtJgInfo {
private Integer id;
private String sbcode; // 井盖编码
private String name; // 井盖名称
private String category_id; // 设施类型代码
private String category; // 设施类型代码
private String address; // 检测位置
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSbcode() {
return sbcode;
}
public void setSbcode(String sbcode) {
this.sbcode = sbcode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCategory_id() {
return category_id;
}
public void setCategory_id(String category_id) {
this.category_id = category_id;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
package cn.gintone.dtoPt;
public class PtSXTInfo {
private Integer id;
private String sxtbh; // 摄像头编号
private String sxtmc; // 摄像头名称
private String sxtlxbh; // 摄像头类型编号
private String sxtlxmc; // 摄像头类型
private String wzbs; // 位置
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSxtbh() {
return sxtbh;
}
public void setSxtbh(String sxtbh) {
this.sxtbh = sxtbh;
}
public String getSxtmc() {
return sxtmc;
}
public void setSxtmc(String sxtmc) {
this.sxtmc = sxtmc;
}
public String getSxtlxbh() {
return sxtlxbh;
}
public void setSxtlxbh(String sxtlxbh) {
this.sxtlxbh = sxtlxbh;
}
public String getSxtlxmc() {
return sxtlxmc;
}
public void setSxtlxmc(String sxtlxmc) {
this.sxtlxmc = sxtlxmc;
}
public String getWzbs() {
return wzbs;
}
public void setWzbs(String wzbs) {
this.wzbs = wzbs;
}
}
package cn.gintone.dtoPt;
public class PtUserInfo {
private Integer u_id;
private String u_name; // 用户名
private String u_real_name; // ⽤户真实姓名
public Integer getU_id() {
return u_id;
}
public void setU_id(Integer u_id) {
this.u_id = u_id;
}
public String getU_name() {
return u_name;
}
public void setU_name(String u_name) {
this.u_name = u_name;
}
public String getU_real_name() {
return u_real_name;
}
public void setU_real_name(String u_real_name) {
this.u_real_name = u_real_name;
}
}
package cn.gintone.entity;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 物联网设备请求配置 DO
*
* @author 安全系统管理
*/
@TableName("t_device_req_conf")
@KeySequence("t_device_req_conf_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeviceReqConfDO extends BaseDO {
public static final Long PARENT_ID_ROOT = 0L;
/**
* id
*/
@TableId
private Long id;
/**
* 设备名称
*/
private String deviceName;
/**
* 设备id
*/
private String deviceId;
/**
* 设备类型id
*/
private String deviceTypeId;
/**
* 父级id
*/
private Long parentId;
}
\ No newline at end of file
package cn.gintone.entity;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 平台部门 DO
*
* @author 安全系统管理
*/
@TableName("t_pt_dept_info")
@KeySequence("t_pt_dept_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PtDeptInfoDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* 部门id
*/
private Integer orgId;
/**
* 部门编码
*/
private String orgCode;
/**
* 部门名称
*/
private String orgName;
/**
* 部门类型
*/
private String orgType;
/**
* 父部门id
*/
private Integer parentOrgId;
/**
* 父部门名称
*/
private String parentOrgName;
}
\ No newline at end of file
package cn.gintone.entity;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 系统简称 DO
*
* @author 安全系统管理
*/
@TableName("t_sys_abbre")
@KeySequence("t_sys_abbre_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SysAbbreDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* 系统简称中文
*/
private String abbreCn;
/**
* 系统简称英文
*/
private String abbreEn;
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ public class VisitInfoDO extends BaseDO {
/**
* 系统简称
*/
private String sysAbbre;
private Long sysAbbre;
/**
* 系统名称
*/
......@@ -50,7 +50,7 @@ public class VisitInfoDO extends BaseDO {
/**
* 菜单地址Id
*/
private String urlId;
private Long urlId;
/**
* 角色id
*/
......
package cn.gintone.entity;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* web请求配置 DO
*
* @author 安全系统管理
*/
@TableName("t_web_req_conf")
@KeySequence("t_web_req_conf_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WebReqConfDO extends BaseDO {
public static final Long PARENT_ID_ROOT = 0L;
/**
* id
*/
@TableId
private Long id;
/**
* 系统简称中文
*/
private String abbreCn;
/**
* 系统简称外键
*/
private Long abbreId;
/**
* api地址
*/
private String apiUrl;
/**
* api名称
*/
private String apiName;
/**
* 父级id
*/
private Long parentId;
}
\ No newline at end of file
package cn.gintone.myconf;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "basicinfo")
public class BasicUrlConf {
private String userInfoUrl;
public String getUserInfoUrl() {
return userInfoUrl;
}
public void setUserInfoUrl(String userInfoUrl) {
this.userInfoUrl = userInfoUrl;
}
}
......@@ -54,7 +54,7 @@ public class DeviceConnetRuleServiceImpl implements DeviceConnetRuleService {
validateConnetRuleExists(id);
// 删除
connetRuleMapper.deleteById(id);
connetRuleInfoMapper.deleteById(new QueryWrapper<DeviceConnetRuleInfoDO>().lambda().eq(DeviceConnetRuleInfoDO::getDeviceRuleId, id));
connetRuleInfoMapper.delete(new QueryWrapper<DeviceConnetRuleInfoDO>().lambda().eq(DeviceConnetRuleInfoDO::getDeviceRuleId, id));
}
private void validateConnetRuleExists(Long id) {
......
package cn.gintone.service;
import java.util.*;
import javax.validation.*;
import cn.gintone.controller.vo.DeviceReqConfListReqVO;
import cn.gintone.controller.vo.DeviceReqConfSaveReqVO;
import cn.gintone.entity.DeviceReqConfDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 物联网设备请求配置 Service 接口
*
* @author 安全系统管理
*/
public interface DeviceReqConfService {
/**
* 创建物联网设备请求配置
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createDeviceReqConf(@Valid DeviceReqConfSaveReqVO createReqVO);
/**
* 更新物联网设备请求配置
*
* @param updateReqVO 更新信息
*/
void updateDeviceReqConf(@Valid DeviceReqConfSaveReqVO updateReqVO);
/**
* 删除物联网设备请求配置
*
* @param id 编号
*/
void deleteDeviceReqConf(Long id);
/**
* 获得物联网设备请求配置
*
* @param id 编号
* @return 物联网设备请求配置
*/
DeviceReqConfDO getDeviceReqConf(Long id);
/**
* 获得物联网设备请求配置列表
*
* @param listReqVO 查询条件
* @return 物联网设备请求配置列表
*/
List<DeviceReqConfDO> getDeviceReqConfList(DeviceReqConfListReqVO listReqVO);
}
\ No newline at end of file
package cn.gintone.service;
import cn.gintone.ErrorInfo;
import cn.gintone.controller.vo.DeviceReqConfListReqVO;
import cn.gintone.controller.vo.DeviceReqConfSaveReqVO;
import cn.gintone.dal.DeviceReqConfMapper;
import cn.gintone.entity.DeviceReqConfDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 物联网设备请求配置 Service 实现类
*
* @author 安全系统管理
*/
@Service
@Validated
public class DeviceReqConfServiceImpl implements DeviceReqConfService {
@Resource
private DeviceReqConfMapper deviceReqConfMapper;
@Override
public Long createDeviceReqConf(DeviceReqConfSaveReqVO createReqVO) {
// 校验父级id的有效性
validateParentDeviceReqConf(null, createReqVO.getParentId());
// 校验设备名称的唯一性
validateDeviceReqConfDeviceNameUnique(null, createReqVO.getParentId(), createReqVO.getDeviceName());
// 插入
DeviceReqConfDO deviceReqConf = BeanUtils.toBean(createReqVO, DeviceReqConfDO.class);
deviceReqConfMapper.insert(deviceReqConf);
// 返回
return deviceReqConf.getId();
}
@Override
public void updateDeviceReqConf(DeviceReqConfSaveReqVO updateReqVO) {
// 校验存在
validateDeviceReqConfExists(updateReqVO.getId());
// 校验父级id的有效性
validateParentDeviceReqConf(updateReqVO.getId(), updateReqVO.getParentId());
// 校验设备名称的唯一性
validateDeviceReqConfDeviceNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getDeviceName());
// 更新
DeviceReqConfDO updateObj = BeanUtils.toBean(updateReqVO, DeviceReqConfDO.class);
deviceReqConfMapper.updateById(updateObj);
}
@Override
public void deleteDeviceReqConf(Long id) {
// 校验存在
validateDeviceReqConfExists(id);
// 校验是否有子物联网设备请求配置
if (deviceReqConfMapper.selectCountByParentId(id) > 0) {
throw exception(ErrorInfo.DEVICE_REQ_CONF_EXITS_CHILDREN);
}
// 删除
deviceReqConfMapper.deleteById(id);
}
private void validateDeviceReqConfExists(Long id) {
if (deviceReqConfMapper.selectById(id) == null) {
throw exception(ErrorInfo.DEVICE_REQ_CONF_NOT_EXISTS);
}
}
private void validateParentDeviceReqConf(Long id, Long parentId) {
if (parentId == null || DeviceReqConfDO.PARENT_ID_ROOT.equals(parentId)) {
return;
}
// 1. 不能设置自己为父物联网设备请求配置
if (Objects.equals(id, parentId)) {
throw exception(ErrorInfo.DEVICE_REQ_CONF_PARENT_ERROR);
}
// 2. 父物联网设备请求配置不存在
DeviceReqConfDO parentDeviceReqConf = deviceReqConfMapper.selectById(parentId);
if (parentDeviceReqConf == null) {
throw exception(ErrorInfo.DEVICE_REQ_CONF_PARENT_NOT_EXITS);
}
// 3. 递归校验父物联网设备请求配置,如果父物联网设备请求配置是自己的子物联网设备请求配置,则报错,避免形成环路
if (id == null) { // id 为空,说明新增,不需要考虑环路
return;
}
for (int i = 0; i < Short.MAX_VALUE; i++) {
// 3.1 校验环路
parentId = parentDeviceReqConf.getParentId();
if (Objects.equals(id, parentId)) {
throw exception(ErrorInfo.DEVICE_REQ_CONF_PARENT_IS_CHILD);
}
// 3.2 继续递归下一级父物联网设备请求配置
if (parentId == null || DeviceReqConfDO.PARENT_ID_ROOT.equals(parentId)) {
break;
}
parentDeviceReqConf = deviceReqConfMapper.selectById(parentId);
if (parentDeviceReqConf == null) {
break;
}
}
}
private void validateDeviceReqConfDeviceNameUnique(Long id, Long parentId, String deviceName) {
DeviceReqConfDO deviceReqConf = deviceReqConfMapper.selectByParentIdAndDeviceName(parentId, deviceName);
if (deviceReqConf == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的物联网设备请求配置
if (id == null) {
throw exception(ErrorInfo.DEVICE_REQ_CONF_DEVICE_NAME_DUPLICATE);
}
if (!Objects.equals(deviceReqConf.getId(), id)) {
throw exception(ErrorInfo.DEVICE_REQ_CONF_DEVICE_NAME_DUPLICATE);
}
}
@Override
public DeviceReqConfDO getDeviceReqConf(Long id) {
return deviceReqConfMapper.selectById(id);
}
@Override
public List<DeviceReqConfDO> getDeviceReqConfList(DeviceReqConfListReqVO listReqVO) {
return deviceReqConfMapper.selectList(listReqVO);
}
}
\ No newline at end of file
package cn.gintone.service;
import java.util.*;
import javax.validation.*;
import cn.gintone.controller.vo.PtDeptInfoPageReqVO;
import cn.gintone.controller.vo.PtDeptInfoSaveReqVO;
import cn.gintone.entity.PtDeptInfoDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 平台部门 Service 接口
*
* @author 安全系统管理
*/
public interface PtDeptInfoService {
/**
* 创建平台部门
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createPtDeptInfo(@Valid PtDeptInfoSaveReqVO createReqVO);
/**
* 更新平台部门
*
* @param updateReqVO 更新信息
*/
void updatePtDeptInfo(@Valid PtDeptInfoSaveReqVO updateReqVO);
/**
* 删除平台部门
*
* @param id 编号
*/
void deletePtDeptInfo(Long id);
/**
* 获得平台部门
*
* @param id 编号
* @return 平台部门
*/
PtDeptInfoDO getPtDeptInfo(Long id);
/**
* 获得平台部门分页
*
* @param pageReqVO 分页查询
* @return 平台部门分页
*/
PageResult<PtDeptInfoDO> getPtDeptInfoPage(PtDeptInfoPageReqVO pageReqVO);
}
\ No newline at end of file
package cn.gintone.service;
import cn.gintone.ErrorInfo;
import cn.gintone.controller.vo.PtDeptInfoPageReqVO;
import cn.gintone.controller.vo.PtDeptInfoSaveReqVO;
import cn.gintone.dal.PtDeptInfoMapper;
import cn.gintone.entity.PtDeptInfoDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 平台部门 Service 实现类
*
* @author 安全系统管理
*/
@Service
@Validated
public class PtDeptInfoServiceImpl implements PtDeptInfoService {
@Resource
private PtDeptInfoMapper ptDeptInfoMapper;
@Override
public Long createPtDeptInfo(PtDeptInfoSaveReqVO createReqVO) {
// 插入
PtDeptInfoDO ptDeptInfo = BeanUtils.toBean(createReqVO, PtDeptInfoDO.class);
ptDeptInfoMapper.insert(ptDeptInfo);
// 返回
return ptDeptInfo.getId();
}
@Override
public void updatePtDeptInfo(PtDeptInfoSaveReqVO updateReqVO) {
// 校验存在
validatePtDeptInfoExists(updateReqVO.getId());
// 更新
PtDeptInfoDO updateObj = BeanUtils.toBean(updateReqVO, PtDeptInfoDO.class);
ptDeptInfoMapper.updateById(updateObj);
}
@Override
public void deletePtDeptInfo(Long id) {
// 校验存在
validatePtDeptInfoExists(id);
// 删除
ptDeptInfoMapper.deleteById(id);
}
private void validatePtDeptInfoExists(Long id) {
if (ptDeptInfoMapper.selectById(id) == null) {
throw exception(ErrorInfo.PT_DEPT_INFO_NOT_EXISTS);
}
}
@Override
public PtDeptInfoDO getPtDeptInfo(Long id) {
return ptDeptInfoMapper.selectById(id);
}
@Override
public PageResult<PtDeptInfoDO> getPtDeptInfoPage(PtDeptInfoPageReqVO pageReqVO) {
return ptDeptInfoMapper.selectPage(pageReqVO);
}
}
\ No newline at end of file
package cn.gintone.service;
import cn.gintone.controller.vo.SysAbbrePageReqVO;
import cn.gintone.controller.vo.SysAbbreSaveReqVO;
import cn.gintone.entity.SysAbbreDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import java.util.*;
import javax.validation.*;
/**
* 系统简称 Service 接口
*
* @author 安全系统管理
*/
public interface SysAbbreService {
/**
* 创建系统简称
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createSysAbbre(@Valid SysAbbreSaveReqVO createReqVO);
/**
* 更新系统简称
*
* @param updateReqVO 更新信息
*/
void updateSysAbbre(@Valid SysAbbreSaveReqVO updateReqVO);
/**
* 删除系统简称
*
* @param id 编号
*/
void deleteSysAbbre(Long id);
/**
* 获得系统简称
*
* @param id 编号
* @return 系统简称
*/
SysAbbreDO getSysAbbre(Long id);
/**
* 获得系统简称分页
*
* @param pageReqVO 分页查询
* @return 系统简称分页
*/
PageResult<SysAbbreDO> getSysAbbrePage(SysAbbrePageReqVO pageReqVO);
}
\ No newline at end of file
package cn.gintone.service;
import cn.gintone.ErrorInfo;
import cn.gintone.controller.vo.SysAbbrePageReqVO;
import cn.gintone.controller.vo.SysAbbreSaveReqVO;
import cn.gintone.dal.SysAbbreMapper;
import cn.gintone.entity.SysAbbreDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 系统简称 Service 实现类
*
* @author 安全系统管理
*/
@Service
@Validated
public class SysAbbreServiceImpl implements SysAbbreService {
@Resource
private SysAbbreMapper sysAbbreMapper;
@Override
public Long createSysAbbre(SysAbbreSaveReqVO createReqVO) {
// 插入
SysAbbreDO sysAbbre = BeanUtils.toBean(createReqVO, SysAbbreDO.class);
sysAbbreMapper.insert(sysAbbre);
// 返回
return sysAbbre.getId();
}
@Override
public void updateSysAbbre(SysAbbreSaveReqVO updateReqVO) {
// 校验存在
validateSysAbbreExists(updateReqVO.getId());
// 更新
SysAbbreDO updateObj = BeanUtils.toBean(updateReqVO, SysAbbreDO.class);
sysAbbreMapper.updateById(updateObj);
}
@Override
public void deleteSysAbbre(Long id) {
// 校验存在
validateSysAbbreExists(id);
// 删除
sysAbbreMapper.deleteById(id);
}
private void validateSysAbbreExists(Long id) {
if (sysAbbreMapper.selectById(id) == null) {
throw exception(ErrorInfo.SYS_ABBRE_NOT_EXISTS);
}
}
@Override
public SysAbbreDO getSysAbbre(Long id) {
return sysAbbreMapper.selectById(id);
}
@Override
public PageResult<SysAbbreDO> getSysAbbrePage(SysAbbrePageReqVO pageReqVO) {
return sysAbbreMapper.selectPage(pageReqVO);
}
}
\ No newline at end of file
package cn.gintone.service;
import java.util.*;
import javax.validation.*;
import cn.gintone.controller.vo.WebReqConfListReqVO;
import cn.gintone.controller.vo.WebReqConfSaveReqVO;
import cn.gintone.entity.WebReqConfDO;
/**
* web请求配置 Service 接口
*
* @author 安全系统管理
*/
public interface WebReqConfService {
/**
* 创建web请求配置
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createWebReqConf(@Valid WebReqConfSaveReqVO createReqVO);
/**
* 更新web请求配置
*
* @param updateReqVO 更新信息
*/
void updateWebReqConf(@Valid WebReqConfSaveReqVO updateReqVO);
/**
* 删除web请求配置
*
* @param id 编号
*/
void deleteWebReqConf(Long id);
/**
* 获得web请求配置
*
* @param id 编号
* @return web请求配置
*/
WebReqConfDO getWebReqConf(Long id);
/**
* 获得web请求配置列表
*
* @param listReqVO 查询条件
* @return web请求配置列表
*/
List<WebReqConfDO> getWebReqConfList(WebReqConfListReqVO listReqVO);
}
\ No newline at end of file
package cn.gintone.service;
import cn.gintone.ErrorInfo;
import cn.gintone.controller.vo.WebReqConfListReqVO;
import cn.gintone.controller.vo.WebReqConfSaveReqVO;
import cn.gintone.dal.VisitInfoMapper;
import cn.gintone.dal.WebReqConfMapper;
import cn.gintone.entity.VisitInfoDO;
import cn.gintone.entity.WebReqConfDO;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* web请求配置 Service 实现类
*
* @author 安全系统管理
*/
@Service
@Validated
public class WebReqConfServiceImpl implements WebReqConfService {
@Resource
private WebReqConfMapper webReqConfMapper;
@Resource
private VisitInfoMapper visitInfoMapper;
@Override
public Long createWebReqConf(WebReqConfSaveReqVO createReqVO) {
// 校验父级id的有效性
validateParentWebReqConf(null, createReqVO.getParentId());
// 校验api名称的唯一性
validateWebReqConfApiNameUnique(null, createReqVO.getParentId(), createReqVO.getApiName());
// 插入
WebReqConfDO webReqConf = BeanUtils.toBean(createReqVO, WebReqConfDO.class);
webReqConfMapper.insert(webReqConf);
// 返回
return webReqConf.getId();
}
@Override
public void updateWebReqConf(WebReqConfSaveReqVO updateReqVO) {
// 校验存在
validateWebReqConfExists(updateReqVO.getId());
// 校验父级id的有效性
validateParentWebReqConf(updateReqVO.getId(), updateReqVO.getParentId());
// 校验api名称的唯一性
validateWebReqConfApiNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getApiName());
visitInfoMapper.update(new UpdateWrapper<VisitInfoDO>()
.lambda()
.eq(VisitInfoDO::getUrlId, updateReqVO.getId())
.set(VisitInfoDO::getUrlName, updateReqVO.getApiName())
.set(VisitInfoDO::getUrl, updateReqVO.getApiUrl())
);
// 更新
WebReqConfDO updateObj = BeanUtils.toBean(updateReqVO, WebReqConfDO.class);
webReqConfMapper.updateById(updateObj);
}
@Override
public void deleteWebReqConf(Long id) {
// 校验存在
validateWebReqConfExists(id);
// 校验是否有子web请求配置
if (webReqConfMapper.selectCountByParentId(id) > 0) {
throw exception(ErrorInfo.WEB_REQ_CONF_EXITS_CHILDREN);
}
// 删除
webReqConfMapper.deleteById(id);
}
private void validateWebReqConfExists(Long id) {
if (webReqConfMapper.selectById(id) == null) {
throw exception(ErrorInfo.WEB_REQ_CONF_NOT_EXISTS);
}
}
private void validateParentWebReqConf(Long id, Long parentId) {
if (parentId == null || WebReqConfDO.PARENT_ID_ROOT.equals(parentId)) {
return;
}
// 1. 不能设置自己为父web请求配置
if (Objects.equals(id, parentId)) {
throw exception(ErrorInfo.WEB_REQ_CONF_PARENT_ERROR);
}
// 2. 父web请求配置不存在
WebReqConfDO parentWebReqConf = webReqConfMapper.selectById(parentId);
if (parentWebReqConf == null) {
throw exception(ErrorInfo.WEB_REQ_CONF_PARENT_NOT_EXITS);
}
// 3. 递归校验父web请求配置,如果父web请求配置是自己的子web请求配置,则报错,避免形成环路
if (id == null) { // id 为空,说明新增,不需要考虑环路
return;
}
for (int i = 0; i < Short.MAX_VALUE; i++) {
// 3.1 校验环路
parentId = parentWebReqConf.getParentId();
if (Objects.equals(id, parentId)) {
throw exception(ErrorInfo.WEB_REQ_CONF_PARENT_IS_CHILD);
}
// 3.2 继续递归下一级父web请求配置
if (parentId == null || WebReqConfDO.PARENT_ID_ROOT.equals(parentId)) {
break;
}
parentWebReqConf = webReqConfMapper.selectById(parentId);
if (parentWebReqConf == null) {
break;
}
}
}
private void validateWebReqConfApiNameUnique(Long id, Long parentId, String apiName) {
WebReqConfDO webReqConf = webReqConfMapper.selectByParentIdAndApiName(parentId, apiName);
if (webReqConf == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的web请求配置
if (id == null) {
throw exception(ErrorInfo.WEB_REQ_CONF_API_NAME_DUPLICATE);
}
if (!Objects.equals(webReqConf.getId(), id)) {
throw exception(ErrorInfo.WEB_REQ_CONF_API_NAME_DUPLICATE);
}
}
@Override
public WebReqConfDO getWebReqConf(Long id) {
return webReqConfMapper.selectById(id);
}
@Override
public List<WebReqConfDO> getWebReqConfList(WebReqConfListReqVO listReqVO) {
return webReqConfMapper.selectList(listReqVO);
}
}
\ No newline at end of file
package cn.gintone.utils;
import cn.gintone.dtoPt.*;
import cn.iocoder.yudao.module.system.controller.admin.auth.myVo.PtResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import java.util.HashMap;
import java.util.Map;
public class BasicInfoHttpUtils {
/**
* 从平台获取部门信息
* @param url
* @param appkey
* @param pdToken
* @return
*/
public static PtResult<PtData<PtDeptInfo>> getDeptInfo(String url, String appkey, String pdToken) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("appkey", appkey);
headers.put("Authorization", pdToken);
String rStr = MyHttpThreeUtils.postJson(url, headers, null);
PtResult<PtData<PtDeptInfo>> result = JSON.parseObject(rStr, new TypeReference<PtResult<PtData<PtDeptInfo>>>() {});
return result;
}
/**
* 从平台获取人员信息
* @param url
* @param appkey
* @param pdToken
* @return
*/
public static PtResult<PtData<PtUserInfo>> getUserInfo(String url, String appkey, String pdToken) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("appkey", appkey);
headers.put("Authorization", pdToken);
String rStr = MyHttpThreeUtils.postJson(url, headers, null);
PtResult<PtData<PtUserInfo>> result = JSON.parseObject(rStr, new TypeReference<PtResult<PtData<PtUserInfo>>>() {});
return result;
}
/**
* 获取泵站信息
* @param url
* @param appkey
* @param pdToken
* @return
*/
public static PtResult<PtData<PtBzInfo>> getBzInfo(String url, String appkey, String pdToken) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("appkey", appkey);
headers.put("Authorization", pdToken);
String rStr = MyHttpThreeUtils.postJson(url, headers, null);
PtResult<PtData<PtBzInfo>> result = JSON.parseObject(rStr, new TypeReference<PtResult<PtData<PtBzInfo>>>() {});
return result;
}
/**
* 防控车辆信息
* @param url
* @param appkey
* @param pdToken
* @return
*/
public static PtResult<PtData<PtCarInfo>> getFKCLInfo(String url, String appkey, String pdToken) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("appkey", appkey);
headers.put("Authorization", pdToken);
String rStr = MyHttpThreeUtils.postJson(url, headers, null);
PtResult<PtData<PtCarInfo>> result = JSON.parseObject(rStr, new TypeReference<PtResult<PtData<PtCarInfo>>>() {});
return result;
}
/**
* 摄像图信息
* @param url
* @param appkey
* @param pdToken
* @return
*/
public static PtResult<PtData<PtSXTInfo>> getSXTInfo(String url, String appkey, String pdToken) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("appkey", appkey);
headers.put("Authorization", pdToken);
String rStr = MyHttpThreeUtils.postJson(url, headers, null);
PtResult<PtData<PtSXTInfo>> result = JSON.parseObject(rStr, new TypeReference<PtResult<PtData<PtSXTInfo>>>() {});
return result;
}
/**
* 管点信息
* @param url
* @param appkey
* @param pdToken
* @return
*/
public static PtResult<PtData<PtGdInfo>> getGDInfo(String url, String appkey, String pdToken) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("appkey", appkey);
headers.put("Authorization", pdToken);
String rStr = MyHttpThreeUtils.postJson(url, headers, null);
PtResult<PtData<PtGdInfo>> result = JSON.parseObject(rStr, new TypeReference<PtResult<PtData<PtGdInfo>>>() {});
return result;
}
/**
* 井盖信息
* @param url
* @param appkey
* @param pdToken
* @return
*/
public static PtResult<PtData<PtJgInfo>> getJgInfo(String url, String appkey, String pdToken) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("appkey", appkey);
headers.put("Authorization", pdToken);
String rStr = MyHttpThreeUtils.postJson(url, headers, null);
PtResult<PtData<PtJgInfo>> result = JSON.parseObject(rStr, new TypeReference<PtResult<PtData<PtJgInfo>>>() {});
return result;
}
}
package cn.gintone.utils;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.*;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.Map;
/**
* HTTP请求工具类
* 支持HTTP/HTTPS协议自动判断
* 支持GET/POST/PUT/DELETE请求方法
*/
public class MyHttpThreeUtils {
private static RestTemplate restTemplate;
static {
// 初始化RestTemplate,支持HTTPS
restTemplate = createRestTemplate();
}
/**
* 创建支持HTTPS的RestTemplate
*/
private static RestTemplate createRestTemplate() {
try {
// 信任所有证书
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
.loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpClient = HttpClients.custom()
.setSSLSocketFactory(csf)
.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
// 设置连接和读取超时时间(单位:毫秒)
requestFactory.setConnectTimeout(5000);
requestFactory.setReadTimeout(10000);
return new RestTemplate(requestFactory);
} catch (KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) {
throw new RuntimeException("创建RestTemplate失败", e);
}
}
/**
* 发送GET请求
* @param url 请求地址
* @param headers 请求头
* @param params 请求参数
* @return 响应结果
*/
public static String get(String url, Map<String, String> headers, Map<String, Object> params) {
HttpHeaders httpHeaders = new HttpHeaders();
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(null, httpHeaders);
// 处理URL参数
String fullUrl = buildUrlWithParams(url, params);
ResponseEntity<String> response = restTemplate.exchange(
fullUrl, HttpMethod.GET, requestEntity, String.class);
return response.getBody();
}
/**
* 发送POST请求(JSON格式)
* @param url 请求地址
* @param headers 请求头
* @param body 请求体(JSON字符串)
* @return 响应结果
*/
public static String postJson(String url, Map<String, String> headers, String body) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(body, httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(
url, HttpMethod.POST, requestEntity, String.class);
return response.getBody();
}
/**
* 发送POST请求(表单格式)
* @param url 请求地址
* @param headers 请求头
* @param formData 表单数据
* @return 响应结果
*/
public static String postForm(String url, Map<String, String> headers, Map<String, String> formData) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
if (headers != null) {
headers.forEach(httpHeaders::add);
}
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
if (formData != null) {
formData.forEach(map::add);
}
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(map, httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(
url, HttpMethod.POST, requestEntity, String.class);
return response.getBody();
}
/**
* 发送PUT请求(JSON格式)
* @param url 请求地址
* @param headers 请求头
* @param body 请求体(JSON字符串)
* @return 响应结果
*/
public static String putJson(String url, Map<String, String> headers, String body) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(body, httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(
url, HttpMethod.PUT, requestEntity, String.class);
return response.getBody();
}
/**
* 发送DELETE请求
* @param url 请求地址
* @param headers 请求头
* @param params 请求参数
* @return 响应结果
*/
public static String delete(String url, Map<String, String> headers, Map<String, Object> params) {
HttpHeaders httpHeaders = new HttpHeaders();
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(null, httpHeaders);
// 处理URL参数
String fullUrl = buildUrlWithParams(url, params);
ResponseEntity<String> response = restTemplate.exchange(
fullUrl, HttpMethod.DELETE, requestEntity, String.class);
return response.getBody();
}
/**
* 构建带参数的URL
* @param url 原始URL
* @param params 参数Map
* @return 带参数的URL
*/
private static String buildUrlWithParams(String url, Map<String, Object> params) {
if (params == null || params.isEmpty()) {
return url;
}
StringBuilder sb = new StringBuilder(url);
if (!url.contains("?")) {
sb.append("?");
} else {
sb.append("&");
}
params.forEach((key, value) -> sb.append(key).append("=").append(value).append("&"));
// 删除最后一个多余的&
return sb.substring(0, sb.length() - 1);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.gintone.dal.DeviceReqConfMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.ptinfo.dal.mysql.ptdeptinfo.PtDeptInfoMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.gintone.dal.SysAbbreMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.gintone.dal.WebReqConfMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
\ No newline at end of file
......@@ -66,6 +66,17 @@
<artifactId>yudao-module-system-api</artifactId> <!-- 需要使用它,进行 Token 的校验 -->
<version>${revision}</version>
</dependency>
<!-- HTTPClient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
</dependencies>
</project>
......@@ -7,20 +7,29 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.myVo.LoginUserInfo;
import cn.iocoder.yudao.framework.security.core.myVo.PtResult;
import cn.iocoder.yudao.framework.security.core.util.MyHttpTwoUtils;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi;
import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.annotation.Resource;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Token 过滤器,验证 token 的有效性
......@@ -34,9 +43,11 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
private final SecurityProperties securityProperties;
private final GlobalExceptionHandler globalExceptionHandler;
private final OAuth2TokenApi oauth2TokenApi;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Override
@SuppressWarnings("NullableProblems")
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
......@@ -44,7 +55,8 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
String pdToken = request.getHeader("pdToken");
StringBuffer requestURL = request.getRequestURL();
System.out.println(requestURL.toString());
stringRedisTemplate.opsForValue().set("pdToken", pdToken);
// System.out.println(requestURL.toString());
if (requestURL.toString().contains("system/") || requestURL.toString().contains("get-by-website") || requestURL.toString().contains("checkPdToken")) {
} else {
......@@ -56,6 +68,22 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
result.setMsg("未登录");
ServletUtils.writeJSON(response, result);
return;
} else {
/*Map<String, String> headers = new HashMap<>();
headers.put("appkey", "secure");
headers.put("Authorization", pdToken);
String rStr = MyHttpTwoUtils.get("http://127.0.0.1:7006/oauth/N100101", headers, null);
PtResult<LoginUserInfo> result = JSON.parseObject(rStr, new TypeReference<PtResult<LoginUserInfo>>() {});
if (null == result || !result.getCode().equals("200")) {
CommonResult<?> result1 = new CommonResult<>();
result1.setCode(403);
result1.setMsg("未登录");
ServletUtils.writeJSON(response, result);
} else {
LoginUserInfo data = result.getData();
String accessToken = data.getAccessToken();
stringRedisTemplate.opsForValue().set("pdToken", accessToken);
}*/
}
return;
}
......
package cn.iocoder.yudao.framework.security.core.myVo;
import java.util.Arrays;
public class DataAuth {
private String[] subjectIds;
private String[] regionIds;
public String[] getSubjectIds() {
return subjectIds;
}
public void setSubjectIds(String[] subjectIds) {
this.subjectIds = subjectIds;
}
public String[] getRegionIds() {
return regionIds;
}
public void setRegionIds(String[] regionIds) {
this.regionIds = regionIds;
}
@Override
public String toString() {
return "DataAuth{" +
"subjectIds=" + Arrays.toString(subjectIds) +
", regionIds=" + Arrays.toString(regionIds) +
'}';
}
}
package cn.iocoder.yudao.framework.security.core.myVo;
public class LoginRequestVo {
private String username;
private String password;
private String phoneNum;
private String vCode;
private int platform;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public String getvCode() {
return vCode;
}
public void setvCode(String vCode) {
this.vCode = vCode;
}
public int getPlatform() {
return platform;
}
public void setPlatform(int platform) {
this.platform = platform;
}
@Override
public String toString() {
return "LoginRequestVo{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
", phoneNum='" + phoneNum + '\'' +
", vCode='" + vCode + '\'' +
", platform=" + platform +
'}';
}
}
package cn.iocoder.yudao.framework.security.core.myVo;
public class LoginUserInfo {
private String orgName;
private String userPhoto;
private String loginId;
private String roleId;
private DataAuth dataAuth;
private String phoneNum;
private String userName;
private String accessToken;
private String userId;
private String orgId;
private Integer expiresIn;
private String orgType;
private String userState;
private String clientIp;
private String roleName;
private String imei;
private String refreshToken;
public String getOrgName() {
return orgName;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public String getUserPhoto() {
return userPhoto;
}
public void setUserPhoto(String userPhoto) {
this.userPhoto = userPhoto;
}
public String getLoginId() {
return loginId;
}
public void setLoginId(String loginId) {
this.loginId = loginId;
}
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public DataAuth getDataAuth() {
return dataAuth;
}
public void setDataAuth(DataAuth dataAuth) {
this.dataAuth = dataAuth;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public Integer getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Integer expiresIn) {
this.expiresIn = expiresIn;
}
public String getOrgType() {
return orgType;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
public String getUserState() {
return userState;
}
public void setUserState(String userState) {
this.userState = userState;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
@Override
public String toString() {
return "LoginUserInfo{" +
"orgName='" + orgName + '\'' +
", userPhoto='" + userPhoto + '\'' +
", loginId='" + loginId + '\'' +
", roleId='" + roleId + '\'' +
", dataAuth=" + dataAuth +
", phoneNum='" + phoneNum + '\'' +
", userName='" + userName + '\'' +
", accessToken='" + accessToken + '\'' +
", userId='" + userId + '\'' +
", orgId='" + orgId + '\'' +
", expiresIn=" + expiresIn +
", orgType='" + orgType + '\'' +
", userState='" + userState + '\'' +
", clientIp='" + clientIp + '\'' +
", roleName='" + roleName + '\'' +
", imei='" + imei + '\'' +
", refreshToken='" + refreshToken + '\'' +
'}';
}
}
package cn.iocoder.yudao.framework.security.core.myVo;
public class PtResult<T> {
private String msg;
private String eventId;
private String flag;
private String code;
private T data;
private String errorStack;
public PtResult() {
}
public PtResult(String code, String msg, T data, String eventId, String flag, String errorStack) {
this.msg = msg;
this.eventId = eventId;
this.flag = flag;
this.code = code;
this.data = data;
this.errorStack = errorStack;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getErrorStack() {
return errorStack;
}
public void setErrorStack(String errorStack) {
this.errorStack = errorStack;
}
@Override
public String toString() {
return "PtResult{" +
"msg='" + msg + '\'' +
", eventId='" + eventId + '\'' +
", flag='" + flag + '\'' +
", code='" + code + '\'' +
", data=" + data +
", errorStack='" + errorStack + '\'' +
'}';
}
}
package cn.iocoder.yudao.framework.security.core.util;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.*;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.Map;
/**
* HTTP请求工具类
* 支持HTTP/HTTPS协议自动判断
* 支持GET/POST/PUT/DELETE请求方法
*/
public class MyHttpTwoUtils {
private static RestTemplate restTemplate;
static {
// 初始化RestTemplate,支持HTTPS
restTemplate = createRestTemplate();
}
/**
* 创建支持HTTPS的RestTemplate
*/
private static RestTemplate createRestTemplate() {
try {
// 信任所有证书
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
.loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpClient = HttpClients.custom()
.setSSLSocketFactory(csf)
.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
// 设置连接和读取超时时间(单位:毫秒)
requestFactory.setConnectTimeout(5000);
requestFactory.setReadTimeout(10000);
return new RestTemplate(requestFactory);
} catch (KeyStoreException | NoSuchAlgorithmException | KeyManagementException e) {
throw new RuntimeException("创建RestTemplate失败", e);
}
}
/**
* 发送GET请求
* @param url 请求地址
* @param headers 请求头
* @param params 请求参数
* @return 响应结果
*/
public static String get(String url, Map<String, String> headers, Map<String, Object> params) {
HttpHeaders httpHeaders = new HttpHeaders();
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(null, httpHeaders);
// 处理URL参数
String fullUrl = buildUrlWithParams(url, params);
ResponseEntity<String> response = restTemplate.exchange(
fullUrl, HttpMethod.GET, requestEntity, String.class);
return response.getBody();
}
/**
* 发送POST请求(JSON格式)
* @param url 请求地址
* @param headers 请求头
* @param body 请求体(JSON字符串)
* @return 响应结果
*/
public static String postJson(String url, Map<String, String> headers, String body) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(body, httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(
url, HttpMethod.POST, requestEntity, String.class);
return response.getBody();
}
/**
* 发送POST请求(表单格式)
* @param url 请求地址
* @param headers 请求头
* @param formData 表单数据
* @return 响应结果
*/
public static String postForm(String url, Map<String, String> headers, Map<String, String> formData) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
if (headers != null) {
headers.forEach(httpHeaders::add);
}
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
if (formData != null) {
formData.forEach(map::add);
}
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(map, httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(
url, HttpMethod.POST, requestEntity, String.class);
return response.getBody();
}
/**
* 发送PUT请求(JSON格式)
* @param url 请求地址
* @param headers 请求头
* @param body 请求体(JSON字符串)
* @return 响应结果
*/
public static String putJson(String url, Map<String, String> headers, String body) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(body, httpHeaders);
ResponseEntity<String> response = restTemplate.exchange(
url, HttpMethod.PUT, requestEntity, String.class);
return response.getBody();
}
/**
* 发送DELETE请求
* @param url 请求地址
* @param headers 请求头
* @param params 请求参数
* @return 响应结果
*/
public static String delete(String url, Map<String, String> headers, Map<String, Object> params) {
HttpHeaders httpHeaders = new HttpHeaders();
if (headers != null) {
headers.forEach(httpHeaders::add);
}
HttpEntity<String> requestEntity = new HttpEntity<>(null, httpHeaders);
// 处理URL参数
String fullUrl = buildUrlWithParams(url, params);
ResponseEntity<String> response = restTemplate.exchange(
fullUrl, HttpMethod.DELETE, requestEntity, String.class);
return response.getBody();
}
/**
* 构建带参数的URL
* @param url 原始URL
* @param params 参数Map
* @return 带参数的URL
*/
private static String buildUrlWithParams(String url, Map<String, Object> params) {
if (params == null || params.isEmpty()) {
return url;
}
StringBuilder sb = new StringBuilder(url);
if (!url.contains("?")) {
sb.append("?");
} else {
sb.append("&");
}
params.forEach((key, value) -> sb.append(key).append("=").append(value).append("&"));
// 删除最后一个多余的&
return sb.substring(0, sb.length() - 1);
}
}
package cn.iocoder.yudao.module.system.controller.admin.myUtils;
import cn.iocoder.yudao.module.system.controller.admin.auth.myVo.LoginUserInfo;
import cn.iocoder.yudao.module.system.controller.admin.auth.myVo.PtResult;
import cn.iocoder.yudao.module.system.controller.admin.conf.PtUrlConf;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import java.util.HashMap;
import java.util.Map;
public class PtTokenUtils {
public static PtResult<LoginUserInfo> getUserByToken(PtUrlConf ptUrlConf, String appkey, String authorization) {
// 带参数和请求头
Map<String, String> headers = new HashMap<>();
headers.put("appkey", appkey);
headers.put("Authorization", authorization);
String rStr = MyHttpUtils.get(ptUrlConf.getGetUserByToken(), headers, null);
PtResult<LoginUserInfo> result = JSON.parseObject(rStr, new TypeReference<PtResult<LoginUserInfo>>() {});
return result;
}
}
......@@ -102,15 +102,22 @@ rocketmq:
spring:
# RabbitMQ 配置项,对应 RabbitProperties 配置类
rabbitmq:
host: 127.0.0.1 # RabbitMQ 服务的地址
port: 5672 # RabbitMQ 服务的端口
username: guest # RabbitMQ 服务的账号
password: guest # RabbitMQ 服务的密码
# rabbitmq:
# host: 127.0.0.1 # RabbitMQ 服务的地址
# port: 5672 # RabbitMQ 服务的端口
# username: guest # RabbitMQ 服务的账号
# password: guest # RabbitMQ 服务的密码
# Kafka 配置项,对应 KafkaProperties 配置类
kafka:
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
bootstrap-servers: 192.168.19.128:9092
producer:
retries: 3
timeout: 60000
consumer:
group-id: weblog_consumer_group
auto-offset-reset: earliest
admin:
auto-create: true
--- #################### 服务保障相关配置 ####################
# Lock4j 配置项
......
......@@ -54,7 +54,7 @@ spring:
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true;useUnicode=true;characterEncoding=utf-8 # SQLServer 连接的示例
# url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例
url: jdbc:kingbase8://192.168.19.128:54321/test # 人大金仓 KingbaseES 连接的示例
url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例
# url: jdbc:postgresql://192.168.19.128:54321/test # OpenGauss 连接的示例
username: kingbase
password: kingbase
......@@ -124,15 +124,23 @@ rocketmq:
spring:
# RabbitMQ 配置项,对应 RabbitProperties 配置类
rabbitmq:
host: 192.168.19.205
port: 5672
username: kalo
password: kalo
virtual-host: /
# host: 192.168.19.205
# host: 127.0.0.1
# port: 5672
# username: kalo
# password: kalo
# virtual-host: /
# Kafka 配置项,对应 KafkaProperties 配置类
kafka:
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
bootstrap-servers: 192.168.19.128:9092
producer:
retries: 3
timeout: 60000
consumer:
group-id: weblog_consumer_group
auto-offset-reset: earliest
admin:
auto-create: true
--- #################### 服务保障相关配置 ####################
# Lock4j 配置项
......
......@@ -365,7 +365,8 @@ pf4j:
pluginsDir: /Users/anhaohao/code/gitee/ruoyi-vue-pro/plugins # 插件目录
iotdb:
ip: 192.168.19.128
# ip: 192.168.19.191
ip: 127.0.0.1
port: 6667
username: root
password: root
......@@ -380,3 +381,7 @@ ptauth:
logOffToken: http://3h.sritcloud.com:8000/oauth/N1007
refTokenUrl: http://3h.sritcloud.com:8000/oauth/N1010
logOffTokenAndJump: http://3h.sritcloud.com:8000/oauth/oauth/logout?redirect_uri=
basicinfo:
userInfoUrl: http://59.195.13.243:8000/srit-open-api/data-service/api/user-info-list
\ No newline at end of file
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