Compare commits
4 Commits
main
...
publicendp
Author | SHA1 | Date |
---|---|---|
Kavishka Madhusankha | 7ac7a535ef | 5 hours ago |
Kavishka Madhusankha | 52d68cd33f | 3 days ago |
Kavishka Madhusankha | 9f181d088a | 4 days ago |
Kavishka Madhusankha | fdbae4bd57 | 4 days ago |
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.controller;
|
||||
|
||||
import com.example.Public.Configuration.model.DeviceConfig;
|
||||
import com.example.Public.Configuration.response.Response;
|
||||
import com.example.Public.Configuration.service.impl.DeviceConfigServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/deviceConfig")
|
||||
public class DeviceConfigController {
|
||||
|
||||
@Autowired // This annotation is used to inject the DeviceService object into the DeviceController class.
|
||||
private DeviceConfigServiceImpl deviceConfigService; // This object is used to perform CRUD operations on the Device table in the database.
|
||||
|
||||
@PostMapping("/create-config") // add a new device to the database.
|
||||
public ResponseEntity<?> createConfig(@RequestBody DeviceConfig deviceConfig) {
|
||||
DeviceConfig deviceConfigCheck = deviceConfigService.getDeviceConfigById(String.valueOf(deviceConfig.getConfigId())); // check if the device already exists in the database.// save the device object to the database.
|
||||
if(deviceConfigCheck == null) {
|
||||
deviceConfigService.saveConfigDetails(deviceConfig); // save the device object to the database.
|
||||
return new ResponseEntity<>(new Response(HttpStatus.CREATED.value(),
|
||||
"Device added successfully"), HttpStatus.CREATED); // return a success message.
|
||||
|
||||
}
|
||||
return new ResponseEntity<String>("Device already exists", HttpStatus.BAD_REQUEST); // return a message indicating that the device already exists.
|
||||
}
|
||||
|
||||
@GetMapping("/get-allConfigs")
|
||||
public List<DeviceConfig> getConfigsDevices() { // get all devices from the database.
|
||||
return deviceConfigService.getAllDeviceConfigs(); // return a list of all devices.
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/{config_id}")
|
||||
public ResponseEntity<?> fetchConfigByConfigId(@PathVariable String config_id) { // get a device by its id.
|
||||
DeviceConfig deviceConfig = deviceConfigService.getDeviceConfigById(config_id);
|
||||
if (deviceConfig == null) {
|
||||
return new ResponseEntity<>(new Response(HttpStatus.NOT_FOUND.value(),
|
||||
"No Device found for Config ID: +config_id"), HttpStatus.NOT_FOUND);// return an empty device object if the device does not exist in the database.
|
||||
}
|
||||
return new ResponseEntity<>(deviceConfig, HttpStatus.OK); // return the device object if it exists in the database.
|
||||
}
|
||||
|
||||
@PutMapping("/updateDeviceConfig")
|
||||
public DeviceConfig updateDeviceDetails(@RequestBody DeviceConfig deviceConfig) { // update a device in the database.
|
||||
return deviceConfigService.UpdateConfigDetails(deviceConfig);
|
||||
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-Config- Device/{configId}")
|
||||
public String deleteDeviceConfigById(@PathVariable String configId) {
|
||||
System.out.println("Deleting Device with Config ID: " + configId); // delete a device from the database.
|
||||
return deviceConfigService.deleteConfigDevice(configId);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.controller;
|
||||
|
||||
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||
import com.example.Public.Configuration.response.Response;
|
||||
import com.example.Public.Configuration.service.impl.EnrolmentRequestServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/deviceEnrolmentRequest")
|
||||
public class EnrolmentRequestController {
|
||||
|
||||
@Autowired // This annotation is used to inject the DeviceService object into the DeviceController class.
|
||||
private EnrolmentRequestServiceImpl enrolmentRequestService; // This object is used to perform CRUD operations on the Device table in the database.
|
||||
|
||||
@PostMapping("/create-enrolment-request") // add a new device to the database.
|
||||
public ResponseEntity<?> createEnrolmentRequest(@RequestBody EnrolmentRequestLog enrolmentRequestLog) {
|
||||
EnrolmentRequestLog deviceEnrolmentRequest = enrolmentRequestService.getByEnrolmentRequestId(enrolmentRequestLog.getImei()); // check if the device already exists in the database.// save the device object to the database.
|
||||
if (deviceEnrolmentRequest == null) {
|
||||
enrolmentRequestService.saveEnrolmentRequest(enrolmentRequestLog); // save the device object to the database.
|
||||
return new ResponseEntity<>(new Response(HttpStatus.CREATED.value(), "Device added successfully"), HttpStatus.CREATED); // return a success message.
|
||||
}
|
||||
return new ResponseEntity<String>("Device already exists", HttpStatus.BAD_REQUEST); // return a message indicating that the device already exists.
|
||||
}
|
||||
|
||||
@GetMapping("/get-AllEnrolment-Requests")
|
||||
public List<EnrolmentRequestLog> getDevices() { // get all devices from the database.
|
||||
return enrolmentRequestService.getAllEnrolmentRequests(); // return a list of all devices.
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/{enrolmentRequestId}")
|
||||
public ResponseEntity<?> fetchByEnrolmentRequestId(@PathVariable String imei) { // get a device by its id.
|
||||
EnrolmentRequestLog enrolmentRequestLog = enrolmentRequestService.getByEnrolmentRequestId(imei);
|
||||
if (enrolmentRequestLog == null) {
|
||||
return new ResponseEntity<>(new Response(HttpStatus.NOT_FOUND.value(), "No Device found for Enrolment Request : +imei"), HttpStatus.NOT_FOUND);// return an empty device object if the device does not exist in the database.
|
||||
}
|
||||
return new ResponseEntity<>(enrolmentRequestLog, HttpStatus.OK); // return the device object if it exists in the database.
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-EnrolmentRequest/{imei}")
|
||||
public EnrolmentRequestLog deleteByEnrolmentRequestId(@PathVariable String imei) {//delete a device from the database.
|
||||
return enrolmentRequestService.getByEnrolmentRequestId(imei);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.dao;
|
||||
|
||||
import com.example.Public.Configuration.model.DeviceConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DeviceConfigDao extends JpaRepository<DeviceConfig, Integer> {
|
||||
|
||||
DeviceConfig findByConfigId(String configId);
|
||||
|
||||
void deleteByConfigId(String configId);
|
||||
|
||||
}
|
@ -1,7 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.dao;
|
||||
|
||||
import com.example.Public.Configuration.model.Device;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface DeviceDao extends JpaRepository<Device, Long> {
|
||||
public interface DeviceDao extends JpaRepository<Device, Integer> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.dao;
|
||||
|
||||
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface EnrolmentRequestLogDao extends JpaRepository<EnrolmentRequestLog, Integer> {
|
||||
|
||||
EnrolmentRequestLog findByImei(String imei);
|
||||
|
||||
void deleteByImei(String imei);
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.example.Public.Configuration.dto;
|
||||
|
||||
public class EnrolmentRequestDTO {
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.model;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "device_config")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceConfig {
|
||||
|
||||
@Id
|
||||
@Column(name = "config_profile_id")
|
||||
private String configId;
|
||||
|
||||
@Column(name = "config_profile")
|
||||
private String configProfile;
|
||||
|
||||
// @Column(name = "Network Mode")
|
||||
// private String Network_mode;
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "enrolment_request_log")
|
||||
@AllArgsConstructor
|
||||
public class EnrolmentRequestLog {
|
||||
|
||||
|
||||
@Id
|
||||
@Column(name = "enrolment_request")
|
||||
private String imei;
|
||||
private String device_model;
|
||||
private String ipAddress;
|
||||
private Date update_time;
|
||||
private String network;
|
||||
private String MFW_Version;
|
||||
private String LAC;
|
||||
private String smsPIN;
|
||||
private String subTypeId;
|
||||
private String cellId; //"cellId"
|
||||
private String device_organization;
|
||||
private String MEFW_Version;
|
||||
private String RSSI;
|
||||
|
||||
public EnrolmentRequestLog() {
|
||||
}
|
||||
|
||||
public void setImei(Long imei) {
|
||||
this.imei = String.valueOf(imei);
|
||||
}
|
||||
|
||||
public String getImei() {
|
||||
return imei;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Response {
|
||||
|
||||
private int code;
|
||||
private String message;
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.example.Public.Configuration.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
|
||||
public class ResponseMessage {
|
||||
|
||||
private int status;
|
||||
private String message;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.service;
|
||||
|
||||
import com.example.Public.Configuration.model.DeviceConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DeviceConfigService {
|
||||
|
||||
DeviceConfig saveConfigDetails(DeviceConfig deviceConfig);
|
||||
List<DeviceConfig> getAllDeviceConfigs();
|
||||
DeviceConfig getDeviceConfigById(String config_id);
|
||||
DeviceConfig UpdateConfigDetails(DeviceConfig deviceConfig);
|
||||
String deleteConfigDevice(String configId);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.service;
|
||||
|
||||
import com.example.Public.Configuration.model.DeviceEnrolment;
|
||||
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EnrolmentRequestService {
|
||||
|
||||
DeviceEnrolment saveEnrolmentRequest(EnrolmentRequestLog enrolmentRequestLog);
|
||||
|
||||
List<DeviceEnrolment> getAllEnrolmentDevices();
|
||||
|
||||
DeviceEnrolment getDeviceEnrolmentById(String imei);
|
||||
|
||||
String deleteDeviceEnrolment(String imei);
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.service.impl;
|
||||
|
||||
import com.example.Public.Configuration.dao.DeviceConfigDao;
|
||||
import com.example.Public.Configuration.model.DeviceConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeviceConfigServiceImpl {
|
||||
|
||||
@Autowired
|
||||
private DeviceConfigDao deviceConfigDao; //autowire the deviceDao object
|
||||
|
||||
public void saveConfigDetails(DeviceConfig deviceConfig) { //used to save the device details in the database
|
||||
deviceConfigDao.save(deviceConfig);
|
||||
}
|
||||
|
||||
public List<DeviceConfig> getAllDeviceConfigs() {
|
||||
return deviceConfigDao.findAll(); // use to command using the deviceDao object to get all the device details from the database
|
||||
}
|
||||
|
||||
public DeviceConfig getDeviceConfigById(String config_id) {
|
||||
return deviceConfigDao.findByConfigId(config_id); // use to get the device details by id
|
||||
}
|
||||
|
||||
public DeviceConfig UpdateConfigDetails(DeviceConfig deviceConfig) { //used to update the device details in the database
|
||||
DeviceConfig updatedConfig = deviceConfigDao.findByConfigId(deviceConfig.getConfigId());// get the device details by id
|
||||
if (updatedConfig != null) { // device details are present in the database then update the device details
|
||||
updatedConfig.setConfigProfile(deviceConfig.getConfigProfile());
|
||||
deviceConfigDao.save(updatedConfig);
|
||||
}
|
||||
return updatedConfig; // return the updated device object
|
||||
}
|
||||
|
||||
public String deleteConfigDevice(String configId) {//used to delete the device details from the database
|
||||
deviceConfigDao.deleteByConfigId(configId);//delete the device details by id
|
||||
return "deleted" + configId;//return the message that the device is deleted
|
||||
}
|
||||
|
||||
}
|
@ -1,73 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.service.impl;
|
||||
|
||||
import com.example.Public.Configuration.dao.DeviceDao;
|
||||
import com.example.Public.Configuration.model.Device;
|
||||
import com.example.Public.Configuration.service.DeviceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
public class DeviceServiceImpl {
|
||||
|
||||
@Autowired
|
||||
private DeviceDao deviceDao;
|
||||
private DeviceDao deviceDao; //autowire the deviceDao object
|
||||
|
||||
public Device saveDevice(Device device) {
|
||||
return deviceDao.save(device);
|
||||
public void saveDetails(Device device) { //used to save the device details in the database
|
||||
deviceDao.save(device);
|
||||
}
|
||||
|
||||
public List<Device> getAllDevices() {
|
||||
return deviceDao.findAll();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDeviceById(long device_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device updateDevice(Device device) {
|
||||
return null;
|
||||
return deviceDao.findAll(); // use to command using
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deleteDevice(long device_id) {
|
||||
return "";
|
||||
public Device getDeviceById(int id) {
|
||||
return deviceDao.findById(id).orElse(null); // use to get the device details by id
|
||||
}
|
||||
|
||||
public Device getDeviceById(Long device_id) {
|
||||
return deviceDao.findById(device_id).orElse(null);
|
||||
}
|
||||
public Device UpdateDevice(Device device) { //used to update the device details in the database
|
||||
public Device UpdateDetails(Device device) { //used to update the device details in the database
|
||||
Device updatedDevice = deviceDao.findById(device.getDevice_id()).orElse(null); //This command is used to get the device details by id
|
||||
|
||||
if (updatedDevice != null) { // device details are present in the database then update the device details
|
||||
updatedDevice.setImei(device.getImei());
|
||||
updatedDevice.setDevice_id(device.getDevice_id());
|
||||
updatedDevice.setDevice_model(device.getDevice_model());
|
||||
updatedDevice.setUpdate_time(device.getUpdate_time());
|
||||
updatedDevice.setNetwork(device.getNetwork());
|
||||
updatedDevice.setMFW_Version(device.getMFW_Version());
|
||||
updatedDevice.setLAC(device.getLAC());
|
||||
updatedDevice.setDevice_organization(device.getDevice_organization());
|
||||
updatedDevice.setMEFW_Version(device.getMEFW_Version());
|
||||
updatedDevice.setRSSI(device.getRSSI());
|
||||
deviceDao.save(updatedDevice);
|
||||
}
|
||||
return updatedDevice;
|
||||
}
|
||||
public String deleteDevice(Long device_id) {
|
||||
deviceDao.deleteById(device_id);
|
||||
return "deleted " +device_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return updatedDevice; // return the updated device object
|
||||
}
|
||||
|
||||
public String deleteDevice(int id) {//used to delete the device details from the database
|
||||
deviceDao.deleteById(id);//delete the device details by id
|
||||
return "deleted" + id;//return the message that the device is deleted
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2018 - 2024 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
|
||||
*
|
||||
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
|
||||
*
|
||||
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://entgra.io/licenses/entgra-commercial/1.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.example.Public.Configuration.service.impl;
|
||||
|
||||
import com.example.Public.Configuration.dao.EnrolmentRequestLogDao;
|
||||
import com.example.Public.Configuration.model.EnrolmentRequestLog;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class EnrolmentRequestServiceImpl {
|
||||
|
||||
@Autowired
|
||||
private EnrolmentRequestLogDao enrolmentRequestLogDao;
|
||||
|
||||
public void saveEnrolmentRequest(EnrolmentRequestLog enrolmentRequestLog) {
|
||||
enrolmentRequestLogDao.save(enrolmentRequestLog);
|
||||
}
|
||||
|
||||
public List<EnrolmentRequestLog> getAllEnrolmentRequests() {
|
||||
return enrolmentRequestLogDao.findAll();
|
||||
}
|
||||
|
||||
public EnrolmentRequestLog getByEnrolmentRequestId(String imei) {
|
||||
return enrolmentRequestLogDao.findByImei(imei);
|
||||
}
|
||||
public String deleteByEnrolmentRequestId(String imei) {
|
||||
enrolmentRequestLogDao.deleteByImei(imei);
|
||||
return "deleted" +imei;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue