Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add wp Integration #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integrations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<module>sample-integrations</module>
<module>ping</module>
<module>msc-integration</module>
<module>wp-integration</module>
</modules>

<properties>
Expand Down
53 changes: 53 additions & 0 deletions integrations/wp-integration/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>beaver-iot-integrations</artifactId>
<groupId>com.milesight.beaveriot</groupId>
<version>1.0.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>wp-integration</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.milesight.beaveriot</groupId>
<artifactId>context</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.20</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>3.3.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.milesight.beaveriot</groupId>
<artifactId>entity-service</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.milesight.beaveriot.integration.wp;

import com.milesight.beaveriot.context.integration.bootstrap.IntegrationBootstrap;
import com.milesight.beaveriot.context.integration.model.Integration;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.CamelContext;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class WpIntegrationBootstrap implements IntegrationBootstrap {


@Override
public void onPrepared(Integration integrationConfig) {

}

@Override
public void onStarted(Integration integrationConfig) {
log.info("WP integration started");
}

@Override
public void onDestroy(Integration integrationConfig) {
log.info("WP integration stopping");
}

@Override
public void customizeRoute(CamelContext context) throws Exception {
IntegrationBootstrap.super.customizeRoute(context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.milesight.beaveriot.integration.wp.constant;

import com.milesight.beaveriot.base.utils.StringUtils;

public interface WpIntegrationConstants {

String INTEGRATION_IDENTIFIER = "wp-integration";

public static String getKey(String propertyKey) {
return WpIntegrationConstants.INTEGRATION_IDENTIFIER + ".integration." + StringUtils.toSnakeCase(propertyKey);
}

interface DeviceAdditionalDataName {

String DEVICE_ID = "id";

}

interface InternalPropertyIdentifier {

interface Pattern {
String PREFIX = "_#";
String SUFFIX = "#_";
String TEMPLATE = "_#%s#_";

static boolean match(String key) {
return key.startsWith(PREFIX) && key.endsWith(SUFFIX);
}
}

String LAST_SYNC_TIME = "_#last_sync_time#_";

static String getLastSyncTimeKey(String deviceKey) {
return String.format("%s.%s", deviceKey, LAST_SYNC_TIME);
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.milesight.beaveriot.integration.wp.controller;

import com.milesight.beaveriot.base.response.ResponseBody;
import com.milesight.beaveriot.base.response.ResponseBuilder;
import com.milesight.beaveriot.integration.wp.model.WpMeetingRequest;
import com.milesight.beaveriot.integration.wp.model.WpMeetingResponse;
import com.milesight.beaveriot.integration.wp.service.WpMeetingRoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
*
*/
@Slf4j
@RestController
@RequestMapping("/meeting")
public class WpController {


@Autowired
private WpMeetingRoomService wpMeetingRoomService;

@PostMapping
public ResponseBody<WpMeetingResponse> addMeeting(@RequestBody WpMeetingRequest wpMeetingRequest) {
return ResponseBuilder.success(wpMeetingRoomService.addMeetingRoom(wpMeetingRequest, null));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.milesight.beaveriot.integration.wp.entity;

import com.milesight.beaveriot.context.integration.context.AddDeviceAware;
import com.milesight.beaveriot.context.integration.context.DeleteDeviceAware;
import com.milesight.beaveriot.context.integration.entity.annotation.Attribute;
import com.milesight.beaveriot.context.integration.entity.annotation.Entities;
import com.milesight.beaveriot.context.integration.entity.annotation.Entity;
import com.milesight.beaveriot.context.integration.entity.annotation.IntegrationEntities;
import com.milesight.beaveriot.context.integration.enums.EntityType;
import com.milesight.beaveriot.context.integration.model.ExchangePayload;
import lombok.*;
import lombok.experimental.FieldNameConstants;

@Data
@EqualsAndHashCode(callSuper = true)
@IntegrationEntities
public class WpIntegrationEntities extends ExchangePayload {

@Entity(type = EntityType.SERVICE, identifier = "add_device")
private AddDevice addDevice;

@Entity(type = EntityType.SERVICE)
private SyncDevice syncDevice;

@Entity(type = EntityType.SERVICE, identifier = "delete_device")
private DeleteDevice deleteDevice;


@Entity
private Openapi openapi;

@Data
@EqualsAndHashCode(callSuper = true)
@Entities
public static class DetectReport extends ExchangePayload {
// Entity type inherits from parent entity (DetectReport)
@Entity
private Long consumedTime;

@Entity
private Long onlineCount;

@Entity
private Long offlineCount;
}

@FieldNameConstants
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entities
public static class Openapi extends ExchangePayload {

@Entity(attributes = {@Attribute(minLength = 1)})
private String username;

@Entity(attributes = {@Attribute(minLength = 1)})
private String password;

}

@Data
@EqualsAndHashCode(callSuper = true)
@Entities
public static class AddDevice extends ExchangePayload implements AddDeviceAware {

@Entity(attributes = {@Attribute(min = 1, max = 999)})
private Integer memberCapacity;

}

@Data
@EqualsAndHashCode(callSuper = true)
@Entities
public static class DeleteDevice extends ExchangePayload implements DeleteDeviceAware {
}

public enum DetectStatus {
STANDBY, DETECTING;
}

@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@Entities
public static class SyncDevice extends ExchangePayload {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.milesight.beaveriot.integration.wp.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WpMeeting {
// "schedule": {
// "conferenceRecordId": 245698,
// "startTime": 1732710600,
// "endTime": 1732716000,
// "originalStartTime": 1732710600,
// "originalEndTime": 1732716000,
// "allowCheckIn": false,
// "shouldCheckIn": false,
// "allowCheckOut": false,
// "status": "NOT_STARTED",
// "subject": "图像会议室的预约",
// "meetingRoomName": "图像会议室",
// "meetingRoomId": 2551,
// "meetingRoomType": "common",
// "buildingId": 1300,
// "floorId": 2210,
// "conferenceId": 249275,
// "host": {
// "memberId": 73825,
// "name": "test",
// "email": "[email protected]",
// "role": "HOST",
// "isResource": false,
// "accessibleRealSchedule": false,
// "userId": 78902,
// "hasCheckined": false
// },
// "notificationTime": 15,
// "willStartReminderMinutes": [
// 15
// ],
// "scheduleType": "CONFERENCE",
// "canBeExtended": false,
// "roomExpired": false,
// "checkInStatistics": false
// },

private Integer conferenceRecordId;
private String subject;
private String meetingRoomName;
private String meetingRoomId;
private String meetingId;
private String firstStartTime;
private String lastEndTime;
private Long createTime;
private String startDate;
private String startTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.milesight.beaveriot.integration.wp.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WpMeetingRequest {
// "schedule": {
// "conferenceRecordId": 245698,
// "startTime": 1732710600,
// "endTime": 1732716000,
// "originalStartTime": 1732710600,
// "originalEndTime": 1732716000,
// "allowCheckIn": false,
// "shouldCheckIn": false,
// "allowCheckOut": false,
// "status": "NOT_STARTED",
// "subject": "图像会议室的预约",
// "meetingRoomName": "图像会议室",
// "meetingRoomId": 2551,
// "meetingRoomType": "common",
// "buildingId": 1300,
// "floorId": 2210,
// "conferenceId": 249275,
// "host": {
// "memberId": 73825,
// "name": "test",
// "email": "[email protected]",
// "role": "HOST",
// "isResource": false,
// "accessibleRealSchedule": false,
// "userId": 78902,
// "hasCheckined": false
// },
// "notificationTime": 15,
// "willStartReminderMinutes": [
// 15
// ],
// "scheduleType": "CONFERENCE",
// "canBeExtended": false,
// "roomExpired": false,
// "checkInStatistics": false
// },

private Integer type;
private String meeting;
private String id;
private String key;
private String subject;
private String first;
private String last;
private String date;
private String time;
}
Loading