adding base Project
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package com.realnet.Connector.Controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.Connector.Entity.Connector;
|
||||
import com.realnet.Connector.Repository.Connectorrepository;
|
||||
import com.realnet.users.entity.Sys_Accounts;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/connector")
|
||||
public class ConnectorController {
|
||||
|
||||
@Autowired
|
||||
private Connectorrepository connectorrepository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
|
||||
//ADD DATA
|
||||
@PostMapping("/Connectorjson")
|
||||
public ResponseEntity<?> save(@RequestBody Connector connector) {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||
connector.setAccountId(account_id);
|
||||
Connector save = connectorrepository.save(connector);
|
||||
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
//UPDATE BY ID
|
||||
@PutMapping("/Connectorjson/{id}")
|
||||
public ResponseEntity<?> update(@PathVariable Long id, @RequestBody Connector connector) {
|
||||
Connector con = connectorrepository.findById(id).orElseThrow(null);
|
||||
con.setName(connector.getName());
|
||||
con.setConnector_json(connector.getConnector_json());
|
||||
|
||||
Connector save = connectorrepository.save(con);
|
||||
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
//GET ALL
|
||||
@GetMapping("/Connectorjson")
|
||||
public ResponseEntity<?> getall() {
|
||||
List<Connector> save = connectorrepository.findAll();
|
||||
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
//GET BY ID
|
||||
@GetMapping("/Connectorjson/{id}")
|
||||
public ResponseEntity<?> getbyid(@PathVariable Long id) {
|
||||
Connector con = connectorrepository.findById(id).orElseThrow(null);
|
||||
return new ResponseEntity<>(con, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
//DELETE BY ID
|
||||
@DeleteMapping("/Connectorjson/{id}")
|
||||
public void delete(@PathVariable Long id){
|
||||
Connector con = connectorrepository.findById(id).orElseThrow(null);
|
||||
connectorrepository.delete(con);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.realnet.Connector.Controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.realnet.Connector.Entity.Connector;
|
||||
import com.realnet.Connector.Entity.Mapping;
|
||||
import com.realnet.Connector.Repository.Connectorrepository;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/token/connector/mapping")
|
||||
public class MappingController {
|
||||
|
||||
@Autowired
|
||||
private Connectorrepository connectorrepository;
|
||||
|
||||
@PostMapping("/mapping")
|
||||
public Object connector(@RequestBody Mapping mapping) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
|
||||
// Map<String> param = new HashMap<String>();
|
||||
String str = mapping.getMappingString();
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement element = parser.parse(str);
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
// get key from get api
|
||||
Set<Map.Entry<String, JsonElement>> entries = obj.entrySet();
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
|
||||
String key = entry.getKey();
|
||||
String string = key.toString();
|
||||
list.add(string);
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/mapping1")
|
||||
public Object connector1(@RequestBody Mapping mapping) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
|
||||
// Map<String> param = new HashMap<String>();
|
||||
String str = mapping.getMappingString();
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement element = parser.parse(str);
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
// get values from get api
|
||||
Set<Map.Entry<String, JsonElement>> entries = obj.entrySet();
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
|
||||
String string2 = entry.getValue().getAsString();
|
||||
list.add(string2);
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/mapping2")
|
||||
public Object getvalue(@RequestBody Mapping mapping) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
|
||||
// Map<String> param = new HashMap<String>();
|
||||
String str = mapping.getMappingString();
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement element = parser.parse(str);
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
// get values from get api
|
||||
Set<Map.Entry<String, JsonElement>> entries = obj.entrySet();
|
||||
for (Map.Entry<String, JsonElement> entry : entries) {
|
||||
|
||||
String string2 = entry.getValue().getAsString();
|
||||
list.add(string2);
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
// get api for call connector by name for job(by gk)
|
||||
@GetMapping("/connectorname/{name}")
|
||||
public ResponseEntity<?> getconnector(@PathVariable String name) {
|
||||
Connector save = connectorrepository.findconnectorbyname(name);
|
||||
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.realnet.Connector.Entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Column;
|
||||
|
||||
import com.realnet.Dashboard1.Entity.dashbord_Who_collumn;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Connector extends dashbord_Who_collumn {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
@Column(length = 15000)
|
||||
private String get_str;
|
||||
@Lob
|
||||
private String connector_json;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.realnet.Connector.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Mapping {
|
||||
|
||||
private String mappingString;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.realnet.Connector.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Connector.Entity.Connector;
|
||||
@Repository
|
||||
public interface Connectorrepository extends JpaRepository<Connector, Long>{
|
||||
|
||||
|
||||
@Query(value = "select * from connector where name=?1", nativeQuery = true)
|
||||
Connector findconnectorbyname(String name);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user