sureconnect
This commit is contained in:
parent
301da36697
commit
fd5945b464
@ -9,7 +9,7 @@ import com.realnet.Builders.Entity.Builder_entity_t;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface BuilderRepository extends JpaRepository<Builder_entity_t, Long> {
|
public interface BuilderRepository extends JpaRepository<Builder_entity_t, Long> {
|
||||||
|
|
||||||
@Query(value = "select * from builder_entity_t where job_name= ?1 && job_type=?2", nativeQuery = true)
|
@Query(value = "select * from builder_entity_t where job_name= ?1 AND job_type=?2", nativeQuery = true)
|
||||||
Builder_entity_t findByjobTypeAndName(String job_name, String job_type);
|
Builder_entity_t findByjobTypeAndName(String job_name, String job_type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,130 @@
|
|||||||
|
package com.realnet.Builders.Services;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SqlDumpExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a massive SQL dump safely.
|
||||||
|
*
|
||||||
|
* @param connection JDBC connection
|
||||||
|
* @param sqlDump Full SQL dump string from getSql()
|
||||||
|
*/
|
||||||
|
public void executeDump(Connection connection, String sqlDump) {
|
||||||
|
Statement stmt = null;
|
||||||
|
try {
|
||||||
|
stmt = connection.createStatement();
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
|
// Remove MySQL backticks
|
||||||
|
sqlDump = sqlDump.replaceAll("`", "");
|
||||||
|
|
||||||
|
// Remove table-level DEFAULT COLLATE or CHARSET
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)DEFAULT\\s+CHARSET=[^;\\n]+", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)COLLATE=[^;\\n]+", "");
|
||||||
|
|
||||||
|
// Convert data types
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)bigint", "INTEGER");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)int\\([0-9]+\\)", "INTEGER");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)varchar\\([0-9]+\\)", "TEXT");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)bit\\([0-9]+\\)", "INTEGER");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)longblob", "BLOB");
|
||||||
|
|
||||||
|
// Remove AUTO_INCREMENT (if any)
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)AUTO_INCREMENT", "");
|
||||||
|
|
||||||
|
// Remove MySQL-specific directives
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)SET\\s+[^;]+;", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)ENGINE=\\w+\\s*", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)AUTO_INCREMENT=\\d+", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)CHARSET=\\w+", "");
|
||||||
|
|
||||||
|
// Remove DEFAULT NULL (SQLite allows NULL by default)
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)DEFAULT NULL", "");
|
||||||
|
|
||||||
|
// Convert UNIQUE KEY <name> to UNIQUE
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)UNIQUE KEY [^\\(]+\\(", "UNIQUE(");
|
||||||
|
|
||||||
|
// Remove double commas in CREATE TABLE (,,)
|
||||||
|
sqlDump = sqlDump.replaceAll(",\\s*,", ",");
|
||||||
|
|
||||||
|
// Remove _binary prefix in INSERT statements
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)_binary\\s+'", "'");
|
||||||
|
|
||||||
|
String delimiter = ";"; // default delimiter
|
||||||
|
StringBuilder sqlStatement = new StringBuilder();
|
||||||
|
|
||||||
|
String[] lines = sqlDump.split("\\r?\\n");
|
||||||
|
for (String line : lines) {
|
||||||
|
line = line.trim();
|
||||||
|
|
||||||
|
// Skip empty lines and comments
|
||||||
|
if (line.isEmpty() || line.startsWith("--") || line.startsWith("//") || line.startsWith("/*")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect DELIMITER changes (optional, mostly MySQL)
|
||||||
|
if (line.startsWith("DELIMITER ")) {
|
||||||
|
delimiter = line.substring("DELIMITER ".length()).trim();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove MySQL-specific comments like /*! ... */
|
||||||
|
line = line.replaceAll("/\\*!.*?\\*/", "").trim();
|
||||||
|
if (line.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sqlStatement.append(line).append(" ");
|
||||||
|
|
||||||
|
// Check if statement ends with current delimiter
|
||||||
|
if (sqlStatement.toString().trim().endsWith(delimiter)) {
|
||||||
|
String finalSql = sqlStatement.toString().trim();
|
||||||
|
|
||||||
|
// Remove the delimiter from the end
|
||||||
|
if (delimiter.length() > 0 && finalSql.endsWith(delimiter)) {
|
||||||
|
finalSql = finalSql.substring(0, finalSql.length() - delimiter.length()).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
stmt.execute(finalSql);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println("Failed SQL: " + finalSql);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlStatement.setLength(0); // reset for next statement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.commit();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error executing SQL dump: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
try {
|
||||||
|
connection.rollback();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println("Rollback failed: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (stmt != null) {
|
||||||
|
try {
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package com.realnet.SureConnect.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.RestController;
|
||||||
|
import com.realnet.SureConnect.Entities.Sure_Connect;
|
||||||
|
import com.realnet.SureConnect.Service.SureService;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class SureController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureService sureService;
|
||||||
|
|
||||||
|
// CREATE DATA
|
||||||
|
@PostMapping("/Sure_Connect")
|
||||||
|
public ResponseEntity<?> add(@RequestBody Sure_Connect sure_Connect) {
|
||||||
|
Sure_Connect order = sureService.create(sure_Connect);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(order, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// update data
|
||||||
|
@PutMapping("/Sure_Connect/{id}")
|
||||||
|
public ResponseEntity<?> update(@RequestBody Sure_Connect sure_Connect, @PathVariable Integer id) {
|
||||||
|
|
||||||
|
Sure_Connect order = sureService.update(sure_Connect, id);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(order, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all
|
||||||
|
@GetMapping("/Sure_Connect")
|
||||||
|
public ResponseEntity<?> getall() {
|
||||||
|
List<Sure_Connect> pm = sureService.getall();
|
||||||
|
return new ResponseEntity<>(pm, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get by id
|
||||||
|
@GetMapping("/Sure_Connect/{id}")
|
||||||
|
public ResponseEntity<?> getbyid(@PathVariable int id) {
|
||||||
|
Sure_Connect pm = sureService.getbyid(id);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(pm, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete by id
|
||||||
|
@DeleteMapping("/Sure_Connect/{id}")
|
||||||
|
public ResponseEntity<?> deleteOne(@PathVariable int id) {
|
||||||
|
|
||||||
|
sureService.deletebyid(id);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get by name
|
||||||
|
@GetMapping("/token/Sure_Connectbyname/{connection_name}")
|
||||||
|
public ResponseEntity<?> getbyname(@PathVariable String connection_name) {
|
||||||
|
Sure_Connect pm = sureService.getbyname(connection_name);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(pm, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,140 @@
|
|||||||
|
package com.realnet.SureConnect.Controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
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.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sure_connect/sure_postman")
|
||||||
|
public class Sure_Postman_Api {
|
||||||
|
|
||||||
|
Logger log = org.slf4j.LoggerFactory.getLogger(Sure_Postman_Api.class);
|
||||||
|
|
||||||
|
@PostMapping("/call_api")
|
||||||
|
public ResponseEntity<?> calldifferentmethod(@RequestBody String json_body,
|
||||||
|
@RequestParam String api_url,
|
||||||
|
//@RequestParam String json_body,
|
||||||
|
@RequestParam String method, @RequestParam String token) {
|
||||||
|
|
||||||
|
|
||||||
|
log.info("executing no json_bodyeters");
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("DELETE")) {
|
||||||
|
Object body = DELETE(api_url,token);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(body, HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
Object object = callmethod(api_url, json_body, method, token);
|
||||||
|
|
||||||
|
System.out.println(object);
|
||||||
|
return new ResponseEntity<>(object, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CALL METHOD
|
||||||
|
public Object callmethod(String urll, String json_body, String method, String token) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("GET")) {
|
||||||
|
ResponseEntity<Object> get = GET(urll,token);
|
||||||
|
Object body = get.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
return get.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (method.equalsIgnoreCase("POST")) {
|
||||||
|
ResponseEntity<Object> post = POST(urll, json_body, token);
|
||||||
|
Object body = post.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return post.getBody();
|
||||||
|
|
||||||
|
} else if (method.equalsIgnoreCase("PUT")) {
|
||||||
|
ResponseEntity<Object> put = PUT(urll, json_body, token);
|
||||||
|
Object body = put.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return put.getBody();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private HttpHeaders getHeaders() {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> GET(String url,String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = url;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>( headers);
|
||||||
|
// ResponseEntity<Object> u = restTemplate.getForEntity(url, Object.class);
|
||||||
|
ResponseEntity<Object> u = restTemplate.exchange(resourceUrl, HttpMethod.GET, request, Object.class);
|
||||||
|
|
||||||
|
return u;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> POST(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
ResponseEntity<Object> res = restTemplate.postForEntity(resourceUrl, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> PUT(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
// ResponseEntity<Object> res = restTemplate.put(resourceUrl, request, Object.class);
|
||||||
|
ResponseEntity<Object> res = restTemplate.exchange(resourceUrl, HttpMethod.PUT, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object DELETE(String url, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = url;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(headers);
|
||||||
|
// ResponseEntity<Object> u = restTemplate.getForEntity(url, Object.class);
|
||||||
|
ResponseEntity<Object> u = restTemplate.exchange(resourceUrl, HttpMethod.DELETE, request, Object.class);
|
||||||
|
return u;
|
||||||
|
// restTemplate.delete(url, Object.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.realnet.SureConnect.Entities;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Sure_Connect {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy =GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String connection_name;
|
||||||
|
|
||||||
|
@Column(length = 10000)
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
private String access_token;
|
||||||
|
private int client_id;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.realnet.SureConnect.Repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.SureConnect.Entities.Sure_Connect;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface SureRepository extends JpaRepository<Sure_Connect, Integer>{
|
||||||
|
|
||||||
|
Sure_Connect findById(int id);
|
||||||
|
|
||||||
|
@Query(value = "select * from sure_connect where connection_name=?1 ", nativeQuery = true)
|
||||||
|
Sure_Connect findByConnection_name(String connection_name);
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.realnet.SureConnect.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.realnet.SureConnect.Entities.Sure_Connect;
|
||||||
|
import com.realnet.SureConnect.Repository.SureRepository;
|
||||||
|
import com.realnet.exceptions.ResourceNotFoundException;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SureService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureRepository sureRepository;
|
||||||
|
|
||||||
|
public Sure_Connect create(Sure_Connect sure_Connect) {
|
||||||
|
return sureRepository.save(sure_Connect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Sure_Connect> getall() {
|
||||||
|
return (List<Sure_Connect>) sureRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sure_Connect getbyid(int id) {
|
||||||
|
return sureRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sure_Connect getbyname(String connection_name) {
|
||||||
|
return sureRepository.findByConnection_name(connection_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sure_Connect update(Sure_Connect sure, int id) {
|
||||||
|
Sure_Connect pm = sureRepository.findById(id);
|
||||||
|
// .orElseThrow(()->new ResourceNotFoundException("not found"));
|
||||||
|
|
||||||
|
pm.setAccess_token(sure.getAccess_token());
|
||||||
|
pm.setClient_id(sure.getClient_id());
|
||||||
|
pm.setConnection_name(sure.getConnection_name());
|
||||||
|
pm.setDescription(sure.getDescription());
|
||||||
|
pm.setPassword(sure.getPassword());
|
||||||
|
pm.setType(sure.getType());
|
||||||
|
pm.setUsername(sure.getUsername());
|
||||||
|
return sureRepository.save(pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void deletebyid(int id) {
|
||||||
|
sureRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
//package com.realnet.config.sqlite;
|
||||||
|
//
|
||||||
|
//import java.sql.Types;
|
||||||
|
//import org.hibernate.dialect.Dialect;
|
||||||
|
//import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
|
//
|
||||||
|
//public class SQLiteDialect extends Dialect {
|
||||||
|
//
|
||||||
|
// public SQLiteDialect() {
|
||||||
|
// registerColumnType(Types.INTEGER, "integer");
|
||||||
|
// registerColumnType(Types.VARCHAR, "text");
|
||||||
|
// registerColumnType(Types.BLOB, "blob");
|
||||||
|
// registerColumnType(Types.REAL, "real");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
|
// return new SQLiteIdentityColumnSupport();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean hasAlterTable() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean dropConstraints() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// @Override
|
||||||
|
// public boolean supportsUnionAll() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
//package com.realnet.config.sqlite;
|
||||||
|
//
|
||||||
|
//import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
|
||||||
|
//
|
||||||
|
//public class SQLiteIdentityColumnSupport extends IdentityColumnSupportImpl {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean supportsIdentityColumns() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getIdentitySelectString(String table, String column, int type) {
|
||||||
|
// return "select last_insert_rowid()";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getIdentityColumnString(int type) {
|
||||||
|
// // SQLite mein sirf "integer" + auto increment hota hai
|
||||||
|
// return "integer";
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
//package com.realnet.config.sqlite;
|
||||||
|
//
|
||||||
|
//import java.sql.Connection;
|
||||||
|
//import java.sql.DriverManager;
|
||||||
|
//import java.sql.SQLException;
|
||||||
|
//
|
||||||
|
//public class SQLiteUtil {
|
||||||
|
//
|
||||||
|
// private static final String DB_FILE = "realtest1.db"; // SQLite file
|
||||||
|
//
|
||||||
|
// public static Connection getConnection() throws SQLException {
|
||||||
|
// String url = "jdbc:sqlite:" + DB_FILE;
|
||||||
|
// return DriverManager.getConnection(url);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -1,28 +1,16 @@
|
|||||||
package com.realnet.fnd.entity1;
|
package com.realnet.fnd.entity1;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
|
||||||
import javax.persistence.TemporalType;
|
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
|
||||||
import org.springframework.data.annotation.LastModifiedDate;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|||||||
222
backend/src/main/java/com/realnet/helper/CnsHelper.java
Normal file
222
backend/src/main/java/com/realnet/helper/CnsHelper.java
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
package com.realnet.helper;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.realnet.utils.Port_Constant;
|
||||||
|
|
||||||
|
public class CnsHelper {
|
||||||
|
|
||||||
|
static Logger log = org.slf4j.LoggerFactory.getLogger(CnsHelper.class);
|
||||||
|
|
||||||
|
// CONNECTOR CALL
|
||||||
|
public static String callconnector(String name) throws JsonProcessingException {
|
||||||
|
|
||||||
|
String token = null;
|
||||||
|
ResponseEntity<Object> u = null;
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String url = Port_Constant.BACKEND_PORTAL_DOMAIN + "/token/Sure_Connectbyname/" + name;
|
||||||
|
|
||||||
|
//
|
||||||
|
try {
|
||||||
|
|
||||||
|
u = restTemplate.getForEntity(url, Object.class);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
System.out.println(" token get error " + e);
|
||||||
|
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
Object object = u.getBody();
|
||||||
|
|
||||||
|
if (object != null) {
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String str = mapper.writeValueAsString(object);
|
||||||
|
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonElement element = parser.parse(str);
|
||||||
|
|
||||||
|
JsonObject obj = element.getAsJsonObject();
|
||||||
|
JsonElement tok = obj.get("access_token");
|
||||||
|
System.out.println("token is == " + token);
|
||||||
|
token = tok.getAsString();
|
||||||
|
} else {
|
||||||
|
System.out.println(" empty totek get ...");
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<?> run(String urll, String param, String method, String token, String username,
|
||||||
|
String password) {
|
||||||
|
|
||||||
|
log.info("executing no parameters");
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("DELETE")) {
|
||||||
|
Object body = DELETE(urll);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(body, HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
Object object = callmethod(urll, param, method, token, username, password);
|
||||||
|
|
||||||
|
System.out.println(object);
|
||||||
|
return new ResponseEntity<>(object, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean DELETE(String url) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
restTemplate.delete(url, Object.class);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// CALL METHOD
|
||||||
|
public static Object callmethod(String url, String param, String method, String token, String username,
|
||||||
|
String password) {
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("GET")) {
|
||||||
|
ResponseEntity<Object> get = GET(url);
|
||||||
|
Object body = get.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
return get.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (method.equalsIgnoreCase("POST")) {
|
||||||
|
|
||||||
|
ResponseEntity<Object> post;
|
||||||
|
if (username != null && password != null) {
|
||||||
|
post = POSTForBasicAuth(url, param, username, password);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
post = POST(url, param, token);
|
||||||
|
}
|
||||||
|
Object body = post.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return post.getBody();
|
||||||
|
|
||||||
|
} else if (method.equalsIgnoreCase("PUT")) {
|
||||||
|
ResponseEntity<Object> put = PUT(url, param, token);
|
||||||
|
Object body = put.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return put.getBody();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> GET(String get) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
ResponseEntity<Object> u = restTemplate.getForEntity(get, Object.class);
|
||||||
|
int statusCodeValue = u.getStatusCodeValue();
|
||||||
|
System.out.println(statusCodeValue);
|
||||||
|
|
||||||
|
return u;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> GET(String get, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = get;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(headers);
|
||||||
|
ResponseEntity<Object> u = restTemplate.exchange(resourceUrl, HttpMethod.GET, request, Object.class);
|
||||||
|
|
||||||
|
int statusCodeValue = u.getStatusCodeValue();
|
||||||
|
System.out.println(statusCodeValue);
|
||||||
|
|
||||||
|
return u;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> POST(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
ResponseEntity<Object> res = restTemplate.postForEntity(resourceUrl, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> POSTForBasicAuth(String jobinfo, Object user, String username,
|
||||||
|
String password) {
|
||||||
|
|
||||||
|
System.out.println(" call basic auth..");
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
|
||||||
|
String auth = username + ":" + password;
|
||||||
|
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.US_ASCII));
|
||||||
|
String authHeader = "Basic " + new String(encodedAuth);
|
||||||
|
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
|
||||||
|
headers.set("Authorization", authHeader);
|
||||||
|
|
||||||
|
HttpEntity<Object> request = new HttpEntity<>(user.toString(), headers);
|
||||||
|
ResponseEntity<Object> res = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
res = restTemplate.postForEntity(resourceUrl, request, Object.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
System.out.println(" call basic auth error " + e);
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> PUT(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
// ResponseEntity<Object> res = restTemplate.put(resourceUrl, request, Object.class);
|
||||||
|
ResponseEntity<Object> res = restTemplate.exchange(resourceUrl, HttpMethod.PUT, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpHeaders getHeaders() {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -59,6 +59,7 @@ import com.realnet.users.entity.LoginUser;
|
|||||||
import com.realnet.users.entity.Role;
|
import com.realnet.users.entity.Role;
|
||||||
import com.realnet.users.entity.Sys_Accounts;
|
import com.realnet.users.entity.Sys_Accounts;
|
||||||
import com.realnet.users.entity1.AppUser;
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.entity1.AppUserRole;
|
||||||
import com.realnet.users.entity1.AppUserSessions;
|
import com.realnet.users.entity1.AppUserSessions;
|
||||||
import com.realnet.users.entity1.Registration;
|
import com.realnet.users.entity1.Registration;
|
||||||
import com.realnet.users.response.MessageResponse;
|
import com.realnet.users.response.MessageResponse;
|
||||||
@ -156,11 +157,13 @@ public class SessionController {
|
|||||||
|
|
||||||
AppUser loggedInUser = userService.getLoggedInUser();
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
MDC.put("USER", loggedInUser.getUsername());
|
MDC.put("USER", loggedInUser.getUsername());
|
||||||
|
AppUserRole usrGrp = loggedInUser.getUsrGrp();
|
||||||
|
String groupName = usrGrp.getGroupName();
|
||||||
// System.out.println("/session logged in user -> " + loggedInUser);
|
// System.out.println("/session logged in user -> " + loggedInUser);
|
||||||
|
|
||||||
// List<String> loggedInUserRoles = new ArrayList<String>();
|
// List<String> loggedInUserRoles = new ArrayList<String>();
|
||||||
StringBuilder roleString = new StringBuilder();
|
StringBuilder roleString = new StringBuilder();
|
||||||
roleString.append(loggedInUser.getUsrGrp().getGroupName());
|
roleString.append(groupName);
|
||||||
// .forEach(role -> {
|
// .forEach(role -> {
|
||||||
//// loggedInUserRoles.add(role.getName());
|
//// loggedInUserRoles.add(role.getName());
|
||||||
// roleString.append(role.getName() + ", ");
|
// roleString.append(role.getName() + ", ");
|
||||||
|
|||||||
@ -104,6 +104,21 @@ public class AppUserController {
|
|||||||
return new ResponseEntity<>("User not found", HttpStatus.OK);
|
return new ResponseEntity<>("User not found", HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set iser active inactive
|
||||||
|
@GetMapping("/getOneAppUser/active/{id}")
|
||||||
|
public ResponseEntity<?> getOneAppUser(@PathVariable("id") Long id, @RequestParam Boolean active) {
|
||||||
|
Optional<AppUser> a = appUserServiceImpl.getOneUser(id);
|
||||||
|
|
||||||
|
if (a.get() != null) {
|
||||||
|
a.get().setActive(active);
|
||||||
|
|
||||||
|
boolean insertOrSaveUser = appUserServiceImpl.insertOrSaveUser(a.get());
|
||||||
|
|
||||||
|
return new ResponseEntity<>(a.get(), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>("User not found", HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/addOneAppUser")
|
@PostMapping("/addOneAppUser")
|
||||||
public ResponseEntity<?> addOneUser(@RequestBody Registration reg) {
|
public ResponseEntity<?> addOneUser(@RequestBody Registration reg) {
|
||||||
if (appUserRepository.findByEmail(reg.getEmail()) != null) {
|
if (appUserRepository.findByEmail(reg.getEmail()) != null) {
|
||||||
|
|||||||
@ -5,7 +5,9 @@ import java.util.List;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -14,6 +16,7 @@ import com.realnet.session.entity.AboutWork;
|
|||||||
import com.realnet.users.entity.Sys_Accounts;
|
import com.realnet.users.entity.Sys_Accounts;
|
||||||
import com.realnet.users.repository.AboutWorkRepo;
|
import com.realnet.users.repository.AboutWorkRepo;
|
||||||
import com.realnet.users.repository.SysAccountRepo;
|
import com.realnet.users.repository.SysAccountRepo;
|
||||||
|
import com.realnet.users.service1.SysAccountService;
|
||||||
|
|
||||||
@RequestMapping("/token/users/sysaccount")
|
@RequestMapping("/token/users/sysaccount")
|
||||||
@RestController
|
@RestController
|
||||||
@ -25,9 +28,20 @@ public class SysAccountController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AboutWorkRepo aboutWorkRepo;
|
private AboutWorkRepo aboutWorkRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysAccountService accountService;
|
||||||
|
|
||||||
@PostMapping("/savesysaccount")
|
@PostMapping("/savesysaccount")
|
||||||
public Sys_Accounts save(@RequestBody Sys_Accounts sys_Accounts) {
|
public Sys_Accounts save(@RequestBody Sys_Accounts sys_Accounts) {
|
||||||
Sys_Accounts save = sysAccountRepo.save(sys_Accounts);
|
Sys_Accounts save = accountService.save(sys_Accounts);
|
||||||
|
|
||||||
|
System.out.println("created account data is .." + save);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/savesysaccount/{accId}")
|
||||||
|
public Sys_Accounts updte(@PathVariable Long accId, @RequestBody Sys_Accounts sys_Accounts) {
|
||||||
|
Sys_Accounts save = accountService.update(accId, sys_Accounts);
|
||||||
|
|
||||||
System.out.println("created account data is .." + save);
|
System.out.println("created account data is .." + save);
|
||||||
return save;
|
return save;
|
||||||
|
|||||||
@ -113,7 +113,7 @@ public class AppUser implements Serializable {
|
|||||||
private String password4;
|
private String password4;
|
||||||
private Long pwdChangedCnt;
|
private Long pwdChangedCnt;
|
||||||
private Date lastPwdChangedDate;
|
private Date lastPwdChangedDate;
|
||||||
private Blob photo;
|
// private Blob photo;
|
||||||
private String photoName;
|
private String photoName;
|
||||||
|
|
||||||
private String provider;
|
private String provider;
|
||||||
@ -157,7 +157,7 @@ public class AppUser implements Serializable {
|
|||||||
@Transient
|
@Transient
|
||||||
private StringBuilder totalLogInfo;
|
private StringBuilder totalLogInfo;
|
||||||
|
|
||||||
private String tshirtsize;
|
// private String tshirtsize;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@ -392,9 +392,9 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
|||||||
a.setNotification(
|
a.setNotification(
|
||||||
appUserDto.getNotification() != null ? appUserDto.getNotification() : a.getNotification());
|
appUserDto.getNotification() != null ? appUserDto.getNotification() : a.getNotification());
|
||||||
|
|
||||||
if (appUserDto.getTshirtsize() != null) {
|
// if (appUserDto.getTshirtsize() != null) {
|
||||||
a.setTshirtsize(appUserDto.getTshirtsize());
|
// a.setTshirtsize(appUserDto.getTshirtsize());
|
||||||
}
|
// }
|
||||||
a.setMob_no(appUserDto.getMob_no());
|
a.setMob_no(appUserDto.getMob_no());
|
||||||
a.setActive(appUserDto.isActive());
|
a.setActive(appUserDto.isActive());
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
|||||||
AppUser save = appUserRepository.save(a);
|
AppUser save = appUserRepository.save(a);
|
||||||
System.out.println("Password changed Successfully.. ");
|
System.out.println("Password changed Successfully.. ");
|
||||||
|
|
||||||
return new ResponseEntity<>(save, HttpStatus.ACCEPTED);
|
return new ResponseEntity<>("Password changed Successfully", HttpStatus.ACCEPTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
|
||||||
import com.realnet.users.entity.Sys_Accounts;
|
import com.realnet.users.entity.Sys_Accounts;
|
||||||
import com.realnet.users.repository.SysAccountRepo;
|
import com.realnet.users.repository.SysAccountRepo;
|
||||||
|
|
||||||
@ -15,12 +16,64 @@ public class SysAccountService {
|
|||||||
private SysAccountRepo sysAccountRepo;
|
private SysAccountRepo sysAccountRepo;
|
||||||
|
|
||||||
public Sys_Accounts save(Sys_Accounts sys) {
|
public Sys_Accounts save(Sys_Accounts sys) {
|
||||||
|
|
||||||
|
Sys_Accounts account = findByEmail(sys.getEmail());
|
||||||
|
if (account != null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sys.setActive(true);
|
||||||
Sys_Accounts accounts = sysAccountRepo.save(sys);
|
Sys_Accounts accounts = sysAccountRepo.save(sys);
|
||||||
|
|
||||||
return accounts;
|
return accounts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update sysaccount
|
||||||
|
|
||||||
|
public Sys_Accounts update(Long accountId, Sys_Accounts request) {
|
||||||
|
|
||||||
|
Sys_Accounts account = sysAccountRepo.findById(accountId).get();
|
||||||
|
// account_id generally auto-generated hai, update me change nahi karenge
|
||||||
|
|
||||||
|
if (request.getCompanyName() != null) {
|
||||||
|
account.setCompanyName(request.getCompanyName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getWorkspace() != null) {
|
||||||
|
account.setWorkspace(request.getWorkspace());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getGstNumber() != null) {
|
||||||
|
account.setGstNumber(request.getGstNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getMobile() != null) {
|
||||||
|
account.setMobile(request.getMobile());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getEmail() != null) {
|
||||||
|
account.setEmail(request.getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getPancard() != null) {
|
||||||
|
account.setPancard(request.getPancard());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getWorking() != null) {
|
||||||
|
account.setWorking(request.getWorking());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getActive() != null) {
|
||||||
|
account.setActive(request.getActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
Sys_Accounts save = sysAccountRepo.save(account);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<Sys_Accounts> getall() {
|
public List<Sys_Accounts> getall() {
|
||||||
|
|
||||||
List<Sys_Accounts> getall = sysAccountRepo.findAll();
|
List<Sys_Accounts> getall = sysAccountRepo.findAll();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user