feat: initialize backend Spring Boot application structure and components
This commit is contained in:
@@ -137,7 +137,7 @@
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/commons-io/commons-io/2.7/commons-io-2.7.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/net/lingala/zip4j/zip4j/2.6.1/zip4j-2.6.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/json/json/20201115/json-20201115.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.20/lombok-1.18.20.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-devtools/2.2.5.RELEASE/spring-boot-devtools-2.2.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar" enabled="true" runInBatchMode="false"/>
|
||||
|
||||
@@ -51,3 +51,6 @@
|
||||
2024-01-19T14:14:02.474+0530 ERROR Login Failed No value present
|
||||
2024-01-19T14:14:03.357+0530 ERROR Login Failed No value present
|
||||
2026-10-22T16:02:27.789+0530 ERROR Login Failed Cannot invoke "com.realnet.users.entity.Role.getName()" because "role" is null
|
||||
2026-11-03T22:44:08.881+0530 ERROR Login Failed Bad credentials
|
||||
2026-11-03T22:45:04.751+0530 ERROR Login Failed ac-4fqaq2v-shard-00-01.u9a6g8k.mongodb.net; nested exception is com.mongodb.MongoSocketException: ac-4fqaq2v-shard-00-01.u9a6g8k.mongodb.net
|
||||
2026-11-03T22:45:46.935+0530 ERROR Login Failed Query { "$java" : Query: { "username" : "sysadmin"}, Fields: {}, Sort: {} } returned non unique result.
|
||||
|
||||
+1
-1
@@ -290,7 +290,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.realnet.Accesstype_back.Controllers;
|
||||
|
||||
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.CrossOrigin;
|
||||
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.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.realnet.Accesstype_back.Entity.Accesstype;
|
||||
import com.realnet.Accesstype_back.Services.AccesstypeService;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
|
||||
@RequestMapping(value = "/access_type")
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
public class AccesstypeController {
|
||||
|
||||
@Autowired
|
||||
private AccesstypeService service;
|
||||
|
||||
@PostMapping("/Accesstype")
|
||||
public Accesstype Savedata(@RequestBody Accesstype data) throws JsonProcessingException {
|
||||
Accesstype save = service.Savedata(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
@GetMapping("/Accesstype")
|
||||
public List<Accesstype> getdetails() {
|
||||
List<Accesstype> get = service.getdetails();
|
||||
return get;
|
||||
}
|
||||
|
||||
@GetMapping("/Accesstype/{id}")
|
||||
public Accesstype getdetailsbyId(@PathVariable Long id) {
|
||||
Accesstype get = service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
|
||||
@PutMapping("/Accesstype/{id}")
|
||||
public Accesstype update(@RequestBody Accesstype data, @PathVariable Long id) {
|
||||
Accesstype update = service.update(data, id);
|
||||
return update;
|
||||
}
|
||||
|
||||
@DeleteMapping("/Accesstype/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Long id) {
|
||||
service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("deleted"), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.realnet.Accesstype_back.Controllers;
|
||||
|
||||
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.CrossOrigin;
|
||||
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.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.realnet.Accesstype_back.Entity.Accesstype;
|
||||
import com.realnet.Accesstype_back.Services.AccesstypeService;
|
||||
|
||||
@RequestMapping(value = "/token/access_type")
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
public class TokenFreeAccesstypeController {
|
||||
|
||||
@Autowired
|
||||
private AccesstypeService service;
|
||||
|
||||
@PostMapping("/Accesstype")
|
||||
public Accesstype Savedata(@RequestBody Accesstype data) throws JsonProcessingException {
|
||||
Accesstype save = service.Savedata(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
@GetMapping("/Accesstype")
|
||||
public List<Accesstype> getdetails() {
|
||||
List<Accesstype> get = service.getdetails();
|
||||
return get;
|
||||
}
|
||||
|
||||
@GetMapping("/Accesstype/{id}")
|
||||
public Accesstype getdetailsbyId(@PathVariable Long id) {
|
||||
Accesstype get = service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
|
||||
@PutMapping("/Accesstype/{id}")
|
||||
public Accesstype update(@RequestBody Accesstype data, @PathVariable Long id) {
|
||||
Accesstype update = service.update(data, id);
|
||||
return update;
|
||||
}
|
||||
|
||||
@DeleteMapping("/Accesstype/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Long id) {
|
||||
service.delete_by_id(id);
|
||||
return new ResponseEntity<>("deleted", HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.realnet.Accesstype_back.Entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Document
|
||||
@Data
|
||||
public class Accesstype {
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private boolean defaultvalue;
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.realnet.Accesstype_back.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Accesstype_back.Entity.Accesstype;
|
||||
|
||||
@Repository
|
||||
public interface AccesstypeRepository extends MongoRepository<Accesstype, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Optional<Accesstype> findById(Long id);
|
||||
|
||||
Optional<Accesstype> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.realnet.Accesstype_back.Services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.Accesstype_back.Entity.Accesstype;
|
||||
import com.realnet.Accesstype_back.Repository.AccesstypeRepository;
|
||||
|
||||
@Service
|
||||
public class AccesstypeService {
|
||||
|
||||
@Autowired
|
||||
private AccesstypeRepository repository;
|
||||
|
||||
public Accesstype Savedata(Accesstype data) {
|
||||
if (data.getId() == null || data.getId() <= 0) {
|
||||
Optional<Accesstype> top = repository.findTopByOrderByIdDesc();
|
||||
data.setId(top.map(a -> a.getId() + 1).orElse(1L));
|
||||
}
|
||||
return repository.save(data);
|
||||
}
|
||||
|
||||
public List<Accesstype> getdetails() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public Accesstype getdetailsbyId(Long id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public void delete_by_id(Long id) {
|
||||
Optional<Accesstype> existing = repository.findById(id);
|
||||
existing.ifPresent(a -> repository.delete(a));
|
||||
}
|
||||
|
||||
public Accesstype update(Accesstype data, Long id) {
|
||||
Accesstype old = repository.findById(id).orElse(null);
|
||||
if (old == null) {
|
||||
data.setId(id);
|
||||
return repository.save(data);
|
||||
}
|
||||
old.setName(data.getName());
|
||||
old.setDescription(data.getDescription());
|
||||
old.setDefaultvalue(data.isDefaultvalue());
|
||||
return repository.save(old);
|
||||
}
|
||||
}
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
package com.realnet.Communication.Services;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.ResourceAccessException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.utils.Port_Constant;
|
||||
|
||||
@Service
|
||||
public class EmailNotificationService {
|
||||
|
||||
@Autowired
|
||||
private EmailService emailService;
|
||||
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
public void sendDirectEmail(String email, String subject, String message) throws JsonProcessingException {
|
||||
emailService.sendSimpleMessage(null, email, subject, message);
|
||||
}
|
||||
|
||||
public void sendmailViaSetu(String email, String Name, String type) {
|
||||
switch (type) {
|
||||
case "TeamMember":
|
||||
sendEmailTeamMember(email, Name);
|
||||
break;
|
||||
case "WorkSpaceUser":
|
||||
sendEmailtoWorkUser(email, Name);
|
||||
break;
|
||||
case "AddProject":
|
||||
sendEmailAfterAddPrj(email, Name);
|
||||
break;
|
||||
case "CopyProject":
|
||||
sendEmailAfterCopyPrj(email, Name);
|
||||
break;
|
||||
case "CreateWireframe":
|
||||
sendEmailAfterCopyPrj(email, Name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseEntity<?> sendEmailTeamMember(String email, String FullName) {
|
||||
String subject = "Team Added to Workspace";
|
||||
String message = "Dear " + FullName + ",\n\nYou have been added to the workspace.";
|
||||
String templateName = "addproject";
|
||||
String gatewayName = "ganesh";
|
||||
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> sendEmailtoWorkUser(String email, String FullName) {
|
||||
String subject = "Workspace Access Granted";
|
||||
String message = "Dear " + FullName + ",\n\nYou have been granted access to the workspace.";
|
||||
String templateName = "addproject";
|
||||
String gatewayName = "ganesh";
|
||||
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> sendEmailAfterAddPrj(String email, String Name) {
|
||||
String subject = "Add Project";
|
||||
String message = "Project " + Name + " has been created successfully.";
|
||||
String templateName = "addproject";
|
||||
String gatewayName = "ganesh";
|
||||
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> sendEmailAfterCopyPrj(String email, String Name) {
|
||||
String subject = "Copy Project";
|
||||
String message = "Project " + Name + " has been Copied successfully.";
|
||||
String templateName = "addproject";
|
||||
String gatewayName = "ganesh";
|
||||
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> sendEmailAfterCreateWireframe(String email, String Name) {
|
||||
String subject = "Create Wireframe";
|
||||
String message = "A new wireframe has been successfully added to your project.";
|
||||
String templateName = "addproject";
|
||||
String gatewayName = "ganesh";
|
||||
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||
}
|
||||
|
||||
public ResponseEntity<?> sendEmailViaSetu(String email, String message, String templateName, String gatewayName)
|
||||
throws ResourceAccessException {
|
||||
try {
|
||||
String jsonData = "{\r\n" + " \"job_type\": \"Email\",\r\n" + " \"send_to\": \"" + (email != null ? email.trim() : "")
|
||||
+ "\",\r\n" + " \"cc\": \"cc@example.com\",\r\n"
|
||||
+ " \"gatewaydone\": \"N\",\r\n" + " \"template_name\": \"" + (templateName != null ? templateName.trim() : "") + "\",\r\n"
|
||||
+ " \"replacement_string\": \"Hello, {name} " + message + "!\",\r\n" + " \"gatewayName\": \""
|
||||
+ (gatewayName != null ? gatewayName.trim() : "") + "\"\r\n" + "}\r\n";
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
queryParams.add("data", jsonData);
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(queryParams, headers);
|
||||
|
||||
String apiUrl2 = Port_Constant.SURE_SETU_DOMAIN + "/token/Surecommunication/communication/jobtable/Com_jobTable";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(apiUrl2, requestEntity, String.class);
|
||||
return ResponseEntity.ok(responseEntity.getBody());
|
||||
} catch (ResourceAccessException e) {
|
||||
throw new ResourceAccessException("communication server no start..." + e);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.realnet.Dashboard1.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.CrossOrigin;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.Dashboard1.Entity.Dashbord1_Line;
|
||||
import com.realnet.Dashboard1.Entity.Dashbord_Header;
|
||||
import com.realnet.Dashboard1.Repository.HeaderRepository;
|
||||
import com.realnet.Dashboard1.Service.HeaderService;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
public class Dashbord1Controller {
|
||||
|
||||
@Autowired
|
||||
private HeaderService headerService;
|
||||
|
||||
@Autowired
|
||||
private HeaderRepository headerRepository;
|
||||
|
||||
@PostMapping("/Savedata")
|
||||
public Dashbord_Header Savedata(@RequestBody Dashbord_Header dashbord_Header) {
|
||||
Dashbord_Header dash = headerService.Savedata(dashbord_Header);
|
||||
return dash;
|
||||
}
|
||||
|
||||
@GetMapping("/get_Dashboard_header")
|
||||
public List<Dashbord_Header> getdetails() {
|
||||
List<Dashbord_Header> dash = headerService.getdetails();
|
||||
return dash;
|
||||
}
|
||||
|
||||
@GetMapping("/get_all_lines")
|
||||
public List<Dashbord1_Line> get_all_lines() {
|
||||
List<Dashbord1_Line> dash = headerService.get_all_lines();
|
||||
return dash;
|
||||
}
|
||||
|
||||
@GetMapping("/get_module_id")
|
||||
public List<Dashbord_Header> get_by_module_id(@RequestParam(value = "module_id") int module_id) {
|
||||
List<Dashbord_Header> module = headerService.get_by_module_id(module_id);
|
||||
return module;
|
||||
}
|
||||
|
||||
@GetMapping("/get_dashboard_headerbyid/{id}")
|
||||
public Dashbord_Header getdetailsbyId(@PathVariable int id) {
|
||||
Dashbord_Header dash = headerService.getdetailsbyId(id);
|
||||
return dash;
|
||||
}
|
||||
|
||||
@PutMapping("/update_dashboard_header")
|
||||
public Dashbord_Header update_dashboard_header(@RequestBody Dashbord_Header dashbord_Header) {
|
||||
Dashbord_Header dash = headerService.update_dashboard_header(dashbord_Header);
|
||||
return dash;
|
||||
}
|
||||
|
||||
@PutMapping("/update_Dashbord1_Lineby_id/{id}")
|
||||
public Dashbord1_Line update_Dashbord1_Lineby_id(@PathVariable int id, @RequestBody Dashbord1_Line dashbord1_Line) {
|
||||
Dashbord1_Line dash = headerService.update_Dashbord1_Lineby_id(id, dashbord1_Line);
|
||||
return dash;
|
||||
}
|
||||
|
||||
@PostMapping("/update_Dashbord1_Line")
|
||||
public Dashbord1_Line update_Dashbord1_Line(@RequestBody Dashbord1_Line dashbord1_Line) {
|
||||
Dashbord1_Line dash1 = headerService.update_Dashbord1_Line(dashbord1_Line);
|
||||
return dash1;
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete_by_header_id/{id}")
|
||||
public void delete_by_id(@PathVariable int id) {
|
||||
headerService.delete_by_id(id);
|
||||
}
|
||||
|
||||
@GetMapping("/get_dashboard/{module_id}")
|
||||
public ResponseEntity<?> getREPORT(@PathVariable Integer module_id) {
|
||||
List<Dashbord_Header> list = headerRepository.findbydashboardmodule(module_id);
|
||||
int count = list != null ? list.size() : 0;
|
||||
return new ResponseEntity<>(count, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.realnet.Dashboard1.Entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString(exclude = { "dashbord_Header" })
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Document
|
||||
public class Dashbord1_Line extends dashbord_Who_collumn {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String header_id;
|
||||
|
||||
private String Model;
|
||||
|
||||
private String common_filter;
|
||||
|
||||
private Dashbord_Header dashbord_Header;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.realnet.Dashboard1.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString(exclude = { "dashbord1_Line" })
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Document
|
||||
public class Dashbord_Header extends dashbord_Who_collumn {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String menuName;
|
||||
|
||||
private boolean updated;
|
||||
|
||||
private String tech_Stack;
|
||||
|
||||
private String object_type;
|
||||
private String sub_object_type;
|
||||
|
||||
private boolean build;
|
||||
|
||||
private boolean testing;
|
||||
|
||||
private String dashboard_name;
|
||||
|
||||
private int module_id;
|
||||
|
||||
private String description;
|
||||
|
||||
private String secuirity_profile;
|
||||
|
||||
private Boolean add_to_home;
|
||||
|
||||
private List<Dashbord1_Line> dashbord1_Line = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.realnet.Dashboard1.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class dashbord_Who_collumn implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@CreatedDate
|
||||
private Date createdAt;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
private Long updatedBy;
|
||||
|
||||
@LastModifiedDate
|
||||
private Date updatedAt;
|
||||
|
||||
private Long accountId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.realnet.Dashboard1.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Dashboard1.Entity.Dashbord1_Line;
|
||||
|
||||
@Repository
|
||||
public interface Dashboard_lineRepository extends MongoRepository<Dashbord1_Line, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Dashbord1_Line findById(int id);
|
||||
|
||||
@Query("{'header_id': ?0}")
|
||||
List<Dashbord1_Line> getByheader(String id);
|
||||
|
||||
Optional<Dashbord1_Line> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.realnet.Dashboard1.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Dashboard1.Entity.Dashbord_Header;
|
||||
|
||||
@Repository
|
||||
public interface HeaderRepository extends MongoRepository<Dashbord_Header, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Dashbord_Header findById(int id);
|
||||
|
||||
@Query("{'module_id': ?0}")
|
||||
List<Dashbord_Header> findbydashboardmodule(int module_id);
|
||||
|
||||
@Query("{'dashboard_name': ?0}")
|
||||
Dashbord_Header findByDashboard_name(String dashboard_name);
|
||||
|
||||
Optional<Dashbord_Header> findTopByOrderByIdDesc();
|
||||
|
||||
@Query(value = "{'module_id': ?0}", count = true)
|
||||
Long countByModule_id(int module_id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.realnet.Dashboard1.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.Dashboard1.Entity.Dashbord1_Line;
|
||||
import com.realnet.Dashboard1.Entity.Dashbord_Header;
|
||||
import com.realnet.Dashboard1.Repository.Dashboard_lineRepository;
|
||||
import com.realnet.Dashboard1.Repository.HeaderRepository;
|
||||
|
||||
@Service
|
||||
public class HeaderService {
|
||||
|
||||
@Autowired
|
||||
private HeaderRepository headerRepository;
|
||||
|
||||
@Autowired
|
||||
private Dashboard_lineRepository dashboard_lineRepository;
|
||||
|
||||
public Dashbord_Header Savedata(Dashbord_Header dashbord_Header) {
|
||||
if (dashbord_Header.getId() == null || dashbord_Header.getId() <= 0) {
|
||||
Optional<Dashbord_Header> top = headerRepository.findTopByOrderByIdDesc();
|
||||
dashbord_Header.setId(top.map(h -> h.getId() + 1).orElse(1));
|
||||
}
|
||||
if (dashbord_Header.getDashbord1_Line() != null) {
|
||||
for (Dashbord1_Line line : dashbord_Header.getDashbord1_Line()) {
|
||||
if (line.getId() == null || line.getId() <= 0) {
|
||||
Optional<Dashbord1_Line> topL = dashboard_lineRepository.findTopByOrderByIdDesc();
|
||||
line.setId(topL.map(l -> l.getId() + 1).orElse(1));
|
||||
}
|
||||
line.setHeader_id(String.valueOf(dashbord_Header.getId()));
|
||||
dashboard_lineRepository.save(line);
|
||||
}
|
||||
}
|
||||
return headerRepository.save(dashbord_Header);
|
||||
}
|
||||
|
||||
public List<Dashbord_Header> getdetails() {
|
||||
return headerRepository.findAll();
|
||||
}
|
||||
|
||||
public Dashbord_Header getdetailsbyId(int id) {
|
||||
return headerRepository.findById(id);
|
||||
}
|
||||
|
||||
public void delete_by_id(int id) {
|
||||
Dashbord_Header existing = headerRepository.findById(id);
|
||||
if (existing != null) {
|
||||
headerRepository.delete(existing);
|
||||
}
|
||||
}
|
||||
|
||||
public Dashbord_Header update_dashboard_header(Dashbord_Header dashbord_Header) {
|
||||
return headerRepository.save(dashbord_Header);
|
||||
}
|
||||
|
||||
public Dashbord1_Line update_Dashbord1_Line(Dashbord1_Line dashbord1_Line) {
|
||||
if (dashbord1_Line.getId() == null || dashbord1_Line.getId() <= 0) {
|
||||
Optional<Dashbord1_Line> topL = dashboard_lineRepository.findTopByOrderByIdDesc();
|
||||
dashbord1_Line.setId(topL.map(l -> l.getId() + 1).orElse(1));
|
||||
}
|
||||
return dashboard_lineRepository.save(dashbord1_Line);
|
||||
}
|
||||
|
||||
public List<Dashbord_Header> get_by_module_id(int module_id) {
|
||||
return headerRepository.findbydashboardmodule(module_id);
|
||||
}
|
||||
|
||||
public List<Dashbord1_Line> get_all_lines() {
|
||||
return dashboard_lineRepository.findAll();
|
||||
}
|
||||
|
||||
public Dashbord1_Line update_Dashbord1_Lineby_id(int id, Dashbord1_Line dashbord1_Line) {
|
||||
Dashbord1_Line oldline = dashboard_lineRepository.findById(id);
|
||||
if (oldline == null) {
|
||||
dashbord1_Line.setId(id);
|
||||
return dashboard_lineRepository.save(dashbord1_Line);
|
||||
}
|
||||
oldline.setAccountId(dashbord1_Line.getAccountId());
|
||||
oldline.setHeader_id(dashbord1_Line.getHeader_id());
|
||||
oldline.setModel(dashbord1_Line.getModel());
|
||||
oldline.setCommon_filter(dashbord1_Line.getCommon_filter());
|
||||
|
||||
return dashboard_lineRepository.save(oldline);
|
||||
}
|
||||
}
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.realnet.FromExtensionJson.Controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.FromExtensionJson.Entity.FromExtensionJson_t;
|
||||
import com.realnet.FromExtensionJson.Repository.FromExtensionJson_Repository;
|
||||
import com.realnet.FromExtensionJson.Services.FromExtensionJson_Service;
|
||||
|
||||
@RequestMapping(value = { "/FromExtensionJson", "/FromExtensionJsonExtensionJson" })
|
||||
@RestController
|
||||
public class FromExtensionJson_Controller {
|
||||
|
||||
@Autowired
|
||||
private FromExtensionJson_Service service;
|
||||
|
||||
@Autowired
|
||||
private FromExtensionJson_Repository extensionJson_Repository;
|
||||
|
||||
@PostMapping("/ExtensionJson")
|
||||
public FromExtensionJson_t Savedata(@RequestBody FromExtensionJson_t data) {
|
||||
FromExtensionJson_t save = service.Savedata(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
@GetMapping("/ExtensionJson")
|
||||
public List<FromExtensionJson_t> getdetails() {
|
||||
List<FromExtensionJson_t> get = service.getdetails();
|
||||
return get;
|
||||
}
|
||||
|
||||
@GetMapping("/ExtensionJson/{id}")
|
||||
public FromExtensionJson_t getdetailsbyId(@PathVariable String id) {
|
||||
FromExtensionJson_t get = service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
|
||||
@DeleteMapping("/ExtensionJson/{id}")
|
||||
public void delete_by_id(@PathVariable String id) {
|
||||
service.delete_by_id(id);
|
||||
}
|
||||
|
||||
@PutMapping("/ExtensionJson/{id}")
|
||||
public FromExtensionJson_t update(@RequestBody FromExtensionJson_t data, @PathVariable String id) {
|
||||
FromExtensionJson_t update = service.update(data, id);
|
||||
return update;
|
||||
}
|
||||
|
||||
@GetMapping({ "/ExtensionJson/{formCode}", "/{formCode}" })
|
||||
public ResponseEntity<String> getdetailsbyFormcode(@PathVariable String formCode) {
|
||||
FromExtensionJson_t get = extensionJson_Repository.getdetailsbyFormCode(formCode);
|
||||
if (get != null) {
|
||||
String jsonObject = get.getJsonObject();
|
||||
return ResponseEntity.ok().body(jsonObject);
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/ListExtensionJson/{formCode}")
|
||||
public ResponseEntity<List<String>> getJsonObjectsByFormCodeList(@PathVariable String formCode) {
|
||||
List<FromExtensionJson_t> list = extensionJson_Repository.getJsonObjectsByFormCode(formCode);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
List<String> jsonObjects = new ArrayList<>();
|
||||
for (FromExtensionJson_t item : list) {
|
||||
if (item.getJsonObject() != null) {
|
||||
jsonObjects.add(item.getJsonObject());
|
||||
}
|
||||
}
|
||||
return ResponseEntity.ok().body(jsonObjects);
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.realnet.FromExtensionJson.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Document
|
||||
@Data
|
||||
public class FromExtensionJson_t {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
private String form_code;
|
||||
private String account_id;
|
||||
private String jsonObject;
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.realnet.FromExtensionJson.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.FromExtensionJson.Entity.FromExtensionJson_t;
|
||||
|
||||
@Repository
|
||||
public interface FromExtensionJson_Repository extends MongoRepository<FromExtensionJson_t, String> {
|
||||
|
||||
@Query("{'form_code': ?0}")
|
||||
FromExtensionJson_t getdetailsbyFormCode(String formCode);
|
||||
|
||||
@Query("{'form_code': ?0}")
|
||||
List<FromExtensionJson_t> getJsonObjectsByFormCode(String formCode);
|
||||
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.realnet.FromExtensionJson.Services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.FromExtensionJson.Entity.FromExtensionJson_t;
|
||||
import com.realnet.FromExtensionJson.Repository.FromExtensionJson_Repository;
|
||||
|
||||
@Service
|
||||
public class FromExtensionJson_Service {
|
||||
|
||||
@Autowired
|
||||
private FromExtensionJson_Repository repository;
|
||||
|
||||
public FromExtensionJson_t Savedata(FromExtensionJson_t data) {
|
||||
return repository.save(data);
|
||||
}
|
||||
|
||||
public List<FromExtensionJson_t> getdetails() {
|
||||
return (List<FromExtensionJson_t>) repository.findAll();
|
||||
}
|
||||
|
||||
public FromExtensionJson_t getdetailsbyId(String id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public void delete_by_id(String id) {
|
||||
repository.deleteById(id);
|
||||
}
|
||||
|
||||
public FromExtensionJson_t update(FromExtensionJson_t data, String id) {
|
||||
FromExtensionJson_t old = repository.findById(id).orElse(null);
|
||||
if (old != null) {
|
||||
old.setForm_code(data.getForm_code());
|
||||
old.setAccount_id(data.getAccount_id());
|
||||
old.setJsonObject(data.getJsonObject());
|
||||
return repository.save(old);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.realnet.Modules_t_back.Controllers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
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.Modules_t_back.Entity.Modules_t;
|
||||
import com.realnet.Modules_t_back.Services.Modules_tService;
|
||||
|
||||
@RequestMapping(value = "/_back")
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
public class Modules_tController {
|
||||
|
||||
@Autowired
|
||||
private Modules_tService service;
|
||||
|
||||
@PostMapping("/Modules_t")
|
||||
public Modules_t Savedata(@RequestBody Modules_t data) {
|
||||
Modules_t save = service.Savedata(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
@GetMapping("/Modules_t")
|
||||
public List<Modules_t> getdetails() {
|
||||
List<Modules_t> get = service.getdetails();
|
||||
return get;
|
||||
}
|
||||
|
||||
@GetMapping("/Modules_t/{id}")
|
||||
public Modules_t getdetailsbyId(@PathVariable Long id) {
|
||||
Modules_t get = service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
|
||||
@DeleteMapping("/Modules_t/{id}")
|
||||
public void delete_by_id(@PathVariable Long id) {
|
||||
service.delete_by_id(id);
|
||||
}
|
||||
|
||||
@PutMapping("/Modules_t/{id}")
|
||||
public Modules_t update(@RequestBody Modules_t data, @PathVariable Long id) {
|
||||
Modules_t update = service.update(data, id);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.realnet.Modules_t_back.Entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Document
|
||||
@Data
|
||||
public class Modules_t {
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String module_name;
|
||||
private String module_description;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.realnet.Modules_t_back.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Modules_t_back.Entity.Modules_t;
|
||||
|
||||
@Repository
|
||||
public interface Modules_tRepository extends MongoRepository<Modules_t, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Optional<Modules_t> findById(Long id);
|
||||
|
||||
Optional<Modules_t> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.realnet.Modules_t_back.Services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.Modules_t_back.Entity.Modules_t;
|
||||
import com.realnet.Modules_t_back.Repository.Modules_tRepository;
|
||||
|
||||
@Service
|
||||
public class Modules_tService {
|
||||
|
||||
@Autowired
|
||||
private Modules_tRepository repository;
|
||||
|
||||
public Modules_t Savedata(Modules_t data) {
|
||||
if (data.getId() == null || data.getId() <= 0) {
|
||||
Optional<Modules_t> top = repository.findTopByOrderByIdDesc();
|
||||
data.setId(top.map(m -> m.getId() + 1).orElse(1L));
|
||||
}
|
||||
return repository.save(data);
|
||||
}
|
||||
|
||||
public List<Modules_t> getdetails() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public Modules_t getdetailsbyId(Long id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public void delete_by_id(Long id) {
|
||||
Optional<Modules_t> existing = repository.findById(id);
|
||||
existing.ifPresent(m -> repository.delete(m));
|
||||
}
|
||||
|
||||
public Modules_t update(Modules_t data, Long id) {
|
||||
Modules_t old = repository.findById(id).orElse(null);
|
||||
if (old == null) {
|
||||
data.setId(id);
|
||||
return repository.save(data);
|
||||
}
|
||||
old.setModule_name(data.getModule_name());
|
||||
old.setModule_description(data.getModule_description());
|
||||
return repository.save(old);
|
||||
}
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.realnet.Rpt_builder2.Controllers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
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.Rpt_builder2.Entity.Rpt_builder2_t;
|
||||
import com.realnet.Rpt_builder2.Services.Rpt_builder2_Service;
|
||||
|
||||
@RequestMapping(value = "/Rpt_builder2")
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
public class Rpt_builder2_Controller {
|
||||
|
||||
@Autowired
|
||||
private Rpt_builder2_Service service;
|
||||
|
||||
@PostMapping("/Rpt_builder2")
|
||||
public Rpt_builder2_t Savedata(@RequestBody Rpt_builder2_t data) {
|
||||
Rpt_builder2_t save = service.Savedata(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
@GetMapping("/Rpt_builder2")
|
||||
public List<Rpt_builder2_t> getdetails() {
|
||||
List<Rpt_builder2_t> get = service.getdetails();
|
||||
return get;
|
||||
}
|
||||
|
||||
@GetMapping("/Rpt_builder2/{id}")
|
||||
public Rpt_builder2_t getdetailsbyId(@PathVariable Long id) {
|
||||
Rpt_builder2_t get = service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
|
||||
@DeleteMapping("/Rpt_builder2/{id}")
|
||||
public void delete_by_id(@PathVariable Long id) {
|
||||
service.delete_by_id(id);
|
||||
}
|
||||
|
||||
@PutMapping("/Rpt_builder2/{id}")
|
||||
public Rpt_builder2_t update(@RequestBody Rpt_builder2_t data, @PathVariable Long id) {
|
||||
Rpt_builder2_t update = service.update(data, id);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.realnet.Rpt_builder2.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.realnet.Rpt_builder2_lines.Entity.Rpt_builder2_lines_t;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Document
|
||||
@Data
|
||||
public class Rpt_builder2_t {
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String reportName;
|
||||
private String description;
|
||||
private Boolean active;
|
||||
private Boolean isSql;
|
||||
|
||||
private Integer sureConnectId;
|
||||
private String sureconnect_name;
|
||||
private String folderName;
|
||||
|
||||
private List<Rpt_builder2_lines_t> Rpt_builder2_lines = new ArrayList<>();
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.realnet.Rpt_builder2.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Rpt_builder2.Entity.Rpt_builder2_t;
|
||||
|
||||
@Repository
|
||||
public interface Rpt_builder2_Repository extends MongoRepository<Rpt_builder2_t, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Optional<Rpt_builder2_t> findById(Long id);
|
||||
|
||||
Optional<Rpt_builder2_t> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.realnet.Rpt_builder2.Services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.Rpt_builder2.Entity.Rpt_builder2_t;
|
||||
import com.realnet.Rpt_builder2.Repository.Rpt_builder2_Repository;
|
||||
|
||||
@Service
|
||||
public class Rpt_builder2_Service {
|
||||
|
||||
@Autowired
|
||||
private Rpt_builder2_Repository repository;
|
||||
|
||||
public Rpt_builder2_t Savedata(Rpt_builder2_t data) {
|
||||
if (data.getId() == null || data.getId() <= 0) {
|
||||
Optional<Rpt_builder2_t> top = repository.findTopByOrderByIdDesc();
|
||||
data.setId(top.map(r -> r.getId() + 1).orElse(1L));
|
||||
}
|
||||
return repository.save(data);
|
||||
}
|
||||
|
||||
public List<Rpt_builder2_t> getdetails() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public Rpt_builder2_t getdetailsbyId(Long id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public void delete_by_id(Long id) {
|
||||
Optional<Rpt_builder2_t> existing = repository.findById(id);
|
||||
existing.ifPresent(r -> repository.delete(r));
|
||||
}
|
||||
|
||||
public Rpt_builder2_t update(Rpt_builder2_t data, Long id) {
|
||||
Rpt_builder2_t old = repository.findById(id).orElse(null);
|
||||
if (old == null) {
|
||||
data.setId(id);
|
||||
return repository.save(data);
|
||||
}
|
||||
old.setReportName(data.getReportName());
|
||||
old.setDescription(data.getDescription());
|
||||
old.setActive(data.getActive());
|
||||
old.setFolderName(data.getFolderName());
|
||||
if (data.getSureConnectId() != null) {
|
||||
old.setSureConnectId(data.getSureConnectId());
|
||||
old.setSureconnect_name(data.getSureconnect_name());
|
||||
}
|
||||
return repository.save(old);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.realnet.Rpt_builder2_lines.Entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.realnet.Rpt_builder2.Entity.Rpt_builder2_t;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Document
|
||||
@Data
|
||||
public class Rpt_builder2_lines_t {
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String header_id;
|
||||
|
||||
private String model;
|
||||
|
||||
private Rpt_builder2_t rpt_builder2_t;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.realnet.Workspaceuser.Controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.DDTable;
|
||||
import com.realnet.Workspaceuser.Entity.SecUsedDd;
|
||||
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||
import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.repository1.AppUserRepository;
|
||||
|
||||
@RestController
|
||||
public class DDController {
|
||||
|
||||
@Autowired
|
||||
private Sec_teams_Repository sec_teams_Repository;
|
||||
|
||||
@Autowired
|
||||
private AppUserRepository appUserRepository;
|
||||
|
||||
@GetMapping("/Sec_team")
|
||||
public ResponseEntity<?> getteam() {
|
||||
List<Sec_teams> sec = sec_teams_Repository.findAll();
|
||||
ArrayList<DDTable> dd = new ArrayList<>();
|
||||
if (sec != null) {
|
||||
for (Sec_teams s : sec) {
|
||||
DDTable d = new DDTable();
|
||||
d.setId(s.getId());
|
||||
d.setName(s.getName());
|
||||
dd.add(d);
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/Report_to")
|
||||
public ResponseEntity<?> reportto() {
|
||||
List<AppUser> sec = appUserRepository.findAll();
|
||||
ArrayList<SecUsedDd> dd = new ArrayList<>();
|
||||
if (sec != null) {
|
||||
for (AppUser s : sec) {
|
||||
SecUsedDd d = new SecUsedDd();
|
||||
d.setUserId(s.getUserId());
|
||||
d.setFullName(s.getFullName());
|
||||
dd.add(d);
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/Assign")
|
||||
public ResponseEntity<?> Assign() {
|
||||
List<AppUser> sec = appUserRepository.findAll();
|
||||
ArrayList<SecUsedDd> dd = new ArrayList<>();
|
||||
if (sec != null) {
|
||||
for (AppUser s : sec) {
|
||||
SecUsedDd d = new SecUsedDd();
|
||||
d.setUserId(s.getUserId());
|
||||
d.setFullName(s.getFullName());
|
||||
dd.add(d);
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/Requestor")
|
||||
public ResponseEntity<?> Requestor() {
|
||||
List<AppUser> sec = appUserRepository.findAll();
|
||||
ArrayList<SecUsedDd> dd = new ArrayList<>();
|
||||
if (sec != null) {
|
||||
for (AppUser s : sec) {
|
||||
SecUsedDd d = new SecUsedDd();
|
||||
d.setUserId(s.getUserId());
|
||||
d.setFullName(s.getFullName());
|
||||
dd.add(d);
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/Owner")
|
||||
public ResponseEntity<?> Owner() {
|
||||
List<AppUser> sec = appUserRepository.findAll();
|
||||
ArrayList<SecUsedDd> dd = new ArrayList<>();
|
||||
if (sec != null) {
|
||||
for (AppUser s : sec) {
|
||||
SecUsedDd d = new SecUsedDd();
|
||||
d.setUserId(s.getUserId());
|
||||
d.setFullName(s.getFullName());
|
||||
dd.add(d);
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.realnet.Workspaceuser.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.Workspaceuser.Entity.Sec_teams;
|
||||
import com.realnet.Workspaceuser.Service.Sec_teamService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
@RequestMapping("/Workspace_team")
|
||||
@RestController
|
||||
public class SecTeamController {
|
||||
|
||||
@Autowired
|
||||
private Sec_teamService sec_teamService;
|
||||
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
@PostMapping("/SecTeam")
|
||||
public Sec_teams create(@RequestBody Sec_teams rnrule) {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
if (loggedInUser != null && loggedInUser.getAccount() != null) {
|
||||
long accountId = loggedInUser.getAccount().getAccount_id();
|
||||
rnrule.setAccountId(accountId);
|
||||
}
|
||||
return sec_teamService.create(rnrule);
|
||||
}
|
||||
|
||||
@GetMapping("/SecTeam")
|
||||
public ResponseEntity<?> getall() {
|
||||
List<Sec_teams> li = sec_teamService.getall();
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/SecTeam/AccountId")
|
||||
public ResponseEntity<?> getallByAccountId() {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
long accountId = (loggedInUser != null && loggedInUser.getAccount() != null)
|
||||
? loggedInUser.getAccount().getAccount_id()
|
||||
: 0L;
|
||||
List<Sec_teams> li = sec_teamService.getallbyAccountId(accountId);
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/SecTeam/{id}")
|
||||
public ResponseEntity<?> getbyid(@PathVariable int id) {
|
||||
Sec_teams rn = sec_teamService.getbyid(id);
|
||||
return new ResponseEntity<>(rn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/SecTeam/{id}")
|
||||
public ResponseEntity<?> update(@RequestBody Sec_teams project, @PathVariable int id) {
|
||||
Sec_teams rule_t = sec_teamService.updatebyid(project, id);
|
||||
return new ResponseEntity<>(rule_t, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("/SecTeam/{id}")
|
||||
public void deletebyid(@PathVariable int id) {
|
||||
sec_teamService.deletebyid(id);
|
||||
}
|
||||
}
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
package com.realnet.Workspaceuser.Controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.Communication.Services.EmailNotificationService;
|
||||
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||
import com.realnet.Workspaceuser.Entity.Sec_workspace_users;
|
||||
import com.realnet.Workspaceuser.Repository.SecWorkspaceUserRepo;
|
||||
import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
||||
import com.realnet.users.entity.Role;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.repository.RoleRepo;
|
||||
import com.realnet.users.repository1.AppUserRepository;
|
||||
import com.realnet.users.response.MessageResponse;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/workspace/secworkspaceuser")
|
||||
public class SecWorkSpaceUSerController {
|
||||
|
||||
@Autowired
|
||||
private SecWorkspaceUserRepo secWorkspaceUserRepo;
|
||||
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
@Autowired
|
||||
private Sec_team_MemberRepository memberRepository;
|
||||
|
||||
@Autowired
|
||||
private AppUserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private RoleRepo roleRepo;
|
||||
|
||||
@Autowired
|
||||
private EmailNotificationService emailNotificationService;
|
||||
|
||||
@PostMapping("/addteam/{project_id}/{team_id}")
|
||||
public ResponseEntity<?> addwholeteam(@PathVariable Integer project_id, @PathVariable int team_id,
|
||||
@RequestBody Sec_workspace_users users) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
List<Sec_team_members> members = memberRepository.getallteam(team_id);
|
||||
if (members != null) {
|
||||
for (Sec_team_members mem : members) {
|
||||
Sec_workspace_users secuser = secWorkspaceUserRepo.getallsecworkspcceuser(mem.getMember_id(), project_id);
|
||||
if (secuser == null) {
|
||||
Sec_workspace_users user = new Sec_workspace_users();
|
||||
AppUser us = userRepository.findById(mem.getMember_id());
|
||||
if (us != null && us.getAccount() != null) {
|
||||
user.setAccountId(us.getAccount().getAccount_id());
|
||||
}
|
||||
user.setUser_id(mem.getMember_id());
|
||||
user.setWorksapce_id(project_id);
|
||||
user.setProject_id(project_id);
|
||||
user.setUser_name(mem.getMember_name());
|
||||
|
||||
Sec_workspace_users save = secWorkspaceUserRepo.save(user);
|
||||
list.add(save);
|
||||
|
||||
try {
|
||||
if (us != null) {
|
||||
emailNotificationService.sendmailViaSetu(us.getEmail(), us.getFullName(), "TeamMember");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("email sending error ..." + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/sec_workspace_users")
|
||||
public ResponseEntity<?> getallusers() {
|
||||
List<Sec_workspace_users> list = secWorkspaceUserRepo.findAll();
|
||||
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/get_by_projectid/{project_id}")
|
||||
public ResponseEntity<?> getallusers(@PathVariable Integer project_id) {
|
||||
List<Sec_workspace_users> list = secWorkspaceUserRepo.getallproject(project_id);
|
||||
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/add_workspace/users/{userid}/{project_id}/{access_duration}")
|
||||
public ResponseEntity<?> addsecusers(@RequestBody Sec_workspace_users users, @PathVariable Long userid,
|
||||
@PathVariable Integer project_id, @PathVariable Integer access_duration, @RequestParam String role) {
|
||||
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
Long fromuserid = loggedInUser != null ? loggedInUser.getUserId() : null;
|
||||
|
||||
Sec_workspace_users workspace_users = secWorkspaceUserRepo.getallsecworkspcceuser(userid, project_id);
|
||||
if (workspace_users == null) {
|
||||
AppUser us = userRepository.findById(userid);
|
||||
if (us != null && us.getAccount() != null) {
|
||||
users.setAccountId(us.getAccount().getAccount_id());
|
||||
}
|
||||
users.setFromuserId(fromuserid);
|
||||
users.setUser_id(userid);
|
||||
if (us != null) {
|
||||
users.setUser_name(us.getFullName());
|
||||
}
|
||||
users.setWorksapce_id(project_id);
|
||||
users.setProject_id(project_id);
|
||||
users.setAccess_duration(access_duration);
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(new Date());
|
||||
c.add(Calendar.DATE, access_duration);
|
||||
users.setAccess_till_date(c.getTime());
|
||||
|
||||
Role userRole = roleRepo.findByName(role);
|
||||
if (userRole != null) {
|
||||
users.setUser_role(role);
|
||||
}
|
||||
|
||||
Sec_workspace_users save = secWorkspaceUserRepo.save(users);
|
||||
|
||||
try {
|
||||
if (us != null) {
|
||||
emailNotificationService.sendmailViaSetu(us.getEmail(), us.getFullName(), "WorkSpaceUser");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("email sending error ..." + e);
|
||||
}
|
||||
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||
} else {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("user already added"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.realnet.Workspaceuser.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.Workspaceuser.Entity.Sec_team_members;
|
||||
import com.realnet.Workspaceuser.Service.SecTeam_MemberService;
|
||||
|
||||
@RequestMapping("/Workspace_team_member")
|
||||
@RestController
|
||||
public class Sec_team_members_Controller {
|
||||
|
||||
@Autowired
|
||||
private SecTeam_MemberService secTeam_MemberService;
|
||||
|
||||
@PostMapping("/Teammember")
|
||||
public Sec_team_members create(@RequestBody Sec_team_members rnrule) {
|
||||
return secTeam_MemberService.create(rnrule);
|
||||
}
|
||||
|
||||
@GetMapping("/Teammember")
|
||||
public ResponseEntity<?> getall() {
|
||||
List<Sec_team_members> li = secTeam_MemberService.getall();
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/Teammember/{id}")
|
||||
public ResponseEntity<?> getbyid(@PathVariable int id) {
|
||||
Sec_team_members rn = secTeam_MemberService.getbyid(id);
|
||||
return new ResponseEntity<>(rn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/Teammember/{id}")
|
||||
public ResponseEntity<?> update(@RequestBody Sec_team_members project, @PathVariable int id) {
|
||||
Sec_team_members rule_t = secTeam_MemberService.updatebyid(project, id);
|
||||
return new ResponseEntity<>(rule_t, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("/Teammember/{id}")
|
||||
public void deletebyid(@PathVariable int id) {
|
||||
secTeam_MemberService.deletebyid(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.realnet.Workspaceuser.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.Workspaceuser.Entity.Sec_workspace;
|
||||
import com.realnet.Workspaceuser.Repository.WorkspaceRepository;
|
||||
import com.realnet.Workspaceuser.Service.WorkspaceService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
@RequestMapping("/Workspace_workspace")
|
||||
@RestController
|
||||
public class WorkspaceController {
|
||||
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
@Autowired
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
@Autowired
|
||||
private WorkspaceRepository workspaceRepository;
|
||||
|
||||
@PostMapping("/workspace")
|
||||
public Sec_workspace create(@RequestBody Sec_workspace rnrule) {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
if (loggedInUser != null) {
|
||||
Long userId = loggedInUser.getUserId();
|
||||
rnrule.setOwner_id(userId);
|
||||
|
||||
if (loggedInUser.getAccount() != null) {
|
||||
long accountId = loggedInUser.getAccount().getAccount_id();
|
||||
rnrule.setAccountId(accountId);
|
||||
}
|
||||
}
|
||||
Sec_workspace rn = workspaceService.create(rnrule);
|
||||
return rn;
|
||||
}
|
||||
|
||||
@GetMapping("/workspace")
|
||||
public ResponseEntity<?> getall() {
|
||||
List<Sec_workspace> li = workspaceService.getall();
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/FindByaccount")
|
||||
public ResponseEntity<?> getallbyaccount() {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
long accountId = (loggedInUser != null && loggedInUser.getAccount() != null)
|
||||
? loggedInUser.getAccount().getAccount_id()
|
||||
: 0L;
|
||||
List<Sec_workspace> li = workspaceRepository.findByAccountId(accountId);
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/workspace/{id}")
|
||||
public ResponseEntity<?> getbyid(@PathVariable int id) {
|
||||
Sec_workspace rn = workspaceService.getbyid(id);
|
||||
return new ResponseEntity<>(rn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/workspace/{id}")
|
||||
public ResponseEntity<?> update(@RequestBody Sec_workspace project, @PathVariable int id) {
|
||||
Sec_workspace rule_t = workspaceService.updatebyid(project, id);
|
||||
return new ResponseEntity<>(rule_t, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("/workspace/{id}")
|
||||
public void deletebyid(@PathVariable int id) {
|
||||
workspaceService.deletebyid(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.realnet.Workspaceuser.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DDTable {
|
||||
private int id;
|
||||
private String name;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.realnet.Workspaceuser.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SecUsedDd {
|
||||
private Long userId;
|
||||
private String fullName;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.realnet.Workspaceuser.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Document(collection = "sec_team_members")
|
||||
@Data
|
||||
public class Sec_team_members implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private int id;
|
||||
private int team_id;
|
||||
private Long member_id;
|
||||
private boolean member_type;
|
||||
private String access_days;
|
||||
private Date access_start_date;
|
||||
private String member_name;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.realnet.Workspaceuser.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.realnet.fnd.entity.Rn_Who_AccId_Column;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Document(collection = "sec_teams")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Sec_teams extends Rn_Who_AccId_Column implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String Is_active;
|
||||
|
||||
public String getIs_active() {
|
||||
return Is_active;
|
||||
}
|
||||
|
||||
public void setIs_active(String is_active) {
|
||||
Is_active = is_active;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.realnet.Workspaceuser.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.realnet.fnd.entity.Rn_Who_AccId_Column;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Document(collection = "sec_workspace")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Sec_workspace extends Rn_Who_AccId_Column implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String is_default;
|
||||
private String Is_active;
|
||||
private Long owner_id;
|
||||
private Integer project_id;
|
||||
|
||||
public String getIs_active() {
|
||||
return Is_active;
|
||||
}
|
||||
|
||||
public void setIs_active(String is_active) {
|
||||
Is_active = is_active;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.realnet.Workspaceuser.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.realnet.WhoCollumn.Who_column;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Document(collection = "sec_workspace_users")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Sec_workspace_users extends Who_column implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Long id;
|
||||
private int worksapce_id;
|
||||
private Long user_id;
|
||||
private String user_name;
|
||||
private Integer project_id;
|
||||
private String user_role;
|
||||
|
||||
private String project_name;
|
||||
private Long fromuserId;
|
||||
|
||||
private Integer access_duration;
|
||||
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
|
||||
private Date access_till_date;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.realnet.Workspaceuser.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_workspace_users;
|
||||
|
||||
@Repository
|
||||
public interface SecWorkspaceUserRepo extends MongoRepository<Sec_workspace_users, String> {
|
||||
|
||||
@Query("{'user_id': ?0}")
|
||||
List<Sec_workspace_users> getallbyuserid(Long userId);
|
||||
|
||||
@Query("{'user_id': ?0, 'project_id': ?1}")
|
||||
Sec_workspace_users getallsecworkspcceuser(Long userid, Integer project_id);
|
||||
|
||||
@Query("{'project_id': ?0}")
|
||||
List<Sec_workspace_users> getallproject(Integer project_id);
|
||||
|
||||
@Query(value = "{'user_id': ?0}", count = true)
|
||||
Long countSharewithme(Long userId);
|
||||
|
||||
Optional<Sec_workspace_users> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.realnet.Workspaceuser.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||
|
||||
@Repository
|
||||
public interface Sec_team_MemberRepository extends MongoRepository<Sec_team_members, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Sec_team_members findById(int id);
|
||||
|
||||
@Query("{'team_id': ?0}")
|
||||
List<Sec_team_members> getallteam(int team_id);
|
||||
|
||||
@Query("{'team_id': ?0, 'member_id': ?1}")
|
||||
Sec_team_members findteammember(int id, Long userId);
|
||||
|
||||
Optional<Sec_team_members> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.realnet.Workspaceuser.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||
|
||||
@Repository
|
||||
public interface Sec_teams_Repository extends MongoRepository<Sec_teams, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Sec_teams findById(int id);
|
||||
|
||||
@Query("{'accountId': ?0}")
|
||||
List<Sec_teams> findAllByAccountid(Long accountId);
|
||||
|
||||
Optional<Sec_teams> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.realnet.Workspaceuser.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_workspace;
|
||||
|
||||
@Repository
|
||||
public interface WorkspaceRepository extends MongoRepository<Sec_workspace, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Sec_workspace findById(int id);
|
||||
|
||||
@Query("{'accountId': ?0}")
|
||||
List<Sec_workspace> findByAccountId(Long accountId);
|
||||
|
||||
@Query("{'project_id': ?0}")
|
||||
List<Sec_workspace> findByProject_id(Integer project_id);
|
||||
|
||||
Optional<Sec_workspace> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.realnet.Workspaceuser.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||
import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
||||
|
||||
@Service
|
||||
public class SecTeam_MemberService {
|
||||
|
||||
@Autowired
|
||||
private Sec_team_MemberRepository sec_team_MemberRepository;
|
||||
|
||||
public Sec_team_members create(Sec_team_members rnrule) {
|
||||
if (rnrule.getId() <= 0) {
|
||||
Optional<Sec_team_members> top = sec_team_MemberRepository.findTopByOrderByIdDesc();
|
||||
rnrule.setId(top.map(t -> t.getId() + 1).orElse(1));
|
||||
}
|
||||
return sec_team_MemberRepository.save(rnrule);
|
||||
}
|
||||
|
||||
public List<Sec_team_members> getall() {
|
||||
return sec_team_MemberRepository.findAll();
|
||||
}
|
||||
|
||||
public Sec_team_members getbyid(int id) {
|
||||
return sec_team_MemberRepository.findById(id);
|
||||
}
|
||||
|
||||
public Sec_team_members updatebyid(Sec_team_members project, int id) {
|
||||
Sec_team_members rule = sec_team_MemberRepository.findById(id);
|
||||
if (rule == null) {
|
||||
rule = project;
|
||||
rule.setId(id);
|
||||
} else {
|
||||
rule.setAccess_days(project.getAccess_days());
|
||||
rule.setAccess_start_date(project.getAccess_start_date());
|
||||
rule.setMember_id(project.getMember_id());
|
||||
rule.setMember_name(project.getMember_name());
|
||||
rule.setTeam_id(project.getTeam_id());
|
||||
}
|
||||
|
||||
return sec_team_MemberRepository.save(rule);
|
||||
}
|
||||
|
||||
public void deletebyid(int id) {
|
||||
Sec_team_members rule = sec_team_MemberRepository.findById(id);
|
||||
if (rule != null) {
|
||||
sec_team_MemberRepository.delete(rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.realnet.Workspaceuser.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||
import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
||||
|
||||
@Service
|
||||
public class Sec_teamService {
|
||||
|
||||
@Autowired
|
||||
private Sec_teams_Repository sec_teams_Repository;
|
||||
|
||||
public Sec_teams create(Sec_teams rnrule) {
|
||||
if (rnrule.getId() <= 0) {
|
||||
Optional<Sec_teams> top = sec_teams_Repository.findTopByOrderByIdDesc();
|
||||
rnrule.setId(top.map(t -> t.getId() + 1).orElse(1));
|
||||
}
|
||||
return sec_teams_Repository.save(rnrule);
|
||||
}
|
||||
|
||||
public List<Sec_teams> getall() {
|
||||
return sec_teams_Repository.findAll();
|
||||
}
|
||||
|
||||
public List<Sec_teams> getallbyAccountId(Long accountId) {
|
||||
return sec_teams_Repository.findAllByAccountid(accountId);
|
||||
}
|
||||
|
||||
public Sec_teams getbyid(int id) {
|
||||
return sec_teams_Repository.findById(id);
|
||||
}
|
||||
|
||||
public Sec_teams updatebyid(Sec_teams project, int id) {
|
||||
Sec_teams rule = sec_teams_Repository.findById(id);
|
||||
if (rule == null) {
|
||||
rule = project;
|
||||
rule.setId(id);
|
||||
} else {
|
||||
rule.setAccountId(project.getAccountId());
|
||||
rule.setDescription(project.getDescription());
|
||||
rule.setIs_active(project.getIs_active());
|
||||
rule.setName(project.getName());
|
||||
}
|
||||
|
||||
return sec_teams_Repository.save(rule);
|
||||
}
|
||||
|
||||
public void deletebyid(int id) {
|
||||
Sec_teams rule = sec_teams_Repository.findById(id);
|
||||
if (rule != null) {
|
||||
sec_teams_Repository.delete(rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.realnet.Workspaceuser.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_workspace;
|
||||
import com.realnet.Workspaceuser.Repository.WorkspaceRepository;
|
||||
|
||||
@Service
|
||||
public class WorkspaceService {
|
||||
|
||||
@Autowired
|
||||
private WorkspaceRepository workspaceRepository;
|
||||
|
||||
public Sec_workspace create(Sec_workspace rnrule) {
|
||||
if (rnrule.getId() <= 0) {
|
||||
Optional<Sec_workspace> top = workspaceRepository.findTopByOrderByIdDesc();
|
||||
rnrule.setId(top.map(w -> w.getId() + 1).orElse(1));
|
||||
}
|
||||
return workspaceRepository.save(rnrule);
|
||||
}
|
||||
|
||||
public List<Sec_workspace> getall() {
|
||||
return workspaceRepository.findAll();
|
||||
}
|
||||
|
||||
public Sec_workspace getbyid(int id) {
|
||||
return workspaceRepository.findById(id);
|
||||
}
|
||||
|
||||
public Sec_workspace updatebyid(Sec_workspace project, int id) {
|
||||
Sec_workspace rule = workspaceRepository.findById(id);
|
||||
if (rule == null) {
|
||||
rule = project;
|
||||
rule.setId(id);
|
||||
} else {
|
||||
rule.setAccountId(project.getAccountId());
|
||||
rule.setDescription(project.getDescription());
|
||||
rule.setIs_active(project.getIs_active());
|
||||
rule.setIs_default(project.getIs_default());
|
||||
rule.setName(project.getName());
|
||||
rule.setOwner_id(project.getOwner_id());
|
||||
rule.setProject_id(project.getProject_id());
|
||||
}
|
||||
|
||||
return workspaceRepository.save(rule);
|
||||
}
|
||||
|
||||
public void deletebyid(int id) {
|
||||
Sec_workspace save = workspaceRepository.findById(id);
|
||||
if (save != null) {
|
||||
workspaceRepository.delete(save);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,49 +10,32 @@ import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.realnet.logging.NoLogging;
|
||||
|
||||
|
||||
public class CorsFilter implements javax.servlet.Filter {
|
||||
@NoLogging
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
res.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS");
|
||||
res.setHeader("Access-Control-Max-Age", "3600");
|
||||
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Accept-Encoding, Accept-Language, Host, Referer, Connection, User-Agent, authorization, sw-useragent, sw-version");
|
||||
//res.setHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
|
||||
// Just REPLY OK if request method is OPTIONS for CORS (pre-flight)
|
||||
if ( req.getMethod().equals("OPTIONS") ) {
|
||||
res.setStatus(HttpServletResponse.SC_OK);
|
||||
return;
|
||||
}
|
||||
String origin = req.getHeader("Origin");
|
||||
res.setHeader("Access-Control-Allow-Origin", (origin != null && !origin.isEmpty()) ? origin : "*");
|
||||
res.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS");
|
||||
res.setHeader("Access-Control-Max-Age", "3600");
|
||||
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Accept-Encoding, Accept-Language, Host, Referer, Connection, User-Agent, authorization, sw-useragent, sw-version");
|
||||
|
||||
if ("OPTIONS".equalsIgnoreCase(req.getMethod())) {
|
||||
res.setStatus(HttpServletResponse.SC_OK);
|
||||
return;
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
// public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
// System.out.println("Filtering on...........................................................");
|
||||
// HttpServletResponse response = (HttpServletResponse) res;
|
||||
// response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
// response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
// response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
|
||||
// response.setHeader("Access-Control-Max-Age", "3600");
|
||||
// response.setHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Origin, Accept, Access-Control-Request-Method, Access-Control-Request-Headers");
|
||||
//
|
||||
// chain.doFilter(req, res);
|
||||
//}
|
||||
|
||||
@NoLogging
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {}
|
||||
|
||||
@Override
|
||||
public void destroy() {}
|
||||
|
||||
@NoLogging
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ public class MongoDataInitializer implements CommandLineRunner {
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder bcryptEncoder;
|
||||
|
||||
@Autowired
|
||||
private com.realnet.sysparameter.repository.SysParamRepository sysParamRepo;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
LOGGER.info("[MongoDataInitializer] Checking and initializing baseline data...");
|
||||
@@ -76,6 +79,17 @@ public class MongoDataInitializer implements CommandLineRunner {
|
||||
// 5. Initialize Core Navigation Menus
|
||||
initMenusAndAccess(adminGrp, userGrp);
|
||||
|
||||
// 6. Initialize System Parameters
|
||||
if (sysParamRepo.findAll().isEmpty()) {
|
||||
com.realnet.sysparameter.entity.SysParamEntity p = new com.realnet.sysparameter.entity.SysParamEntity();
|
||||
p.setId(1);
|
||||
p.setCompany_Display_Name("RealNet CNS");
|
||||
p.setUpload_Logo("logo.png");
|
||||
p.setRegitrationAllowed(true);
|
||||
sysParamRepo.save(p);
|
||||
LOGGER.info("[MongoDataInitializer] Created default SysParamEntity with id 1");
|
||||
}
|
||||
|
||||
// ADD OTHER SERVICE
|
||||
|
||||
LOGGER.info("[MongoDataInitializer] Baseline data initialization check complete.");
|
||||
@@ -122,12 +136,22 @@ public class MongoDataInitializer implements CommandLineRunner {
|
||||
}
|
||||
|
||||
private void initAdminUser(Role adminRole, Role devRole, AppUserRole adminGrp, Sys_Accounts account) {
|
||||
AppUser existing = appUserRepository.findByEmail("sysadmin");
|
||||
AppUser existing = appUserRepository.findByEmail("sysadmin@domain.com");
|
||||
if (existing == null) {
|
||||
existing = appUserRepository.findByEmail("sysadmin");
|
||||
}
|
||||
if (existing == null) {
|
||||
existing = appUserRepository.findByEmail("admin");
|
||||
}
|
||||
if (existing == null) {
|
||||
if (existing != null) {
|
||||
if (existing.getUserId() == null) {
|
||||
existing.setUserId(1L);
|
||||
appUserRepository.save(existing);
|
||||
LOGGER.info("[MongoDataInitializer] Assigned userId 1L to existing admin user.");
|
||||
}
|
||||
} else {
|
||||
AppUser adminUser = new AppUser();
|
||||
adminUser.setUserId(1L);
|
||||
adminUser.setUsername("sysadmin");
|
||||
adminUser.setEmail("sysadmin@domain.com");
|
||||
adminUser.setFullName("System Admin");
|
||||
@@ -145,7 +169,7 @@ public class MongoDataInitializer implements CommandLineRunner {
|
||||
adminUser.setRoles(roles);
|
||||
|
||||
appUserRepository.save(adminUser);
|
||||
LOGGER.info("[MongoDataInitializer] Created default Admin user: sysadmin / sysadmin");
|
||||
LOGGER.info("[MongoDataInitializer] Created default Admin user: sysadmin / sysadmin (userId: 1)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
protected CorsConfigurationSource corsConfigurationSource() {
|
||||
final CorsConfiguration configuration = new CorsConfiguration();
|
||||
|
||||
configuration.setAllowedOrigins(Collections.singletonList("http://localhost:3000"));
|
||||
configuration.setAllowedOrigins(Arrays.asList("http://localhost:4201", "http://localhost:4200", "http://localhost:3000"));
|
||||
configuration.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"));
|
||||
|
||||
// NOTE: setAllowCredentials(true) is important,
|
||||
@@ -194,6 +194,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
// Add CORS Filter //http.cors().and().csrf().disable().
|
||||
.addFilterBefore(new CorsFilter(), ChannelProcessingFilter.class).authorizeRequests()
|
||||
.antMatchers("/token/**").permitAll()
|
||||
.antMatchers("/sysparam/**").permitAll()
|
||||
.antMatchers("/access_type/**").permitAll()
|
||||
.antMatchers("/_back/**").permitAll()
|
||||
.antMatchers("/Dashboard/**").permitAll()
|
||||
.antMatchers("/get_Dashboard_header").permitAll()
|
||||
.antMatchers("/Rpt_builder2/**").permitAll()
|
||||
.antMatchers("/log2/**").permitAll()
|
||||
.antMatchers("/api/**").permitAll()
|
||||
// .antMatchers("/SqlworkbenchSqlcont/**").hasRole("ADMIN")
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.realnet.dashboard_builder_authsec.Controllers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
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.dashboard_builder_authsec.Entity.Dashboard;
|
||||
import com.realnet.dashboard_builder_authsec.Services.DashboardService;
|
||||
|
||||
@RequestMapping(value = "/Dashboard")
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@RestController
|
||||
public class DashboardController {
|
||||
|
||||
@Autowired
|
||||
private DashboardService service;
|
||||
|
||||
@PostMapping("/Dashboard")
|
||||
public Dashboard Savedata(@RequestBody Dashboard data) {
|
||||
Dashboard save = service.Savedata(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
@PutMapping("/Dashboard/{id}")
|
||||
public Dashboard update(@RequestBody Dashboard data, @PathVariable Integer id) {
|
||||
Dashboard update = service.update(data, id);
|
||||
return update;
|
||||
}
|
||||
|
||||
@GetMapping("/Dashboard")
|
||||
public List<Dashboard> getdetails() {
|
||||
List<Dashboard> get = service.getdetails();
|
||||
return get;
|
||||
}
|
||||
|
||||
@GetMapping("/Dashboard/{id}")
|
||||
public Dashboard getdetailsbyId(@PathVariable Integer id) {
|
||||
Dashboard get = service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
|
||||
@DeleteMapping("/Dashboard/{id}")
|
||||
public void delete_by_id(@PathVariable Integer id) {
|
||||
service.delete_by_id(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.realnet.dashboard_builder_authsec.Entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.realnet.WhoCollumn.Extension;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Document
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Dashboard extends Extension {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String model;
|
||||
|
||||
private boolean isdashboard;
|
||||
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.realnet.dashboard_builder_authsec.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.dashboard_builder_authsec.Entity.Dashboard;
|
||||
|
||||
@Repository
|
||||
public interface DashboardRepository extends MongoRepository<Dashboard, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Optional<Dashboard> findById(Integer id);
|
||||
|
||||
Optional<Dashboard> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.realnet.dashboard_builder_authsec.Services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.dashboard_builder_authsec.Entity.Dashboard;
|
||||
import com.realnet.dashboard_builder_authsec.Repository.DashboardRepository;
|
||||
|
||||
@Service
|
||||
public class DashboardService {
|
||||
|
||||
@Autowired
|
||||
private DashboardRepository repository;
|
||||
|
||||
public Dashboard Savedata(Dashboard data) {
|
||||
if (data.getId() == null || data.getId() <= 0) {
|
||||
Optional<Dashboard> top = repository.findTopByOrderByIdDesc();
|
||||
data.setId(top.map(d -> d.getId() + 1).orElse(1));
|
||||
}
|
||||
return repository.save(data);
|
||||
}
|
||||
|
||||
public List<Dashboard> getdetails() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public Dashboard getdetailsbyId(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Optional<Dashboard> existing = repository.findById(id);
|
||||
existing.ifPresent(d -> repository.delete(d));
|
||||
}
|
||||
|
||||
public Dashboard update(Dashboard data, Integer id) {
|
||||
Dashboard old = repository.findById(id).orElse(null);
|
||||
if (old == null) {
|
||||
data.setId(id);
|
||||
return repository.save(data);
|
||||
}
|
||||
old.setName(data.getName());
|
||||
old.setModel(data.getModel());
|
||||
old.setIsdashboard(data.isIsdashboard());
|
||||
return repository.save(old);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,155 +1,144 @@
|
||||
//package com.realnet.fnd.controller;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import javax.validation.Valid;
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.http.HttpHeaders;
|
||||
//import org.springframework.http.HttpStatus;
|
||||
//import org.springframework.http.MediaType;
|
||||
//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.RequestHeader;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestParam;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import com.realnet.FromExtensionJson.Entity.FromExtensionJson_t;
|
||||
//import com.realnet.FromExtensionJson.Services.FromExtensionJson_Service;
|
||||
//import com.realnet.exceptions.ResourceNotFoundException;
|
||||
//import com.realnet.fnd.entity.Rn_Ext_Fields;
|
||||
//import com.realnet.fnd.service.ExtFieldService;
|
||||
//import com.realnet.users.entity1.AppUser;
|
||||
//import com.realnet.users.service1.AppUserServiceImpl;
|
||||
//
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//
|
||||
//@RestController
|
||||
//@RequestMapping(value = "/api", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
//@Api(tags = { "Extension Fields" })
|
||||
//public class Rn_ExtensionController {
|
||||
//
|
||||
// @Value("${angularProjectPath}")
|
||||
// private String angularProjectPath;
|
||||
//
|
||||
// @Autowired
|
||||
// private ExtFieldService extFieldService;
|
||||
//
|
||||
//
|
||||
// @Autowired
|
||||
// private FromExtensionJson_Service formeExtensionJson_Service;
|
||||
//
|
||||
// @Autowired(required = false)
|
||||
// // private UserService userService;
|
||||
// private AppUserServiceImpl userService;
|
||||
//
|
||||
//// @Autowired
|
||||
//// private TokenUtil tokenUtil;
|
||||
//
|
||||
// // GET ALL
|
||||
// @ApiOperation(value = "List of Extensions")
|
||||
// @GetMapping("/extension")
|
||||
// public ResponseEntity<List<Rn_Ext_Fields>> getExtensions() {
|
||||
// List<Rn_Ext_Fields> result = extFieldService.getAll();
|
||||
// return ResponseEntity.ok().body(result);
|
||||
// }
|
||||
//
|
||||
// // GET BY ID
|
||||
// @ApiOperation(value = "Get an Extension")
|
||||
// @GetMapping("/extension/{id}")
|
||||
// public ResponseEntity<Rn_Ext_Fields> getExtensionById(@PathVariable(value = "id") int id) {
|
||||
// Rn_Ext_Fields rn_ext_fields = extFieldService.getById(id);
|
||||
// return ResponseEntity.ok().body(rn_ext_fields);
|
||||
// }
|
||||
//
|
||||
// // SAVE
|
||||
// @ApiOperation(value = "Add new Extension", response = Rn_Ext_Fields.class)
|
||||
// @PostMapping("/extension")
|
||||
// public ResponseEntity<Rn_Ext_Fields> saveExtension(
|
||||
// @RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authToken,
|
||||
// @Valid @RequestBody Rn_Ext_Fields rn_ext_fields) {
|
||||
// // String userId = tokenUtil.getUserId(authToken);
|
||||
// AppUser loggedInUser = userService.getLoggedInUser();
|
||||
// // rn_ext_fields.setCreated_by(loggedInUser.getUserId());
|
||||
// rn_ext_fields.setAccount_id(loggedInUser.getAccount().getAccount_id());
|
||||
// Rn_Ext_Fields savedRn_Ext_Fields = extFieldService.save(rn_ext_fields);
|
||||
// if (savedRn_Ext_Fields == null) {
|
||||
// throw new ResourceNotFoundException("Rn_Ext_Field is not saved");
|
||||
// }
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(savedRn_Ext_Fields);
|
||||
// }
|
||||
//
|
||||
// // UPDATE
|
||||
// @ApiOperation(value = "Update an Extension", response = Rn_Ext_Fields.class)
|
||||
// @PutMapping("/extension/{id}")
|
||||
// public ResponseEntity<Rn_Ext_Fields> updateRn_Ext_Field(
|
||||
// @RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authToken,
|
||||
// @PathVariable(value = "id") int id, @Valid @RequestBody Rn_Ext_Fields rn_ext_fields) {
|
||||
//// String userId = tokenUtil.getUserId(authToken);
|
||||
//// // teacher.setAccountId(userId);
|
||||
//// rn_ext_fields.setUpdatedBy(userId);
|
||||
// Rn_Ext_Fields updatedRn_Ext_Field = extFieldService.updateById(id, rn_ext_fields);
|
||||
// return ResponseEntity.status(HttpStatus.ACCEPTED).body(updatedRn_Ext_Field);
|
||||
// }
|
||||
//
|
||||
// // DELETE
|
||||
// @DeleteMapping("/extension/{id}")
|
||||
// public ResponseEntity<Map<String, Boolean>> deleteRn_Ext_Field(@PathVariable(value = "id") int id) {
|
||||
// boolean deleted = extFieldService.deleteById(id);
|
||||
// Map<String, Boolean> response = new HashMap<>();
|
||||
// if (deleted) {
|
||||
// response.put("deleted", Boolean.TRUE);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
// }
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
||||
// }
|
||||
//
|
||||
//// @GetMapping("/lookup_values")
|
||||
//// public ResponseEntity<List<String>> getLookUps() {
|
||||
//// List<String> result = extFieldService.getLookupValues();
|
||||
//// System.out.println(result);
|
||||
//// return ResponseEntity.ok().body(result);
|
||||
//// }
|
||||
////
|
||||
//// @GetMapping("/datatypes")
|
||||
//// public ResponseEntity<List<String>> getDataTypes() {
|
||||
//// List<String> result = extFieldService.getDataTypeValues();
|
||||
//// System.out.println(result);
|
||||
//// return ResponseEntity.ok().body(result);
|
||||
//// }
|
||||
//
|
||||
// @GetMapping("/extension_build/{formId}")
|
||||
// public ResponseEntity<?> buildExtension(@RequestParam(value = "account_id", required = false) String account_id,
|
||||
// @RequestParam(value = "form_code", required = false) String form_code, @PathVariable Integer formId) {
|
||||
//
|
||||
// ArrayList<String> list = new ArrayList<>();
|
||||
//
|
||||
// System.out.println("Acc Id" + account_id + " Form Code = " + form_code);
|
||||
// String formCode = extFieldService.buildExtensionByFormCode(account_id, form_code,formId);
|
||||
// list.add(formCode);
|
||||
// Map<String, Boolean> res = new HashMap<String, Boolean>();
|
||||
// res.put("build", true);
|
||||
// FromExtensionJson_t json_t = new FromExtensionJson_t();
|
||||
// json_t.setAccount_id(account_id);
|
||||
// json_t.setForm_code(form_code);
|
||||
//
|
||||
// json_t.setJsonObject(formCode);
|
||||
//
|
||||
// formeExtensionJson_Service.Savedata(json_t);
|
||||
//
|
||||
//
|
||||
// return ResponseEntity.ok().body(list);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package com.realnet.fnd.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.FromExtensionJson.Entity.FromExtensionJson_t;
|
||||
import com.realnet.FromExtensionJson.Services.FromExtensionJson_Service;
|
||||
import com.realnet.exceptions.ResourceNotFoundException;
|
||||
import com.realnet.fnd.entity.Rn_Ext_Fields;
|
||||
import com.realnet.fnd.service.ExtFieldService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Api(tags = { "Extension Fields" })
|
||||
public class Rn_ExtensionController {
|
||||
|
||||
@Value("${angularProjectPath}")
|
||||
private String angularProjectPath;
|
||||
|
||||
@Autowired
|
||||
private ExtFieldService extFieldService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private FromExtensionJson_Service formeExtensionJson_Service;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
// GET ALL
|
||||
@ApiOperation(value = "List of Extensions")
|
||||
@GetMapping("/extension")
|
||||
public ResponseEntity<List<Rn_Ext_Fields>> getExtensions() {
|
||||
List<Rn_Ext_Fields> result = extFieldService.getAll();
|
||||
return ResponseEntity.ok().body(result);
|
||||
}
|
||||
|
||||
// GET BY ID
|
||||
@ApiOperation(value = "Get an Extension")
|
||||
@GetMapping("/extension/{id}")
|
||||
public ResponseEntity<Rn_Ext_Fields> getExtensionById(@PathVariable(value = "id") int id) {
|
||||
Rn_Ext_Fields rn_ext_fields = extFieldService.getById(id);
|
||||
return ResponseEntity.ok().body(rn_ext_fields);
|
||||
}
|
||||
|
||||
// SAVE
|
||||
@ApiOperation(value = "Add new Extension", response = Rn_Ext_Fields.class)
|
||||
@PostMapping("/extension")
|
||||
public ResponseEntity<Rn_Ext_Fields> saveExtension(
|
||||
@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authToken,
|
||||
@Valid @RequestBody Rn_Ext_Fields rn_ext_fields) {
|
||||
if (userService != null) {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
if (loggedInUser != null && loggedInUser.getAccount() != null) {
|
||||
rn_ext_fields.setAccount_id(loggedInUser.getAccount().getAccount_id());
|
||||
}
|
||||
}
|
||||
Rn_Ext_Fields savedRn_Ext_Fields = extFieldService.save(rn_ext_fields);
|
||||
if (savedRn_Ext_Fields == null) {
|
||||
throw new ResourceNotFoundException("Rn_Ext_Field is not saved");
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(savedRn_Ext_Fields);
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
@ApiOperation(value = "Update an Extension", response = Rn_Ext_Fields.class)
|
||||
@PutMapping("/extension/{id}")
|
||||
public ResponseEntity<Rn_Ext_Fields> updateRn_Ext_Field(
|
||||
@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authToken,
|
||||
@PathVariable(value = "id") int id, @Valid @RequestBody Rn_Ext_Fields rn_ext_fields) {
|
||||
Rn_Ext_Fields updatedRn_Ext_Field = extFieldService.updateById(id, rn_ext_fields);
|
||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(updatedRn_Ext_Field);
|
||||
}
|
||||
|
||||
// DELETE
|
||||
@DeleteMapping("/extension/{id}")
|
||||
public ResponseEntity<Map<String, Boolean>> deleteRn_Ext_Field(@PathVariable(value = "id") int id) {
|
||||
boolean deleted = extFieldService.deleteById(id);
|
||||
Map<String, Boolean> response = new HashMap<>();
|
||||
if (deleted) {
|
||||
response.put("deleted", Boolean.TRUE);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
||||
}
|
||||
|
||||
@GetMapping("/lookup_values")
|
||||
public ResponseEntity<List<String>> getLookUps() {
|
||||
List<String> result = extFieldService.getLookupValues();
|
||||
return ResponseEntity.ok().body(result);
|
||||
}
|
||||
|
||||
@GetMapping("/datatypes")
|
||||
public ResponseEntity<List<String>> getDataTypes() {
|
||||
List<String> result = extFieldService.getDataTypeValues();
|
||||
return ResponseEntity.ok().body(result);
|
||||
}
|
||||
|
||||
@GetMapping("/extension_build/{formId}")
|
||||
public ResponseEntity<?> buildExtension(@RequestParam(value = "account_id", required = false) String account_id,
|
||||
@RequestParam(value = "form_code", required = false) String form_code, @PathVariable Integer formId) {
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
System.out.println("Acc Id " + account_id + " Form Code = " + form_code);
|
||||
String formCode = extFieldService.buildExtensionByFormCode(account_id, form_code, formId);
|
||||
list.add(formCode);
|
||||
|
||||
if (formeExtensionJson_Service != null) {
|
||||
FromExtensionJson_t json_t = new FromExtensionJson_t();
|
||||
json_t.setAccount_id(account_id);
|
||||
json_t.setForm_code(form_code);
|
||||
json_t.setJsonObject(formCode);
|
||||
formeExtensionJson_Service.Savedata(json_t);
|
||||
}
|
||||
|
||||
return ResponseEntity.ok().body(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.realnet.fnd.entity1.GrpMenuAccess;
|
||||
import com.realnet.fnd.entity1.MenuDet;
|
||||
import com.realnet.fnd.repository1.GrpMenuAccessRepository;
|
||||
import com.realnet.fnd.service1.SecmenuDetailService;
|
||||
import com.realnet.fnd.repository1.MenuDetRepository;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.entity1.AppUserRole;
|
||||
@@ -48,6 +49,9 @@ public class LoadMenuController {
|
||||
@Autowired
|
||||
private AppUserRepository appUserRepository;
|
||||
|
||||
@Autowired
|
||||
private SecmenuDetailService secmenuDetailService;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoadMenuController.class);
|
||||
|
||||
// GROUP MENU ACCESS MENU LOAD BY USER
|
||||
@@ -124,86 +128,9 @@ public class LoadMenuController {
|
||||
@PathVariable Long gmenuid,
|
||||
@RequestBody GrpMenuAccess gr) {
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
MenuDet formenu = menuDetRepository.findById(gmenuid);
|
||||
|
||||
List<GrpMenuAccess> all = grpMenuAccessRepository.findByGrpAndMenuid1(formenu.getMenuItemId());
|
||||
|
||||
for (GrpMenuAccess a : all) {
|
||||
|
||||
a.setMenuItemId(formenu);
|
||||
a.setItemSeq(formenu.getItemSeq());
|
||||
a.setMenuItemDesc(formenu.getMenuItemDesc());
|
||||
a.setModuleName(formenu.getModuleName());
|
||||
a.setStatus(formenu.getStatus());
|
||||
a.setMain_menu_action_name(formenu.getMain_menu_action_name());
|
||||
a.setMain_menu_icon_name(formenu.getMain_menu_icon_name());
|
||||
a.setMenuId(formenu.getMenuId());
|
||||
GrpMenuAccess save = grpMenuAccessRepository.save(a);
|
||||
list.add(save);
|
||||
}
|
||||
|
||||
List<MenuDet> submenu = menuDetRepository.findAllSubmenuByMenuId(gmenuid);
|
||||
for (int i = 0; i < submenu.size(); i++) {
|
||||
MenuDet m = menuDetRepository.findById(submenu.get(i).getMenuItemId());
|
||||
List<GrpMenuAccess> li = grpMenuAccessRepository.findlist(m.getMenuItemId());
|
||||
|
||||
if (li.isEmpty()) {
|
||||
List<GrpMenuAccess> grp = grpMenuAccessRepository.findAllById(gmenuid);
|
||||
|
||||
for (GrpMenuAccess a : grp) {
|
||||
AppUserRole app = appUserRoleRepository.findById(a.getUsrGrp().getUsrGrp());
|
||||
gr.setUsrGrp(app);
|
||||
gr.setMenuItemId(m);
|
||||
|
||||
gr.setItemSeq(m.getItemSeq());
|
||||
gr.setMenuItemDesc(m.getMenuItemDesc());
|
||||
gr.setModuleName(m.getModuleName());
|
||||
gr.setStatus(m.getStatus());
|
||||
gr.setMain_menu_action_name(m.getMain_menu_action_name());
|
||||
gr.setMain_menu_icon_name(m.getMain_menu_icon_name());
|
||||
gr.setMenuId(m.getMenuId());
|
||||
|
||||
gr.setMCreate("true");
|
||||
gr.setMDelete("true");
|
||||
gr.setMEdit("true");
|
||||
gr.setMQuery("true");
|
||||
gr.setMVisible("true");
|
||||
gr.setIsdisable("true");
|
||||
gr.setMexport("true");
|
||||
|
||||
gr.setCreatedAt(new Date());
|
||||
gr.setUpdatedAt(new Date());
|
||||
|
||||
GrpMenuAccess save2 = grpMenuAccessRepository.save(gr);
|
||||
list.add(save2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
for (GrpMenuAccess g : li) {
|
||||
|
||||
g.setMenuItemId(m);
|
||||
|
||||
g.setItemSeq(m.getItemSeq());
|
||||
g.setMenuItemDesc(m.getMenuItemDesc());
|
||||
g.setModuleName(m.getModuleName());
|
||||
g.setStatus(m.getStatus());
|
||||
g.setMain_menu_action_name(m.getMain_menu_action_name());
|
||||
g.setMain_menu_icon_name(m.getMain_menu_icon_name());
|
||||
g.setMenuId(m.getMenuId());
|
||||
|
||||
GrpMenuAccess save1 = grpMenuAccessRepository.save(g);
|
||||
list.add(save1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Object> list = secmenuDetailService.sync(gmenuid, gr);
|
||||
return new ResponseEntity<>(list, HttpStatus.CREATED);
|
||||
|
||||
}
|
||||
|
||||
// COMPLETED
|
||||
// SINK GRPMENU ACCESS FROM MENU DET BY PASSING MENU ITEM ID OF MENU BY LOGIN USER
|
||||
@PutMapping("/sink1/{gmenuid}")
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.realnet.fnd.controller1;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.exceptions.ResourceNotFoundException;
|
||||
import com.realnet.fnd.entity1.Query;
|
||||
import com.realnet.fnd.repository1.QueryRepository;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
@RequestMapping(value = { "/FndQuery", "/api1" }, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RestController
|
||||
public class QueryController {
|
||||
|
||||
@Autowired
|
||||
private QueryRepository queryRepository;
|
||||
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
// ADD DATA
|
||||
@PostMapping("/query")
|
||||
public ResponseEntity<?> add(@RequestBody Query query) {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
if (loggedInUser != null) {
|
||||
if (loggedInUser.getAccount() != null) {
|
||||
query.setAccountId(loggedInUser.getAccount().getAccount_id());
|
||||
}
|
||||
query.setCreatedBy(loggedInUser.getUserId());
|
||||
}
|
||||
|
||||
if (query.getId() == null || query.getId() <= 0) {
|
||||
Optional<Query> top = queryRepository.findTopByOrderByIdDesc();
|
||||
query.setId(top.map(q -> q.getId() + 1).orElse(1L));
|
||||
}
|
||||
|
||||
Query save = queryRepository.save(query);
|
||||
return new ResponseEntity<>(save, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
// GET BY ID
|
||||
@GetMapping("/query/{id}")
|
||||
public ResponseEntity<?> get(@PathVariable Long id) {
|
||||
Query query = queryRepository.findById(id).orElse(null);
|
||||
return new ResponseEntity<>(query, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// GET ALL
|
||||
@GetMapping("/query")
|
||||
public ResponseEntity<?> getall() {
|
||||
List<Query> query = queryRepository.findAll();
|
||||
return new ResponseEntity<>(query, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// UPDATE BY ID
|
||||
@PutMapping("/query/{id}")
|
||||
public ResponseEntity<?> updateMenuGRPAccess(@PathVariable Long id, @RequestBody Query q) {
|
||||
Query query = queryRepository.findById(id).orElse(null);
|
||||
if (query == null) {
|
||||
throw new ResourceNotFoundException("no resource found");
|
||||
}
|
||||
query.setSql_query(q.getSql_query());
|
||||
query.setQueryname(q.getQueryname());
|
||||
|
||||
Query a = queryRepository.save(query);
|
||||
return new ResponseEntity<>(a, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// DELETE BY ID
|
||||
@DeleteMapping("/query/{id}")
|
||||
public void deleteGrpMenuAccess(@PathVariable Long id) {
|
||||
Query query = queryRepository.findById(id).orElse(null);
|
||||
if (Objects.isNull(query))
|
||||
throw new ResourceNotFoundException("no resource found");
|
||||
|
||||
queryRepository.delete(query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.realnet.fnd.entity1;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.realnet.fnd.entity.Rn_Who_AccId_Column;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Document(collection = "sec_query")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Query extends Rn_Who_AccId_Column implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private Long id;
|
||||
private String queryname;
|
||||
private String sql_query;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
//import org.springframework.data.jpa.repository.JpaRepository;
|
||||
//import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -18,16 +16,13 @@ public interface Rn_LookUpRepository extends MongoRepository<Rn_Lookup_Values, S
|
||||
// for pagination
|
||||
Page<Rn_Lookup_Values> findAll(Pageable p);
|
||||
|
||||
// @Query(value = "SELECT LOOKUP_CODE FROM RN_LOOKUP_VALUES_T WHERE LOOKUP_TYPE ='Form_ext'" , nativeQuery = true)
|
||||
@Query("{'LOOKUP_TYPE': Form_ext}")
|
||||
@Query("{'LOOKUP_TYPE': 'Form_ext'}")
|
||||
List<String> findLookupValues();
|
||||
|
||||
// @Query(value = "SELECT LOOKUP_CODE FROM RN_LOOKUP_VALUES_T WHERE LOOKUP_TYPE ='DataType'" , nativeQuery = true)
|
||||
@Query("{'LOOKUP_TYPE': DataType}")
|
||||
@Query("{'LOOKUP_TYPE': 'DataType'}")
|
||||
List<String> findDataTypeValues();
|
||||
|
||||
// @Query(value = "SELECT * FROM RN_LOOKUP_VALUES_T WHERE LOOKUP_TYPE ='Form_ext'" , nativeQuery = true)
|
||||
@Query("{'LOOKUP_TYPE': Form_ext}")
|
||||
@Query("{'LOOKUP_TYPE': 'Form_ext'}")
|
||||
List<Rn_Lookup_Values> findExtensions();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.realnet.fnd.repository1;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface QueryRepository extends MongoRepository<com.realnet.fnd.entity1.Query, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Optional<com.realnet.fnd.entity1.Query> findById(Long id);
|
||||
|
||||
Optional<com.realnet.fnd.entity1.Query> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ public interface ExtFieldService {
|
||||
Rn_Ext_Fields updateById(int id, Rn_Ext_Fields rn_ext_fields);
|
||||
boolean deleteById(int id);
|
||||
|
||||
// // LOOKUP FIELDS (ATTRIBUTE, FLEX)
|
||||
// List<String> getLookupValues();
|
||||
//
|
||||
// // TEXTFIELD, DROPDOWN ETC...
|
||||
// List<String> getDataTypeValues();
|
||||
// LOOKUP FIELDS (ATTRIBUTE, FLEX)
|
||||
List<String> getLookupValues();
|
||||
|
||||
// TEXTFIELD, DROPDOWN ETC...
|
||||
List<String> getDataTypeValues();
|
||||
|
||||
// BUILD HTML FOR EXTENSION
|
||||
String buildExtensionByFormCode(String acc_id, String f_code, Integer formId);
|
||||
|
||||
@@ -76,15 +76,15 @@ public class ExtFieldServiceImpl implements ExtFieldService {
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<String> getLookupValues() {
|
||||
// return lookUpRepository.findLookupValues();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<String> getDataTypeValues() {
|
||||
// return lookUpRepository.findDataTypeValues();
|
||||
// }
|
||||
@Override
|
||||
public List<String> getLookupValues() {
|
||||
return lookUpRepository1.findLookupValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDataTypeValues() {
|
||||
return lookUpRepository1.findDataTypeValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildExtensionByFormCode(String acc_id, String f_code, Integer formId) {
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
// Added for menucreation and sync part
|
||||
package com.realnet.fnd.service1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.fnd.entity1.GrpMenuAccess;
|
||||
import com.realnet.fnd.entity1.MenuDet;
|
||||
import com.realnet.fnd.repository1.GrpMenuAccessRepository;
|
||||
import com.realnet.fnd.repository1.MenuDetRepository;
|
||||
import com.realnet.users.entity1.AppUserRole;
|
||||
import com.realnet.users.repository1.AppUserRoleRepository;
|
||||
|
||||
@Service
|
||||
public class SecmenuDetailService {
|
||||
|
||||
@Autowired
|
||||
private MenuDetRepository menuDetRepository;
|
||||
|
||||
@Autowired
|
||||
private AppUserRoleRepository appUserRoleRepository;
|
||||
|
||||
@Autowired
|
||||
private GrpMenuAccessRepository grpMenuAccessRepository;
|
||||
|
||||
public MenuDet customsecmenuadd(String tablename, String menuActionLink, Long menuId) {
|
||||
MenuDet menuDet = new MenuDet();
|
||||
String origTableName = tablename.replaceAll("_", " ");
|
||||
menuDet.setMenuId(menuId);
|
||||
menuDet.setItemSeq(8001L);
|
||||
menuDet.setMain_menu_icon_name(tablename);
|
||||
menuDet.setMenuItemDesc(origTableName);
|
||||
menuDet.setModuleName(tablename);
|
||||
menuDet.setMain_menu_action_name(menuActionLink);
|
||||
menuDet.setStatus("Enable");
|
||||
MenuDet save = menuDetRepository.save(menuDet);
|
||||
sync(menuId, new GrpMenuAccess());
|
||||
System.out.println(save.getMenuItemDesc() + " menu inserted");
|
||||
return save;
|
||||
}
|
||||
|
||||
public List<Object> sync(Long gmenuid, GrpMenuAccess gr) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
MenuDet formenu = menuDetRepository.findById(gmenuid);
|
||||
if (formenu == null) {
|
||||
return list;
|
||||
}
|
||||
System.out.println("[SYNC] start gmenuid=" + gmenuid + " formenu=" + formenu.getMenuItemDesc() + " mId="
|
||||
+ formenu.getMenuItemId());
|
||||
|
||||
// Ensure parent for ALL groups
|
||||
List<AppUserRole> allRoles = appUserRoleRepository.findAll();
|
||||
System.out.println("[SYNC] allRoles=" + allRoles.size());
|
||||
for (AppUserRole role : allRoles) {
|
||||
if (grpMenuAccessRepository.findById2(formenu.getMenuItemId(), role.getUsrGrp()) == null) {
|
||||
GrpMenuAccess ng = new GrpMenuAccess();
|
||||
ng.setUsrGrp(role);
|
||||
ng.setMenuItemId(formenu);
|
||||
ng.setItemSeq(formenu.getItemSeq());
|
||||
ng.setMenuItemDesc(formenu.getMenuItemDesc());
|
||||
ng.setModuleName(formenu.getModuleName());
|
||||
ng.setStatus(formenu.getStatus());
|
||||
ng.setMain_menu_action_name(formenu.getMain_menu_action_name());
|
||||
ng.setMain_menu_icon_name(formenu.getMain_menu_icon_name());
|
||||
ng.setMenuId(formenu.getMenuId());
|
||||
ng.setMCreate("true");
|
||||
ng.setMDelete("true");
|
||||
ng.setMEdit("true");
|
||||
ng.setMQuery("true");
|
||||
ng.setMVisible("true");
|
||||
ng.setIsdisable("false");
|
||||
ng.setMexport("true");
|
||||
ng.setCreatedAt(new Date());
|
||||
ng.setUpdatedAt(new Date());
|
||||
grpMenuAccessRepository.save(ng);
|
||||
System.out.println("[SYNC] parent grant to grp=" + role.getUsrGrp());
|
||||
list.add(ng);
|
||||
}
|
||||
}
|
||||
List<GrpMenuAccess> all = grpMenuAccessRepository.findByGrpAndMenuid1(formenu.getMenuItemId());
|
||||
for (GrpMenuAccess a : all) {
|
||||
a.setMenuItemId(formenu);
|
||||
a.setItemSeq(formenu.getItemSeq());
|
||||
a.setMenuItemDesc(formenu.getMenuItemDesc());
|
||||
a.setModuleName(formenu.getModuleName());
|
||||
a.setStatus(formenu.getStatus());
|
||||
a.setMain_menu_action_name(formenu.getMain_menu_action_name());
|
||||
a.setMain_menu_icon_name(formenu.getMain_menu_icon_name());
|
||||
a.setMenuId(formenu.getMenuId());
|
||||
list.add(grpMenuAccessRepository.save(a));
|
||||
}
|
||||
|
||||
List<MenuDet> submenu = menuDetRepository.findAllSubmenuByMenuId(gmenuid);
|
||||
System.out.println("[SYNC] submenus=" + submenu.size());
|
||||
for (int i = 0; i < submenu.size(); i++) {
|
||||
MenuDet m = menuDetRepository.findById(submenu.get(i).getMenuItemId());
|
||||
if (m == null)
|
||||
continue;
|
||||
List<GrpMenuAccess> li = grpMenuAccessRepository.findlist(m.getMenuItemId());
|
||||
System.out.println(
|
||||
"[SYNC] child " + m.getMenuItemDesc() + " mId=" + m.getMenuItemId() + " li=" + li.size());
|
||||
|
||||
List<AppUserRole> allGroups = appUserRoleRepository.findAll();
|
||||
for (AppUserRole role : allGroups) {
|
||||
if (grpMenuAccessRepository.findById2(m.getMenuItemId(), role.getUsrGrp()) != null)
|
||||
continue;
|
||||
GrpMenuAccess ng = new GrpMenuAccess();
|
||||
ng.setUsrGrp(role);
|
||||
ng.setMenuItemId(m);
|
||||
ng.setItemSeq(m.getItemSeq());
|
||||
ng.setMenuItemDesc(m.getMenuItemDesc());
|
||||
ng.setModuleName(m.getModuleName());
|
||||
ng.setStatus(m.getStatus());
|
||||
ng.setMain_menu_action_name(m.getMain_menu_action_name());
|
||||
ng.setMain_menu_icon_name(m.getMain_menu_icon_name());
|
||||
ng.setMenuId(m.getMenuId());
|
||||
ng.setMCreate("true");
|
||||
ng.setMDelete("true");
|
||||
ng.setMEdit("true");
|
||||
ng.setMQuery("true");
|
||||
ng.setMVisible("true");
|
||||
ng.setIsdisable("false");
|
||||
ng.setMexport("true");
|
||||
ng.setCreatedAt(new Date());
|
||||
ng.setUpdatedAt(new Date());
|
||||
grpMenuAccessRepository.save(ng);
|
||||
System.out.println("[SYNC] child grant " + m.getMenuItemDesc() + " to grp=" + role.getUsrGrp());
|
||||
list.add(ng);
|
||||
}
|
||||
for (GrpMenuAccess g : li) {
|
||||
g.setMenuItemId(m);
|
||||
g.setItemSeq(m.getItemSeq());
|
||||
g.setMenuItemDesc(m.getMenuItemDesc());
|
||||
g.setModuleName(m.getModuleName());
|
||||
g.setStatus(m.getStatus());
|
||||
g.setMain_menu_action_name(m.getMain_menu_action_name());
|
||||
g.setMain_menu_icon_name(m.getMain_menu_icon_name());
|
||||
g.setMenuId(m.getMenuId());
|
||||
list.add(grpMenuAccessRepository.save(g));
|
||||
}
|
||||
}
|
||||
System.out.println("[SYNC] done gmenuid=" + gmenuid);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.realnet.sysparameter.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
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.RequestHeader;
|
||||
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.multipart.MultipartFile;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
import com.realnet.exceptions.ResourceNotFoundException;
|
||||
import com.realnet.sysparameter.entity.SysParamEntity;
|
||||
import com.realnet.sysparameter.entity.SysParamUpload;
|
||||
import com.realnet.sysparameter.repository.SysParamRepository;
|
||||
import com.realnet.sysparameter.service.SysParamService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/sysparam")
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
@Api(tags = { "sysparameter" })
|
||||
public class SysParamController {
|
||||
|
||||
@Autowired
|
||||
private SysParamService sysparamService;
|
||||
|
||||
@Autowired
|
||||
private SysParamRepository sysParamRepo;
|
||||
|
||||
@Value("${projectPath:.}")
|
||||
private String projectPath;
|
||||
|
||||
// GET BY ID
|
||||
@ApiOperation(value = "Get A system parameters", response = SysParamEntity.class)
|
||||
@GetMapping("/getSysParams/{id}")
|
||||
public ResponseEntity<SysParamEntity> getSystemParamDetails(@PathVariable(value = "id") int id) {
|
||||
SysParamEntity sysparameter = sysparamService.getById(id);
|
||||
if (sysparameter == null) {
|
||||
throw new ResourceNotFoundException("system parameter not found with id " + id);
|
||||
}
|
||||
return ResponseEntity.ok().body(sysparameter);
|
||||
}
|
||||
|
||||
// ADD SYSTEM PARAMETER
|
||||
@ApiOperation(value = "Add New system parameters")
|
||||
@PostMapping(value = "/addSysParams", consumes = { "application/json" })
|
||||
public ResponseEntity<?> saveFavourite(@RequestBody SysParamEntity sysparam, HttpSession session1)
|
||||
throws IOException {
|
||||
SysParamEntity savedsysparam = sysparamService.save(sysparam);
|
||||
if (savedsysparam == null) {
|
||||
throw new ResourceNotFoundException("system parameter not saved ");
|
||||
}
|
||||
return ResponseEntity.ok().body(savedsysparam);
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
@ApiOperation(value = "update a system parameters", response = SysParamEntity.class)
|
||||
@PutMapping("/updateSysParams/{id}")
|
||||
public ResponseEntity<SysParamEntity> updateSystemParameter(
|
||||
@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authToken,
|
||||
@PathVariable(value = "id") Integer id, @Valid @RequestBody SysParamEntity sysparam) {
|
||||
SysParamEntity updatedsale = sysparamService.updateSysParamById(id, sysparam);
|
||||
if (updatedsale == null || id != updatedsale.getId()) {
|
||||
throw new ResourceNotFoundException("system parameter not found with id " + id);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(updatedsale);
|
||||
}
|
||||
|
||||
// UPDATE logo on project
|
||||
@PutMapping("/logo/updateSysParams/{sys_id}")
|
||||
public ResponseEntity<SysParamEntity> updateLogo(@PathVariable(value = "sys_id") Integer sys_id,
|
||||
@Valid @RequestBody SysParamEntity sysparam) throws JsonProcessingException {
|
||||
SysParamEntity updatedsale = sysparamService.updatelogo(sys_id, sysparam);
|
||||
if (updatedsale == null || sys_id != updatedsale.getId()) {
|
||||
throw new ResourceNotFoundException("system parameter not found with id " + sys_id);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(updatedsale);
|
||||
}
|
||||
|
||||
@PostMapping("/uploadimage")
|
||||
public ResponseEntity<?> uploadProfilePic(@RequestParam("imageFile") MultipartFile file) throws IOException {
|
||||
SysParamEntity sys = new SysParamEntity();
|
||||
String uploadPath = projectPath.concat("/src/main/resources/logo/");
|
||||
|
||||
boolean success = sysparamService.upload_logo(file, uploadPath);
|
||||
|
||||
String fileName = file.getOriginalFilename();
|
||||
String ext = fileName != null && fileName.contains(".") ? fileName.substring(fileName.lastIndexOf(".")) : "";
|
||||
String fileNewName = "profile-pic-" + ext;
|
||||
|
||||
sys.setUpload_Logo(fileNewName);
|
||||
Map<String, Boolean> res = new HashMap<>();
|
||||
if (success) {
|
||||
res.put("success", success);
|
||||
return new ResponseEntity<>(res, HttpStatus.OK);
|
||||
} else {
|
||||
res.put("success", success);
|
||||
return new ResponseEntity<>(res, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
// save data and upload files
|
||||
@PostMapping("/Sysupload")
|
||||
public ResponseEntity<?> add(@RequestParam String o1, @RequestParam Map<String, MultipartFile> attachmentsfile)
|
||||
throws IOException {
|
||||
SysParamEntity sysParamEntity = new ObjectMapper().readValue(o1, SysParamEntity.class);
|
||||
SysParamEntity order = sysparamService.save(sysParamEntity);
|
||||
|
||||
if (!attachmentsfile.isEmpty()) {
|
||||
ArrayList<SysParamUpload> attachments = new ArrayList<>();
|
||||
for (Map.Entry<String, MultipartFile> e : attachmentsfile.entrySet()) {
|
||||
SysParamUpload a = new SysParamUpload();
|
||||
a.setSysParamEntity(order);
|
||||
a.setAttachmentId(order.getId());
|
||||
a.setAttachment(e.getValue().getBytes());
|
||||
a.setAttachmentType(e.getValue().getContentType());
|
||||
a.setAttachmentFilename(e.getValue().getOriginalFilename());
|
||||
attachments.add(a);
|
||||
order.setUpload_Logo(a.getAttachmentFilename());
|
||||
}
|
||||
sysparamService.addallattachments(attachments);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(order, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/Sysupload/{id}")
|
||||
public ResponseEntity<?> update(@RequestParam String o1, @RequestParam Map<String, MultipartFile> attachmentsfile,
|
||||
@PathVariable int id) throws IOException {
|
||||
SysParamEntity sysparam = new ObjectMapper().readValue(o1, SysParamEntity.class);
|
||||
SysParamEntity order = sysparamService.updateSysParamById(id, sysparam);
|
||||
|
||||
if (!attachmentsfile.isEmpty()) {
|
||||
ArrayList<SysParamUpload> attachments = new ArrayList<>();
|
||||
for (Map.Entry<String, MultipartFile> e : attachmentsfile.entrySet()) {
|
||||
SysParamUpload a = new SysParamUpload();
|
||||
a.setSysParamEntity(order);
|
||||
a.setAttachmentId(order.getId());
|
||||
a.setAttachment(e.getValue().getBytes());
|
||||
a.setAttachmentType(e.getValue().getContentType());
|
||||
a.setAttachmentFilename(e.getValue().getOriginalFilename());
|
||||
attachments.add(a);
|
||||
order.setUpload_Logo(a.getAttachmentFilename());
|
||||
}
|
||||
sysparamService.addallattachments(attachments);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(order, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// GET JSON WITH PHOTO BY ID
|
||||
@GetMapping("/sysparam/{id}")
|
||||
public ResponseEntity<?> GETSYS(@PathVariable int id) {
|
||||
SysParamEntity pm = sysParamRepo.findById(id).orElseThrow(() -> new ResourceNotFoundException("id not found"));
|
||||
List<SysParamUpload> attachments = sysparamService.getallattachmentsbyid(id);
|
||||
pm.setSysParamUploads(attachments);
|
||||
return new ResponseEntity<>(pm, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.realnet.sysparameter.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Document
|
||||
@ToString
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SysParamEntity {
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private int id;
|
||||
|
||||
private int schedulerTime;
|
||||
|
||||
private String leaseTaxCode;
|
||||
|
||||
private int vesselConfProcessLimit;
|
||||
|
||||
private int rowToDisplay;
|
||||
|
||||
private int linkToDisplay;
|
||||
|
||||
private int rowToAdd;
|
||||
|
||||
private int lovRowToDisplay;
|
||||
|
||||
private int lovLinkToDisplay;
|
||||
|
||||
private String oidserverName;
|
||||
|
||||
private String oidBase;
|
||||
|
||||
private String oidAdminUser;
|
||||
|
||||
private int oidServerPort;
|
||||
|
||||
private int userDefaultGroup;
|
||||
|
||||
private String defaultDepartment;
|
||||
|
||||
private String defaultPosition;
|
||||
|
||||
private String singleCharge;
|
||||
|
||||
private String firstDayOftheWeek;
|
||||
|
||||
private int hourPerShift;
|
||||
|
||||
private int cnBillingFrequency;
|
||||
|
||||
private String billingDepartmentCode;
|
||||
|
||||
private String basePriceList;
|
||||
|
||||
private String nonContainerServiceOrder;
|
||||
|
||||
private int EdiMaeSchedulerONOFF;
|
||||
|
||||
private String EdiSchedulerONOFF;
|
||||
|
||||
private String upload_Logo;
|
||||
private String upload_Logo_name;
|
||||
|
||||
private String upload_Logo_path;
|
||||
|
||||
private String Company_Display_Name;
|
||||
|
||||
private boolean isRegitrationAllowed = true;
|
||||
|
||||
private List<SysParamUpload> sysParamUploads;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.realnet.sysparameter.entity;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Document
|
||||
@Data
|
||||
public class SysParamUpload {
|
||||
|
||||
@Id
|
||||
private String mongoid;
|
||||
|
||||
private int attachmentId;
|
||||
|
||||
private byte[] attachment;
|
||||
|
||||
private String attachmentType;
|
||||
|
||||
private String attachmentFilename;
|
||||
|
||||
private String cancelStatus = "N";
|
||||
|
||||
private String updatedBy;
|
||||
|
||||
private String externalFlag;
|
||||
|
||||
private SysParamEntity sysParamEntity;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.realnet.sysparameter.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.sysparameter.entity.SysParamEntity;
|
||||
|
||||
@Repository
|
||||
public interface SysParamRepository extends MongoRepository<SysParamEntity, String> {
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Optional<SysParamEntity> findById(int id);
|
||||
|
||||
Optional<SysParamEntity> findTopByOrderByIdDesc();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.realnet.sysparameter.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.sysparameter.entity.SysParamUpload;
|
||||
|
||||
@Repository
|
||||
public interface SysparamUploadRepo extends MongoRepository<SysParamUpload, String> {
|
||||
|
||||
@Query("{'attachmentId': ?0}")
|
||||
List<SysParamUpload> findAllById(int sys_param_entity_id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.realnet.sysparameter.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.realnet.fnd.response.PageResponse;
|
||||
import com.realnet.sysparameter.entity.SysParamEntity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class SysParamResponse extends PageResponse {
|
||||
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
private List<SysParamEntity> sysparameters;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.realnet.sysparameter.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.realnet.sysparameter.entity.SysParamEntity;
|
||||
import com.realnet.sysparameter.entity.SysParamUpload;
|
||||
|
||||
public interface SysParamService {
|
||||
|
||||
public SysParamEntity getById(int id);
|
||||
|
||||
SysParamEntity save(SysParamEntity sysparam);
|
||||
|
||||
public SysParamEntity updateSysParamById(int id, SysParamEntity sysparam);
|
||||
|
||||
public SysParamEntity updatelogo(int id, SysParamEntity sysparam) throws JsonProcessingException;
|
||||
|
||||
public boolean upload_logo(MultipartFile file, String uploadPath);
|
||||
|
||||
public List<SysParamUpload> addallattachments(List<SysParamUpload> attachments);
|
||||
|
||||
public List<SysParamUpload> getallattachmentsbyid(int id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.realnet.sysparameter.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.realnet.exceptions.ResourceNotFoundException;
|
||||
import com.realnet.exceptions.StorageException;
|
||||
import com.realnet.sysparameter.entity.SysParamEntity;
|
||||
import com.realnet.sysparameter.entity.SysParamUpload;
|
||||
import com.realnet.sysparameter.repository.SysParamRepository;
|
||||
import com.realnet.sysparameter.repository.SysparamUploadRepo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysParamServiceImpl implements SysParamService {
|
||||
|
||||
@Autowired
|
||||
private SysParamRepository sysParamRepo;
|
||||
|
||||
@Autowired
|
||||
private SysparamUploadRepo sysparamUploadRepo;
|
||||
|
||||
@Override
|
||||
public SysParamEntity getById(int id) {
|
||||
Optional<SysParamEntity> opt = sysParamRepo.findById(id);
|
||||
if (opt.isPresent()) {
|
||||
return opt.get();
|
||||
}
|
||||
// Fallback to avoid breaking frontend when id 1 is queried before setup
|
||||
SysParamEntity def = new SysParamEntity();
|
||||
def.setId(id);
|
||||
def.setCompany_Display_Name("RealNet CNS");
|
||||
def.setUpload_Logo("logo.png");
|
||||
def.setRegitrationAllowed(true);
|
||||
return sysParamRepo.save(def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysParamEntity save(SysParamEntity sysparam) {
|
||||
if (sysparam.getId() <= 0) {
|
||||
Optional<SysParamEntity> top = sysParamRepo.findTopByOrderByIdDesc();
|
||||
sysparam.setId(top.map(s -> s.getId() + 1).orElse(1));
|
||||
}
|
||||
return sysParamRepo.save(sysparam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysParamEntity updateSysParamById(int id, SysParamEntity sysparam) {
|
||||
SysParamEntity NewSysparam = sysParamRepo.findById(id).orElse(null);
|
||||
if (NewSysparam == null) {
|
||||
sysparam.setId(id);
|
||||
return sysParamRepo.save(sysparam);
|
||||
}
|
||||
NewSysparam.setRegitrationAllowed(sysparam.isRegitrationAllowed());
|
||||
NewSysparam.setSchedulerTime(sysparam.getSchedulerTime());
|
||||
NewSysparam.setLeaseTaxCode(sysparam.getLeaseTaxCode());
|
||||
NewSysparam.setVesselConfProcessLimit(sysparam.getVesselConfProcessLimit());
|
||||
NewSysparam.setRowToDisplay(sysparam.getRowToDisplay());
|
||||
NewSysparam.setLinkToDisplay(sysparam.getLinkToDisplay());
|
||||
NewSysparam.setRowToAdd(sysparam.getRowToAdd());
|
||||
NewSysparam.setLovRowToDisplay(sysparam.getLovRowToDisplay());
|
||||
NewSysparam.setLovLinkToDisplay(sysparam.getLovLinkToDisplay());
|
||||
NewSysparam.setOidserverName(sysparam.getOidserverName());
|
||||
NewSysparam.setOidBase(sysparam.getOidBase());
|
||||
NewSysparam.setOidAdminUser(sysparam.getOidAdminUser());
|
||||
NewSysparam.setOidServerPort(sysparam.getOidServerPort());
|
||||
NewSysparam.setUserDefaultGroup(sysparam.getUserDefaultGroup());
|
||||
NewSysparam.setDefaultDepartment(sysparam.getDefaultDepartment());
|
||||
NewSysparam.setDefaultPosition(sysparam.getDefaultPosition());
|
||||
NewSysparam.setSingleCharge(sysparam.getSingleCharge());
|
||||
NewSysparam.setFirstDayOftheWeek(sysparam.getFirstDayOftheWeek());
|
||||
NewSysparam.setHourPerShift(sysparam.getHourPerShift());
|
||||
NewSysparam.setCnBillingFrequency(sysparam.getCnBillingFrequency());
|
||||
NewSysparam.setBillingDepartmentCode(sysparam.getBillingDepartmentCode());
|
||||
NewSysparam.setBasePriceList(sysparam.getBasePriceList());
|
||||
NewSysparam.setNonContainerServiceOrder(sysparam.getNonContainerServiceOrder());
|
||||
NewSysparam.setEdiMaeSchedulerONOFF(sysparam.getEdiMaeSchedulerONOFF());
|
||||
NewSysparam.setEdiSchedulerONOFF(sysparam.getEdiSchedulerONOFF());
|
||||
NewSysparam.setCompany_Display_Name(sysparam.getCompany_Display_Name());
|
||||
|
||||
return sysParamRepo.save(NewSysparam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysParamEntity updatelogo(int id, SysParamEntity sysparam) throws JsonProcessingException {
|
||||
SysParamEntity NewSysparam = sysParamRepo.findById(id).orElse(null);
|
||||
if (NewSysparam == null) {
|
||||
sysparam.setId(id);
|
||||
return sysParamRepo.save(sysparam);
|
||||
}
|
||||
|
||||
if (sysparam.getUpload_Logo_name() != null && sysparam.getUpload_Logo_path() != null) {
|
||||
NewSysparam.setUpload_Logo_name(sysparam.getUpload_Logo_name());
|
||||
NewSysparam.setUpload_Logo_path(sysparam.getUpload_Logo_path());
|
||||
}
|
||||
if (sysparam.getCompany_Display_Name() != null) {
|
||||
NewSysparam.setCompany_Display_Name(sysparam.getCompany_Display_Name());
|
||||
}
|
||||
|
||||
return sysParamRepo.save(NewSysparam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upload_logo(MultipartFile file, String uploadPath) {
|
||||
if (file.isEmpty()) {
|
||||
throw new StorageException("Failed to store empty file");
|
||||
}
|
||||
try {
|
||||
String fileName = file.getOriginalFilename();
|
||||
String ext = fileName != null && fileName.contains(".") ? fileName.substring(fileName.lastIndexOf(".")) : "";
|
||||
String newName = "profile-pic-" + ext;
|
||||
|
||||
File convFile = new File(
|
||||
System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + newName);
|
||||
file.transferTo(convFile);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
String msg = String.format("Failed to store file %s", file.getName());
|
||||
log.info(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysParamUpload> addallattachments(List<SysParamUpload> attachments) {
|
||||
for (SysParamUpload at : attachments) {
|
||||
sysparamUploadRepo.save(at);
|
||||
}
|
||||
return attachments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysParamUpload> getallattachmentsbyid(int sys_param_entity_id) {
|
||||
return sysparamUploadRepo.findAllById(sys_param_entity_id);
|
||||
}
|
||||
|
||||
public SysParamEntity updateCompNameAndLogo(int id, SysParamEntity sysparam) throws JsonProcessingException {
|
||||
SysParamEntity NewSysparam = sysParamRepo.findById(id).orElse(null);
|
||||
if (NewSysparam == null) {
|
||||
sysparam.setId(id);
|
||||
return sysParamRepo.save(sysparam);
|
||||
}
|
||||
if (sysparam.getUpload_Logo() != null) {
|
||||
NewSysparam.setUpload_Logo(sysparam.getUpload_Logo());
|
||||
}
|
||||
if (sysparam.getCompany_Display_Name() != null) {
|
||||
NewSysparam.setCompany_Display_Name(sysparam.getCompany_Display_Name());
|
||||
}
|
||||
return sysParamRepo.save(NewSysparam);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ 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.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -60,6 +61,8 @@ public class RoleController {
|
||||
/* ========WORKING CODE ======= */
|
||||
// add or remove a Role on a user
|
||||
@GetMapping("org-users/{id}/add-roles/{roleId}")
|
||||
@PutMapping("org-users/{id}/add-roles/{roleId}")
|
||||
@PostMapping("org-users/{id}/add-roles/{roleId}")
|
||||
public ResponseEntity<?> addRole(@PathVariable("id") String id, @PathVariable("roleId") String roleId) {
|
||||
roleService.addRole(id, roleId);
|
||||
Map<String, String> res = new HashMap<String, String>();
|
||||
@@ -68,6 +71,8 @@ public class RoleController {
|
||||
}
|
||||
|
||||
@GetMapping("org-users/{id}/remove-roles/{roleId}")
|
||||
@PutMapping("org-users/{id}/remove-roles/{roleId}")
|
||||
@PostMapping("org-users/{id}/remove-roles/{roleId}")
|
||||
public ResponseEntity<?> removeRole(@PathVariable("id") String id, @PathVariable("roleId") String roleId) {
|
||||
roleService.removeRole(id, roleId);
|
||||
Map<String, String> res = new HashMap<String, String>();
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
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.RequestParam;
|
||||
@@ -89,13 +90,24 @@ public class UserController {
|
||||
}
|
||||
|
||||
// UPDATE (ADMIN, USER BOTH, WHO IS LOGGED IN)
|
||||
// @ApiOperation(value = "Update current user information", response = User.class)
|
||||
// @PutMapping("/user-profile")
|
||||
// public ResponseEntity<?> updateUserProfile(@Valid @RequestBody UserProfileDTO userRequest) {
|
||||
// String loggedInUserEmail = userService.getLoggedInUserEmail();
|
||||
// AppUser user = userService.updateAppUserDto(userRequest);
|
||||
// return new ResponseEntity<>(user, HttpStatus.ACCEPTED);
|
||||
// }
|
||||
@ApiOperation(value = "Update current user information", response = AppUser.class)
|
||||
@PutMapping("/user-profile")
|
||||
public ResponseEntity<?> updateUserProfile(@RequestBody AppUser userRequest) {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
if (loggedInUser == null) {
|
||||
return new ResponseEntity<>("User not found", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
if (userRequest.getFullName() != null) loggedInUser.setFullName(userRequest.getFullName());
|
||||
if (userRequest.getEmail() != null) loggedInUser.setEmail(userRequest.getEmail());
|
||||
if (userRequest.getUsername() != null) loggedInUser.setUsername(userRequest.getUsername());
|
||||
if (userRequest.getMob_no() != null) loggedInUser.setMob_no(userRequest.getMob_no());
|
||||
if (userRequest.getTitle() != null) loggedInUser.setTitle(userRequest.getTitle());
|
||||
if (userRequest.getShortName() != null) loggedInUser.setShortName(userRequest.getShortName());
|
||||
if (userRequest.getAbout() != null) loggedInUser.setAbout(userRequest.getAbout());
|
||||
loggedInUser.setUpdatedate(new Date());
|
||||
AppUser updated = appUserRepository.save(loggedInUser);
|
||||
return new ResponseEntity<>(updated, HttpStatus.ACCEPTED);
|
||||
}
|
||||
|
||||
// UPLOAD IMAGE
|
||||
@PostMapping("/upload")
|
||||
@@ -190,94 +202,120 @@ public class UserController {
|
||||
// by Gaurav
|
||||
|
||||
@ApiOperation(value = "Reset Password", response = PasswordResetRequest.class)
|
||||
@PostMapping("/reset_password")
|
||||
@PostMapping(value = { "/reset_password", "/reset-password" })
|
||||
@PutMapping(value = { "/reset_password", "/reset-password" })
|
||||
public ResponseEntity<?> resetPasswordnew(@Valid @RequestBody PasswordResetRequest passwordResetReq) {
|
||||
AppUser reset = userService.resetPasswordnew(passwordResetReq);
|
||||
System.out.println("resetPassword() Controller : RESET ? " + reset);
|
||||
Map<String, AppUser> res = new HashMap<String, AppUser>();
|
||||
if (reset!=null) {
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
if (reset != null) {
|
||||
res.put("reset", reset);
|
||||
res.put("message", "Password changed Successfully");
|
||||
return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
|
||||
} else {
|
||||
res.put("reset", reset);
|
||||
res.put("reset", null);
|
||||
res.put("message", "Failed to reset password. Please check your old password and ensure new passwords match.");
|
||||
return new ResponseEntity<>(res, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Forgot password", response = PasswordResetRequest.class)
|
||||
@PostMapping("/forgot_password")
|
||||
@PostMapping(value = { "/forgot_password", "/forgot-password" })
|
||||
@PutMapping(value = { "/forgot_password", "/forgot-password" })
|
||||
public ResponseEntity<?> forgotpassword(@Valid @RequestBody PasswordResetRequest passwordResetReq) {
|
||||
AppUser reset = userService.forgotpassword(passwordResetReq);
|
||||
System.out.println("resetPassword() Controller : RESET ? " + reset);
|
||||
Map<String, AppUser> res = new HashMap<String, AppUser>();
|
||||
if (reset!=null) {
|
||||
System.out.println("forgotpassword() Controller : RESET ? " + reset);
|
||||
Map<String, Object> res = new HashMap<>();
|
||||
if (reset != null) {
|
||||
res.put("reset", reset);
|
||||
res.put("message", "Password changed Successfully");
|
||||
return new ResponseEntity<>(res, HttpStatus.ACCEPTED);
|
||||
} else {
|
||||
res.put("reset", reset);
|
||||
res.put("reset", null);
|
||||
res.put("message", "Failed to reset password.");
|
||||
return new ResponseEntity<>(res, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Reset password by email sending
|
||||
// Reset password by email sending
|
||||
@PostMapping("/resources/forgotpassword")
|
||||
public ResponseEntity<?> resetPassword(HttpServletRequest request,
|
||||
@RequestParam("email") String email) {
|
||||
AppUser user = userService.findUserByEmail(email);
|
||||
if (user == null) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(new MessageResponse(email +" not found"));
|
||||
}else {
|
||||
String token = UUID.randomUUID().toString();
|
||||
userService.createPasswordResetTokenForUser(user, token);
|
||||
|
||||
String em = user.getEmail();
|
||||
String subject = "Pass reset";
|
||||
String url = "http://"+Port_Constant.LOCAL_HOST+":"+Port_Constant.FRONTEND_PORT_9191+"/#/forgotresetpassword/" +token;
|
||||
// String url = "http://surecns.ml:30165/#/forgotresetpassword/" + token;
|
||||
// String url = "http://localhost:9191/api" + "/resources/savePassword/" + token;
|
||||
emailService.constructEmail(em, subject, url);
|
||||
return new ResponseEntity<>("Email sent success",HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestParam(value = "email", required = false) String email,
|
||||
@RequestBody(required = false) Map<String, Object> body) {
|
||||
String targetEmail = email;
|
||||
if ((targetEmail == null || targetEmail.trim().isEmpty()) && body != null) {
|
||||
if (body.get("email") != null) {
|
||||
targetEmail = body.get("email").toString();
|
||||
}
|
||||
}
|
||||
if (targetEmail == null || targetEmail.trim().isEmpty()) {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("Email is required"));
|
||||
}
|
||||
targetEmail = targetEmail.trim();
|
||||
AppUser user = userService.findUserByEmail(targetEmail);
|
||||
if (user == null) {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse(targetEmail + " not found"));
|
||||
} else {
|
||||
String token = UUID.randomUUID().toString();
|
||||
userService.createPasswordResetTokenForUser(user, token);
|
||||
|
||||
String em = user.getEmail();
|
||||
String subject = "Pass reset";
|
||||
String url = "http://" + Port_Constant.LOCAL_HOST + ":" + Port_Constant.FRONTEND_PORT_9191 + "/#/forgotresetpassword/" + token;
|
||||
try {
|
||||
emailService.constructEmail(em, subject, url);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Email send error: " + e.getMessage());
|
||||
}
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("message", "Email sent success");
|
||||
resp.put("token", token);
|
||||
return new ResponseEntity<>(resp, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// get email save link
|
||||
@PostMapping("/resources/savePassword/{token}")
|
||||
public ResponseEntity<?> savePassword( @PathVariable String token,
|
||||
@PutMapping("/resources/savePassword/{token}")
|
||||
public ResponseEntity<?> savePassword(@PathVariable String token,
|
||||
@Valid @RequestBody PasswordResetRequest passwordResetReq) {
|
||||
|
||||
|
||||
PasswordResetToken resetToken = passwordTokenRepository.findByToken(token);
|
||||
if (resetToken == null) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(new MessageResponse("Token expire"));
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("Token expire or invalid"));
|
||||
}
|
||||
|
||||
// AppUser a = appUserRepository.findById(resetToken.getUser().getUserId()).orElse(null);
|
||||
AppUser a = appUserRepository.findByEmail(resetToken.getUser().getEmail());
|
||||
|
||||
if(a!=null) {
|
||||
|
||||
if (passwordResetReq.getNewPassword().equals(passwordResetReq.getConfirmPassword())){
|
||||
|
||||
a.setUserPassw(bcryptEncoder.encode(passwordResetReq.getNewPassword()));
|
||||
a.setPwdChangedCnt(a.getPwdChangedCnt()!=null?(long)1+a.getPwdChangedCnt():(long)1);
|
||||
AppUser a = null;
|
||||
if (resetToken.getUser() != null) {
|
||||
if (resetToken.getUser().getEmail() != null) {
|
||||
a = appUserRepository.findByEmail(resetToken.getUser().getEmail());
|
||||
}
|
||||
if (a == null && resetToken.getUser().getUserId() != null) {
|
||||
a = appUserRepository.findById(resetToken.getUser().getUserId());
|
||||
}
|
||||
}
|
||||
if (a == null && passwordResetReq.getEmail() != null) {
|
||||
a = appUserRepository.findByEmail(passwordResetReq.getEmail());
|
||||
}
|
||||
|
||||
if (a != null) {
|
||||
String newPass = passwordResetReq.getNewPassword();
|
||||
String confirmPass = passwordResetReq.getConfirmPassword();
|
||||
if (newPass != null && newPass.equals(confirmPass)) {
|
||||
a.setUserPassw(bcryptEncoder.encode(newPass));
|
||||
a.setPwdChangedCnt(a.getPwdChangedCnt() != null ? (long) 1 + a.getPwdChangedCnt() : (long) 1);
|
||||
a.setLastPwdChangedDate(new Date());
|
||||
a.setChangePassw(passwordResetReq.getNewPassword());
|
||||
|
||||
a.setChangePassw(newPass);
|
||||
|
||||
appUserRepository.save(a);
|
||||
passwordTokenRepository.delete(resetToken);
|
||||
try {
|
||||
passwordTokenRepository.delete(resetToken);
|
||||
} catch (Exception e) {}
|
||||
return new ResponseEntity<>(a, HttpStatus.OK);
|
||||
}
|
||||
return ResponseEntity.badRequest()
|
||||
.body(new MessageResponse("password and confirm password not match"));
|
||||
}
|
||||
return ResponseEntity.badRequest()
|
||||
.body(new MessageResponse("user not found"));
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("password and confirm password not match"));
|
||||
}
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("user not found"));
|
||||
}
|
||||
|
||||
|
||||
@@ -400,13 +438,56 @@ public class UserController {
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(user);
|
||||
// }
|
||||
|
||||
// GET profile details (user ADDED BY ADMIN)
|
||||
@ApiOperation(value = "Get Company User Details", response = AppUser.class)
|
||||
@GetMapping("/org-users")
|
||||
public ResponseEntity<?> getUsersByAccount() {
|
||||
List<AppUser> users = this.userService.getAllUsers();
|
||||
return ResponseEntity.ok().body(users);
|
||||
}
|
||||
|
||||
// GET USER BY ID (ADDED BY ADMIN)
|
||||
@ApiOperation(value = "Get Company User By Id", response = AppUser.class)
|
||||
@GetMapping("/org-users/{id}")
|
||||
public ResponseEntity<?> getUserById(@PathVariable(value = "id") Long id) {
|
||||
AppUser user = appUserRepository.findById(id);
|
||||
if (user == null) {
|
||||
user = userService.getById(id);
|
||||
}
|
||||
if (user == null) {
|
||||
return new ResponseEntity<>("User Not Found ::" + id, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return ResponseEntity.ok().body(user);
|
||||
}
|
||||
|
||||
// UPDATE USER ADDED BY ADMIN
|
||||
// @ApiOperation(value = "Update A Company User", response = User.class)
|
||||
// @PutMapping("/org-users/{id}")
|
||||
// public ResponseEntity<?> updateUser(@PathVariable(value = "id") Long id, @Valid @RequestBody User user) {
|
||||
// User updatedUser = userService.updateById(id, user);
|
||||
// return ResponseEntity.status(HttpStatus.ACCEPTED).body(updatedUser);
|
||||
// }
|
||||
@ApiOperation(value = "Update A Company User", response = AppUser.class)
|
||||
@PutMapping("/org-users/{id}")
|
||||
public ResponseEntity<?> updateUser(@PathVariable(value = "id") Long id, @RequestBody AppUser user) {
|
||||
AppUser existing = appUserRepository.findById(id);
|
||||
if (existing == null) {
|
||||
existing = userService.getById(id);
|
||||
}
|
||||
if (existing != null) {
|
||||
if (user.getFullName() != null) existing.setFullName(user.getFullName());
|
||||
if (user.getEmail() != null) existing.setEmail(user.getEmail());
|
||||
if (user.getUsername() != null) existing.setUsername(user.getUsername());
|
||||
if (user.getMob_no() != null) existing.setMob_no(user.getMob_no());
|
||||
if (user.getStatus() != null) existing.setStatus(user.getStatus());
|
||||
if (user.getUsrGrp() != null) existing.setUsrGrp(user.getUsrGrp());
|
||||
if (user.getDepartmentCode() != null) existing.setDepartmentCode(user.getDepartmentCode());
|
||||
if (user.getPositionCode() != null) existing.setPositionCode(user.getPositionCode());
|
||||
if (user.getTitle() != null) existing.setTitle(user.getTitle());
|
||||
if (user.getShortName() != null) existing.setShortName(user.getShortName());
|
||||
existing.setActive(user.isActive());
|
||||
existing.setUpdatedate(new Date());
|
||||
AppUser updatedUser = appUserRepository.save(existing);
|
||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(updatedUser);
|
||||
}
|
||||
user.setUserId(id);
|
||||
AppUser saved = appUserRepository.save(user);
|
||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(saved);
|
||||
}
|
||||
|
||||
// DELETE USER ADDED BY ADMIN
|
||||
// @DeleteMapping("/org-users/{id}")
|
||||
|
||||
@@ -110,8 +110,11 @@ public class AppUserController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/updateAppUser")
|
||||
public ResponseEntity<?> updateOneUser(@RequestBody AppUser appUser) {
|
||||
@PutMapping({"/updateAppUser", "/updateAppUser/{userId}"})
|
||||
public ResponseEntity<?> updateOneUser(@PathVariable(required = false) Long userId, @RequestBody AppUser appUser) {
|
||||
if (userId != null && appUser.getUserId() == null) {
|
||||
appUser.setUserId(userId);
|
||||
}
|
||||
AppUser a = appUserServiceImpl.updateOneUser(appUser);
|
||||
return new ResponseEntity<>(a, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ 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;
|
||||
@@ -21,7 +22,7 @@ import com.realnet.users.repository1.AppUserRoleRepository;
|
||||
import com.realnet.users.service1.AppUserRoleServiceImpl;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/token/api")
|
||||
@RequestMapping(value = { "/api", "/token/api" })
|
||||
public class AppUserGrpController {
|
||||
private AppUserRoleServiceImpl appUserRoleServiceImpl;
|
||||
|
||||
@@ -72,9 +73,28 @@ public class AppUserGrpController {
|
||||
return new ResponseEntity<>(a, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/updateOneUsrGrp")
|
||||
public ResponseEntity<?> updateOne(@RequestBody AppUserRole appUserRole) {
|
||||
AppUserRole a = appUserRoleServiceImpl.addOne(appUserRole);
|
||||
@PostMapping({"/updateOneUsrGrp", "/updateOneUsrGrp/{id}"})
|
||||
@PutMapping({"/updateOneUsrGrp", "/updateOneUsrGrp/{id}"})
|
||||
public ResponseEntity<?> updateOne(@PathVariable(required = false) Long id, @RequestBody AppUserRole appUserRole) {
|
||||
if (id != null && appUserRole.getUsrGrp() == null) {
|
||||
appUserRole.setUsrGrp(id);
|
||||
}
|
||||
AppUserRole a;
|
||||
if (appUserRole.getUsrGrp() != null) {
|
||||
AppUserRole existing = appUserRoleRepository.findById(appUserRole.getUsrGrp());
|
||||
if (existing != null) {
|
||||
if (appUserRole.getGroupName() != null) existing.setGroupName(appUserRole.getGroupName());
|
||||
if (appUserRole.getGroupDesc() != null) existing.setGroupDesc(appUserRole.getGroupDesc());
|
||||
if (appUserRole.getStatus() != null) existing.setStatus(appUserRole.getStatus());
|
||||
if (appUserRole.getGroupLevel() != null) existing.setGroupLevel(appUserRole.getGroupLevel());
|
||||
existing.setUpdatedate(new java.util.Date());
|
||||
a = appUserRoleServiceImpl.updateOne(existing);
|
||||
} else {
|
||||
a = appUserRoleServiceImpl.updateOne(appUserRole);
|
||||
}
|
||||
} else {
|
||||
a = appUserRoleServiceImpl.updateOne(appUserRole);
|
||||
}
|
||||
return new ResponseEntity<>(a, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
@@ -14,8 +16,9 @@ import com.realnet.session.entity.AboutWork;
|
||||
import com.realnet.users.entity.Sys_Accounts;
|
||||
import com.realnet.users.repository.AboutWorkRepo;
|
||||
import com.realnet.users.repository.SysAccountRepo;
|
||||
import com.realnet.users.service1.SysAccountService;
|
||||
|
||||
@RequestMapping("/token/users/sysaccount")
|
||||
@RequestMapping({ "/token/users/sysaccount", "/users/sysaccount" })
|
||||
@RestController
|
||||
public class SysAccountController {
|
||||
|
||||
@@ -25,14 +28,25 @@ public class SysAccountController {
|
||||
@Autowired
|
||||
private AboutWorkRepo aboutWorkRepo;
|
||||
|
||||
@Autowired
|
||||
private SysAccountService accountService;
|
||||
|
||||
@PostMapping("/savesysaccount")
|
||||
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 update(@PathVariable Long accId, @RequestBody Sys_Accounts sys_Accounts) {
|
||||
Sys_Accounts save = accountService.update(accId, sys_Accounts);
|
||||
|
||||
System.out.println("updated account data is .." + save);
|
||||
return save;
|
||||
}
|
||||
|
||||
@PostMapping("/addaccountcusto")
|
||||
public AboutWork addaccountcusto(@RequestBody AboutWork aWork) {
|
||||
|
||||
|
||||
@@ -1,137 +1,129 @@
|
||||
//package com.realnet.users.controller1;
|
||||
//
|
||||
//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.RequestBody;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||
//import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||
//import com.realnet.Workspaceuser.Repository.SecWorkspaceUserRepo;
|
||||
//import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
||||
//import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
||||
//import com.realnet.users.entity1.AppUser;
|
||||
//import com.realnet.users.repository1.AppUserRepository;
|
||||
//import com.realnet.users.response.MessageResponse;
|
||||
//import com.realnet.users.service1.AppUserServiceImpl;
|
||||
//
|
||||
//@RestController
|
||||
//@RequestMapping("/User_workSpace")
|
||||
//public class WorkSpaceController1 {
|
||||
// @Autowired
|
||||
// private AppUserServiceImpl userService;
|
||||
//
|
||||
// @Autowired
|
||||
// private AppUserRepository appUserRepository;
|
||||
// @Autowired
|
||||
// private Sec_teams_Repository sec_teams_Repository;
|
||||
//
|
||||
// @Autowired
|
||||
// private Sec_team_MemberRepository memberRepository;
|
||||
//
|
||||
// @Autowired
|
||||
// private SecWorkspaceUserRepo secWorkspaceUserRepo;
|
||||
//
|
||||
// //GET ALL USER attach from login id
|
||||
// @GetMapping("/GetAll")
|
||||
// public ResponseEntity<?> getall(){
|
||||
// AppUser loggedInUser = userService.getLoggedInUser();
|
||||
// Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||
//
|
||||
// List<AppUser> li = appUserRepository.getall(account_id);
|
||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
||||
// }
|
||||
//
|
||||
// //ADD USER TO SPECIFIC TEAM
|
||||
// @PostMapping("/add_team/{id}/{userId}")
|
||||
// public ResponseEntity<?> addteam(@RequestBody Sec_team_members team_mem,
|
||||
// @PathVariable int id,@PathVariable Long userId){
|
||||
// Sec_team_members members = memberRepository.findteammember(id,userId);
|
||||
// if(members == null) {
|
||||
//
|
||||
// Sec_teams team = sec_teams_Repository.findById(id);
|
||||
// if(team != null) {
|
||||
//
|
||||
// AppUser user = appUserRepository.findById(userId).orElseThrow(null);
|
||||
//
|
||||
// team_mem.setTeam_id(team.getId());
|
||||
// team_mem.setMember_name(user.getFullName());
|
||||
// team_mem.setMember_id(user.getUserId());
|
||||
// Sec_team_members save = memberRepository.save(team_mem);
|
||||
//
|
||||
//
|
||||
// return new ResponseEntity<>(save, HttpStatus.OK);
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
||||
// }
|
||||
// else
|
||||
// return ResponseEntity.badRequest().body(new MessageResponse("member already added"));
|
||||
// }
|
||||
//
|
||||
// //REMOVE MEMBER FROM TEAM
|
||||
// @DeleteMapping("/RemoveMember/{id}/{userId}")
|
||||
// public MessageResponse removemember(@PathVariable int id,@PathVariable Long userId){
|
||||
// Sec_team_members members = memberRepository.findteammember(id,userId);
|
||||
// if(members != null) {
|
||||
// memberRepository.delete(members);
|
||||
// return new MessageResponse("deleted");
|
||||
// }else
|
||||
//
|
||||
// return new MessageResponse("member not found");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //GET ALL USER ADD BY ADMIN
|
||||
// @GetMapping("/GetAllUser")
|
||||
// public ResponseEntity<?> GetUser(){
|
||||
// AppUser loggedInUser = userService.getLoggedInUser();
|
||||
// Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||
//
|
||||
// List<AppUser> li = appUserRepository.getalluser(account_id);
|
||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
||||
// }
|
||||
//
|
||||
// //GET ALL GUEST ADD BY ADMIN
|
||||
// @GetMapping("/GetAllGuest")
|
||||
// public ResponseEntity<?> Getguest(){
|
||||
// AppUser loggedInUser = userService.getLoggedInUser();
|
||||
// Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||
//
|
||||
// List<AppUser> li = appUserRepository.getallguest(account_id);
|
||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
||||
// }
|
||||
//
|
||||
// //GET ALL TEAM MEMBER FROM SPECIFIC TEAM
|
||||
// @GetMapping("/GetAllMember/{team_id}")
|
||||
// public ResponseEntity<?> GetAllteamMember(@PathVariable int team_id){
|
||||
//
|
||||
//
|
||||
// List<Sec_team_members> li = memberRepository.getallteam(team_id);
|
||||
// if(li == null) {
|
||||
// return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
||||
// }else
|
||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
package com.realnet.users.controller1;
|
||||
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||
import com.realnet.Workspaceuser.Repository.SecWorkspaceUserRepo;
|
||||
import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
||||
import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.repository1.AppUserRepository;
|
||||
import com.realnet.users.response.MessageResponse;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/User_workSpace")
|
||||
public class WorkSpaceController1 {
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
@Autowired
|
||||
private AppUserRepository appUserRepository;
|
||||
|
||||
@Autowired
|
||||
private Sec_teams_Repository sec_teams_Repository;
|
||||
|
||||
@Autowired
|
||||
private Sec_team_MemberRepository memberRepository;
|
||||
|
||||
@Autowired
|
||||
private SecWorkspaceUserRepo secWorkspaceUserRepo;
|
||||
|
||||
// GET ALL USER attach from login id
|
||||
@GetMapping("/GetAll")
|
||||
public ResponseEntity<?> getall() {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
Long account_id = (loggedInUser != null && loggedInUser.getAccount() != null)
|
||||
? loggedInUser.getAccount().getAccount_id()
|
||||
: 0L;
|
||||
|
||||
List<AppUser> li = appUserRepository.getall(account_id);
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// ADD USER TO SPECIFIC TEAM
|
||||
@PostMapping("/add_team/{id}/{userId}")
|
||||
public ResponseEntity<?> addteam(@RequestBody Sec_team_members team_mem,
|
||||
@PathVariable int id, @PathVariable Long userId) {
|
||||
Sec_team_members members = memberRepository.findteammember(id, userId);
|
||||
if (members == null) {
|
||||
Sec_teams team = sec_teams_Repository.findById(id);
|
||||
if (team != null) {
|
||||
AppUser user = appUserRepository.findById(userId);
|
||||
if (user == null) {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("user not found"));
|
||||
}
|
||||
|
||||
team_mem.setTeam_id(team.getId());
|
||||
team_mem.setMember_name(user.getFullName());
|
||||
team_mem.setMember_id(user.getUserId());
|
||||
Sec_team_members save = memberRepository.save(team_mem);
|
||||
|
||||
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||
} else {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
||||
}
|
||||
} else {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("member already added"));
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE MEMBER FROM TEAM
|
||||
@DeleteMapping("/RemoveMember/{id}/{userId}")
|
||||
public MessageResponse removemember(@PathVariable int id, @PathVariable Long userId) {
|
||||
Sec_team_members members = memberRepository.findteammember(id, userId);
|
||||
if (members != null) {
|
||||
memberRepository.delete(members);
|
||||
return new MessageResponse("deleted");
|
||||
} else {
|
||||
return new MessageResponse("member not found");
|
||||
}
|
||||
}
|
||||
|
||||
// GET ALL USER ADD BY ADMIN
|
||||
@GetMapping("/GetAllUser")
|
||||
public ResponseEntity<?> GetUser() {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
Long account_id = (loggedInUser != null && loggedInUser.getAccount() != null)
|
||||
? loggedInUser.getAccount().getAccount_id()
|
||||
: 0L;
|
||||
|
||||
List<AppUser> li = appUserRepository.getalluser(account_id);
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// GET ALL GUEST ADD BY ADMIN
|
||||
@GetMapping("/GetAllGuest")
|
||||
public ResponseEntity<?> Getguest() {
|
||||
AppUser loggedInUser = userService.getLoggedInUser();
|
||||
Long account_id = (loggedInUser != null && loggedInUser.getAccount() != null)
|
||||
? loggedInUser.getAccount().getAccount_id()
|
||||
: 0L;
|
||||
|
||||
List<AppUser> li = appUserRepository.getallguest(account_id);
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// GET ALL TEAM MEMBER FROM SPECIFIC TEAM
|
||||
@GetMapping("/GetAllMember/{team_id}")
|
||||
public ResponseEntity<?> GetAllteamMember(@PathVariable int team_id) {
|
||||
List<Sec_team_members> li = memberRepository.getallteam(team_id);
|
||||
if (li == null) {
|
||||
return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
||||
} else {
|
||||
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.realnet.users.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
@@ -10,19 +12,21 @@ import com.realnet.users.entity.Role;
|
||||
|
||||
@Repository
|
||||
public interface RoleRepo extends MongoRepository<Role, String> {
|
||||
// for pagination
|
||||
|
||||
|
||||
@Query("{}")
|
||||
Page<Role> findAll(Pageable p);
|
||||
|
||||
@Query("{'name': ?0}")
|
||||
Role findByName(String name);
|
||||
|
||||
|
||||
List<Role> findAllByName(String name);
|
||||
|
||||
default Role findByName(String name) {
|
||||
List<Role> list = findAllByName(name);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Role getOne(String id);
|
||||
|
||||
|
||||
@Query("{'id': ?0}")
|
||||
Role findById(int id);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.realnet.users.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -7,12 +9,21 @@ import org.springframework.stereotype.Repository;
|
||||
import com.realnet.users.entity.Sys_Accounts;
|
||||
|
||||
@Repository
|
||||
public interface SysAccountRepo extends MongoRepository<Sys_Accounts,String > {
|
||||
|
||||
@Query("{'email': ?0}")
|
||||
Sys_Accounts findByEmail(String email);
|
||||
|
||||
@Query("{'account_id': ?0}")
|
||||
Sys_Accounts findById(Long account_id);
|
||||
public interface SysAccountRepo extends MongoRepository<Sys_Accounts, String> {
|
||||
|
||||
@Query("{'email': ?0}")
|
||||
List<Sys_Accounts> findAllByEmail(String email);
|
||||
|
||||
default Sys_Accounts findByEmail(String email) {
|
||||
List<Sys_Accounts> list = findAllByEmail(email);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
@Query("{'account_id': ?0}")
|
||||
List<Sys_Accounts> findAllById(Long account_id);
|
||||
|
||||
default Sys_Accounts findById(Long account_id) {
|
||||
List<Sys_Accounts> list = findAllById(account_id);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.realnet.users.repository1;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -12,85 +10,82 @@ import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.fnd.entity1.GrpMenuAccess;
|
||||
import com.realnet.users.entity.Role;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
@Repository
|
||||
public interface AppUserRepository extends MongoRepository<AppUser, String> {
|
||||
|
||||
@Query("{'username': ?0}")
|
||||
Optional<AppUser> findByUsername(String username);
|
||||
List<AppUser> findAllByUsername(String username);
|
||||
|
||||
// AppUser findByEmail(String email);
|
||||
default Optional<AppUser> findByUsername(String username) {
|
||||
List<AppUser> list = findAllByUsername(username);
|
||||
return (list != null && !list.isEmpty()) ? Optional.of(list.get(0)) : Optional.empty();
|
||||
}
|
||||
|
||||
@Query("{'username': ?0, 'userPassw': ?1}")
|
||||
Optional<AppUser> findByUsernameAndUserPassw(String username, String userPassw);
|
||||
List<AppUser> findAllByUsernameAndUserPassw(String username, String userPassw);
|
||||
|
||||
// Boolean existsByEmail(String email);
|
||||
|
||||
default Optional<AppUser> findByUsernameAndUserPassw(String username, String userPassw) {
|
||||
List<AppUser> list = findAllByUsernameAndUserPassw(username, userPassw);
|
||||
return (list != null && !list.isEmpty()) ? Optional.of(list.get(0)) : Optional.empty();
|
||||
}
|
||||
|
||||
// @Query(value = "SELECT customer_number FROM be_cust_master WHERE customer_id = ?1", countQuery = "SELECT count(*) FROM be_cust_master WHERE customer_id = ?1", nativeQuery = true)
|
||||
// @Query("{'customer_id': ?0}")
|
||||
// String getCustomerNumber(BigDecimal customerId);
|
||||
|
||||
// @Query(value = "select refcodedesc from refcodedet where reftype = ?1 and refcode = ?2", countQuery = "select refcodedesc from refcodedet where reftype = ?1 and refcode = ?2", nativeQuery = true)
|
||||
// @Query("{'reftype': ?0, 'refcode': ?1}")
|
||||
// String getStatus(String tableName, String code);
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.email =?1", nativeQuery = true)
|
||||
@Query("{'email': ?0}")
|
||||
AppUser findByEmail(String email);
|
||||
List<AppUser> findAllByEmail(String email);
|
||||
|
||||
default AppUser findByEmail(String email) {
|
||||
List<AppUser> list = findAllByEmail(email);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.user_name =?1", nativeQuery = true)
|
||||
@Query("{'email': ?0}")
|
||||
AppUser findByUserName(String email);
|
||||
// AppUser findByUsername(String username);
|
||||
List<AppUser> findAllByUserName(String email);
|
||||
|
||||
default AppUser findByUserName(String email) {
|
||||
List<AppUser> list = findAllByUserName(email);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.random_no = ?1", nativeQuery = true)
|
||||
@Query("{'random_no': ?0}")
|
||||
AppUser findByToken(String random_no);
|
||||
List<AppUser> findAllByToken(String random_no);
|
||||
|
||||
default AppUser findByToken(String random_no) {
|
||||
List<AppUser> list = findAllByToken(random_no);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_grp_menu_access a where a.usr_grp= ?1", nativeQuery = true)
|
||||
@Query("{'usr_grp': ?0}")
|
||||
GrpMenuAccess findByUsrGrp(Long usr_grp);
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.account_id =?1", nativeQuery = true)
|
||||
@Query("{'account_id': ?0}")
|
||||
List<AppUser> getall(Long account_id);
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.usr_grp=42 and a.account_id =?1", nativeQuery = true)
|
||||
@Query("{'usr_grp': ?0, 'account_id': ?1}")
|
||||
@Query("{'usr_grp': 42, 'account_id': ?0}")
|
||||
List<AppUser> getalluser(Long account_id);
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.usr_grp=45 and a.account_id =?1", nativeQuery = true)
|
||||
@Query("{'usr_grp': ?0, 'account_id': ?1}")
|
||||
@Query("{'usr_grp': 45, 'account_id': ?0}")
|
||||
List<AppUser> getallguest(Long account_id);
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.user_id =?1", nativeQuery = true)
|
||||
@Query("{'user_id': ?0}")
|
||||
AppUser findByUserId(Long id);
|
||||
List<AppUser> findAllByUserIdLegacy(Long id);
|
||||
|
||||
default AppUser findByUserId(Long id) {
|
||||
List<AppUser> list = findAllByUserIdLegacy(id);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users where user_name LIKE %:keyword% ", nativeQuery = true)
|
||||
@Query("{'user_name': { $regex: ?0, $options: 'i' }}")
|
||||
// List<AppUser> SearchByKeyword(@Param("keyword") String keyword);
|
||||
List<AppUser> SearchByKeyword(String keyword);
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.active =true", nativeQuery = true)
|
||||
@Query("{'active': true}")
|
||||
Page<AppUser> getallusers(Pageable page);
|
||||
|
||||
// @Query(value = "SELECT * FROM sec_users a where a.user_id =?1 && access_till_date >= NOW();", nativeQuery = true)
|
||||
// AppUser findusertilldate(Long id);
|
||||
// AppUser findByIdAndAccessTillDateGreaterThan(Long id, Date currentDate);
|
||||
|
||||
// List<AppUser> findByFullNameContaining(String keyword);
|
||||
|
||||
// @Query("{'id': ?0}")
|
||||
// Optional<Role> findById(Long userId);
|
||||
|
||||
@Query("{'userId': ?0}")
|
||||
AppUser findById(Long userId);
|
||||
|
||||
|
||||
List<AppUser> findAllByUserId(Long userId);
|
||||
|
||||
default AppUser findById(Long userId) {
|
||||
List<AppUser> list = findAllByUserId(userId);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package com.realnet.users.repository1;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.entity1.AppUserRole;
|
||||
import com.realnet.users.entity1.AppUserSessions;
|
||||
|
||||
@Repository
|
||||
public interface AppUserRoleRepository extends MongoRepository<AppUserRole, String> {
|
||||
|
||||
@Query("{'usrGrp': ?0}")
|
||||
AppUserRole findById(Long usrGrp);
|
||||
List<AppUserRole> findAllById(Long usrGrp);
|
||||
|
||||
default AppUserRole findById(Long usrGrp) {
|
||||
List<AppUserRole> list = findAllById(usrGrp);
|
||||
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
||||
}
|
||||
|
||||
Optional<AppUserRole> findTopByOrderByUsrGrpDesc();
|
||||
|
||||
// @Query("{'usrGrpId':?0}")
|
||||
// AppUser findById(Long usrGrpId);
|
||||
|
||||
}
|
||||
|
||||
@@ -350,9 +350,18 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
||||
@Override
|
||||
public AppUser getLoggedInUser() {
|
||||
String loggedInUserName = this.getLoggedInUserEmail();
|
||||
if (loggedInUserName == null || "noSession".equals(loggedInUserName) || "anonymousUser".equals(loggedInUserName)) {
|
||||
return null;
|
||||
}
|
||||
Optional<AppUser> user = appUserRepository.findByUsername(loggedInUserName);
|
||||
// log.info("getLoggedInUser() : {} ", user.get());
|
||||
return user.get();
|
||||
if (user != null && user.isPresent()) {
|
||||
return user.get();
|
||||
}
|
||||
AppUser userByEmail = appUserRepository.findByEmail(loggedInUserName);
|
||||
if (userByEmail != null) {
|
||||
return userByEmail;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -458,16 +467,20 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
||||
return null;
|
||||
}
|
||||
|
||||
public AppUser resetPassword(Long userId, String hash, String newPassword) {
|
||||
|
||||
String string = userId.toString();
|
||||
AppUser a = appUserRepository.findById(string).orElse(null);
|
||||
public AppUser resetPassword(Long userId, String hash, String newPassword) {
|
||||
AppUser a = null;
|
||||
if (userId != null) {
|
||||
a = appUserRepository.findById(userId);
|
||||
if (a == null) {
|
||||
a = appUserRepository.findByUserId(userId);
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
if (a.getPassword4().equals(hash)) {
|
||||
if (a.getPassword4() != null && a.getPassword4().equals(hash)) {
|
||||
a.setUserPassw(bcryptEncoder.encode(newPassword));
|
||||
a.setPwdChangedCnt(a.getPwdChangedCnt() != null ? (long) 1 + a.getPwdChangedCnt() : (long) 1);
|
||||
a.setLastPwdChangedDate(new Date());
|
||||
// a.setPassword4(null);
|
||||
a.setChangePassw(newPassword);
|
||||
appUserRepository.save(a);
|
||||
return a;
|
||||
}
|
||||
@@ -480,15 +493,33 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
||||
// RESET PASSWORD WITH CONFIRM PASSWORD
|
||||
|
||||
public AppUser resetPasswordnew(PasswordResetRequest p) {
|
||||
AppUser a = null;
|
||||
if (p.getUserId() != null) {
|
||||
a = appUserRepository.findById(p.getUserId());
|
||||
if (a == null) {
|
||||
a = appUserRepository.findByUserId(p.getUserId());
|
||||
}
|
||||
}
|
||||
if (a == null && p.getEmail() != null && !p.getEmail().isEmpty()) {
|
||||
a = appUserRepository.findByEmail(p.getEmail());
|
||||
}
|
||||
if (a == null) {
|
||||
try {
|
||||
a = getLoggedInUser();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
Long userId = p.getUserId();
|
||||
String string = userId.toString();
|
||||
AppUser a = appUserRepository.findById(string).orElse(null);
|
||||
if (a != null) {
|
||||
if (bcryptEncoder.matches(p.getOldPassword(), a.getUserPassw())) {
|
||||
|
||||
if (p.getNewPassword().equals(p.getConfirmPassword())) {
|
||||
|
||||
boolean oldMatches = false;
|
||||
if (p.getOldPassword() != null) {
|
||||
if (bcryptEncoder.matches(p.getOldPassword(), a.getUserPassw())
|
||||
|| p.getOldPassword().equals(a.getUserPassw())
|
||||
|| p.getOldPassword().equals(a.getChangePassw())) {
|
||||
oldMatches = true;
|
||||
}
|
||||
}
|
||||
if (oldMatches) {
|
||||
if (p.getNewPassword() != null && p.getNewPassword().equals(p.getConfirmPassword())) {
|
||||
a.setUserPassw(bcryptEncoder.encode(p.getNewPassword()));
|
||||
a.setPwdChangedCnt(a.getPwdChangedCnt() != null ? (long) 1 + a.getPwdChangedCnt() : (long) 1);
|
||||
a.setLastPwdChangedDate(new Date());
|
||||
@@ -508,14 +539,24 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
||||
// FORGOT PASSWORD
|
||||
|
||||
public AppUser forgotpassword(PasswordResetRequest p) {
|
||||
Long userId = p.getUserId();
|
||||
String string = userId.toString();
|
||||
AppUser a = appUserRepository.findById(string).orElse(null);
|
||||
AppUser a = null;
|
||||
if (p.getUserId() != null) {
|
||||
a = appUserRepository.findById(p.getUserId());
|
||||
if (a == null) {
|
||||
a = appUserRepository.findByUserId(p.getUserId());
|
||||
}
|
||||
}
|
||||
if (a == null && p.getEmail() != null && !p.getEmail().isEmpty()) {
|
||||
a = appUserRepository.findByEmail(p.getEmail());
|
||||
}
|
||||
if (a == null) {
|
||||
try {
|
||||
a = getLoggedInUser();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
if (a != null) {
|
||||
|
||||
if (p.getNewPassword().equals(p.getConfirmPassword())) {
|
||||
|
||||
if (p.getNewPassword() != null && p.getNewPassword().equals(p.getConfirmPassword())) {
|
||||
a.setUserPassw(bcryptEncoder.encode(p.getNewPassword()));
|
||||
a.setPwdChangedCnt(a.getPwdChangedCnt() != null ? (long) 1 + a.getPwdChangedCnt() : (long) 1);
|
||||
a.setLastPwdChangedDate(new Date());
|
||||
@@ -527,7 +568,6 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String generateRandomHash(int len) {
|
||||
@@ -568,9 +608,15 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
||||
|
||||
public void createPasswordResetTokenForUser(AppUser user, String token) {
|
||||
AppUser user1 = appUserRepository.findByEmail(user.getEmail());
|
||||
if (user1 == null) {
|
||||
user1 = user;
|
||||
}
|
||||
|
||||
PasswordResetToken myToken = new PasswordResetToken(token);
|
||||
myToken.setUser(user1);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, 60 * 24);
|
||||
myToken.setExpiryDate(cal.getTime());
|
||||
passwordTokenRepository.save(myToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.realnet.users.service1;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.users.entity.Sys_Accounts;
|
||||
import com.realnet.users.repository.SysAccountRepo;
|
||||
|
||||
@Service
|
||||
public class SysAccountService {
|
||||
|
||||
@Autowired
|
||||
private SysAccountRepo sysAccountRepo;
|
||||
|
||||
public Sys_Accounts save(Sys_Accounts sys) {
|
||||
return sysAccountRepo.save(sys);
|
||||
}
|
||||
|
||||
public Sys_Accounts update(Long accountId, Sys_Accounts request) {
|
||||
Sys_Accounts account = sysAccountRepo.findById(accountId);
|
||||
if (account == null) {
|
||||
account = request;
|
||||
account.setAccount_id(accountId);
|
||||
return sysAccountRepo.save(account);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
return sysAccountRepo.save(account);
|
||||
}
|
||||
|
||||
public List<Sys_Accounts> getall() {
|
||||
return sysAccountRepo.findAll();
|
||||
}
|
||||
|
||||
public Sys_Accounts getBYId(Long account_id) {
|
||||
return sysAccountRepo.findById(account_id);
|
||||
}
|
||||
|
||||
public Sys_Accounts findByEmail(String email) {
|
||||
return sysAccountRepo.findByEmail(email);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,19 @@
|
||||
package com.realnet.utils;
|
||||
|
||||
public class Port_Constant {
|
||||
|
||||
// public final static String LOCAL_HOST = "localhost";
|
||||
// public final static String BACKEND_PORT_9191 = "9191";
|
||||
// public final static String FRONTEND_PORT_9191 = "4200";
|
||||
// public final static String SUREOPS_PORT_9090 = "9090";
|
||||
// public final static String JOBPRO_PORT_8087 = "8087";
|
||||
// public final static String SCRIPT_RUNNER_8901 = "8901";
|
||||
// public final static String APP_BUILD_19001 = "19001";
|
||||
// public final static String SURE_JOB_8089 = "8089";
|
||||
// public final static String SURE_COMMUNICATION_19002 = "19002";
|
||||
|
||||
|
||||
|
||||
public final static String LOCAL_HOST = "43.205.154.152";
|
||||
public final static String BACKEND_PORT_9191 = "30166";
|
||||
public final static String FRONTEND_PORT_9191 = "30165";
|
||||
public final static String FRONTEND_PORT_9191 = "30165";
|
||||
public final static String SUREOPS_PORT_9090 = "31123";
|
||||
public final static String JOBPRO_PORT_8087 = "30167";
|
||||
public final static String SCRIPT_RUNNER_8901 = "30168";
|
||||
public final static String APP_BUILD_19001 = "30171";
|
||||
public final static String SURE_JOB_8089 = "30188";
|
||||
public final static String SURE_COMMUNICATION_19002 = "30187";
|
||||
|
||||
public final static String GITEA_IP_ADDRESS = "try.gitea";
|
||||
public final static String GITEA_PORT = "io";
|
||||
|
||||
|
||||
public final static String GITEA_IP_ADDRESS = "try.gitea";
|
||||
public final static String GITEA_PORT = "io";
|
||||
|
||||
public static String SURE_SETU_DOMAIN = "http://" + LOCAL_HOST + ":" + SURE_COMMUNICATION_19002;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# File is used by sprigboot
|
||||
server.contextPath=/*
|
||||
# server.contextPath=/*
|
||||
server.servlet.context-path=/
|
||||
management.health.mongo.enabled=false
|
||||
server.port=9292
|
||||
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/webui/
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
# File is used by sprigboot
|
||||
server.contextPath=/*
|
||||
server.port=9292
|
||||
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/webui/
|
||||
|
||||
spring.banner.location=classpath:banner_txt.txt
|
||||
|
||||
#Temporary disable security to enable it remove this
|
||||
#security.ignored=/**
|
||||
|
||||
springfox.documentation.swagger.v2.path=/api-docs
|
||||
spring.jackson.date-format=yyyy-MM-dd
|
||||
|
||||
|
||||
|
||||
System.Net.ServicePointManager.Expect100Continue = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#spring.data.mongodb.uri=mongodb://gaurav:gaurav123@13.233.70.96:30165/realnet_cns?authSource=admin
|
||||
|
||||
spring.data.mongodb.uri=mongodb+srv://azmat_db_user:064lBmIKyXFPzyLy@cluster0.u9a6g8k.mongodb.net/azzudb
|
||||
# Prefix Path
|
||||
|
||||
|
||||
|
||||
|
||||
# **********paytm dependency ******
|
||||
razorpay.api.key=rzp_test_xVnrBUjJWTEH0r
|
||||
razorpay.api.secret=evTXkIFcgpVtiLa1P7M7CIox
|
||||
|
||||
#***** MAIL SENDER
|
||||
spring.mail.host=smtp.gmail.com
|
||||
spring.mail.username=realitconnect@gmail.com
|
||||
spring.mail.password=tysnukjdimsneiyv
|
||||
spring.mail.port=587
|
||||
#spring.mail.properties.mail.smtp.auth=true
|
||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||
spring.mail.properties.mail.smtp.starttls.required=true
|
||||
|
||||
# JACKSON
|
||||
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
|
||||
|
||||
|
||||
spring.mail.properties.mail.smtp.auth = true
|
||||
spring.mail.properties.mail.smtp.socketFactory.port = 465
|
||||
spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
|
||||
spring.mail.properties.mail.smtp.socketFactory.fallback = false
|
||||
|
||||
#******* MULTIPART RESOLVER
|
||||
spring.servlet.multipart.enabled=true
|
||||
spring.servlet.multipart.max-file-size=100MB
|
||||
spring.servlet.multipart.max-request-size=100MB
|
||||
|
||||
#***************OAUTH2 SOCIAL LOGIN *********
|
||||
# Social login provider props
|
||||
spring.security.oauth2.client.registration.google.clientId=437023664181-0lm0ipgip3qbhga4nd7o4128jv4g2nv9.apps.googleusercontent.com
|
||||
spring.security.oauth2.client.registration.google.clientSecret=I1HPyUqdJ9UONu45W1_wwfww
|
||||
spring.security.oauth2.client.registration.google.scope=profile, email
|
||||
|
||||
|
||||
spring.security.oauth2.client.registration.linkedin.clientId=<your-client-id>
|
||||
spring.security.oauth2.client.registration.linkedin.clientSecret=<your-client-secret>
|
||||
spring.security.oauth2.client.registration.linkedin.client-authentication-method=post
|
||||
spring.security.oauth2.client.registration.linkedin.authorization-grant-type=authorization_code
|
||||
spring.security.oauth2.client.registration.linkedin.scope=r_liteprofile, r_emailaddress
|
||||
spring.security.oauth2.client.registration.linkedin.redirect-uri={baseUrl}/login/oauth2/code/{registrationId}
|
||||
spring.security.oauth2.client.registration.linkedin.client-name=Linkedin
|
||||
spring.security.oauth2.client.registration.linkedin.provider=linkedin
|
||||
spring.security.oauth2.client.provider.linkedin.authorization-uri=https://www.linkedin.com/oauth/v2/authorization
|
||||
spring.security.oauth2.client.provider.linkedin.token-uri=https://www.linkedin.com/oauth/v2/accessToken
|
||||
spring.security.oauth2.client.provider.linkedin.user-info-uri=https://api.linkedin.com/v2/me
|
||||
spring.security.oauth2.client.provider.linkedin.user-name-attribute=id
|
||||
linkedin.email-address-uri=https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))
|
||||
app.auth.tokenSecret=926D96C90030DD58429D2751AC1BDBBC
|
||||
app.auth.tokenExpirationMsec=864000000
|
||||
# After successfully authenticating with the OAuth2 Provider,
|
||||
# we'll be generating an auth token for the user and sending the token to the
|
||||
# redirectUri mentioned by the frontend client in the /oauth2/authorization request.
|
||||
# We're not using cookies because they won't work well in mobile clients.
|
||||
app.oauth2.authorizedRedirectUris=http://localhost:8081/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect
|
||||
|
||||
|
||||
#projectPath=/data
|
||||
projectPath=D:\\WAP\\Codeextractor\\authsec-be\\backend
|
||||
angularProjectPath=D:\\WAP\\Codeextractor\\authsec-be\\backend/webui
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
*******************************************************************
|
||||
*******************************************************************
|
||||
__ _ ____ __ __ __
|
||||
/ \ \ | |__****** / ___| **** ****_ \ \ \ \ \ \
|
||||
/ / \ \ | '_ \ / _ \ \___ \| | | | '__|/ _ \ \ \ \ \ \ \
|
||||
\ \ / / | |_) | __/ ___) | |_| | | | __/ / / / / / /
|
||||
\ /_/ |_.__/ \___| |____/ \__,_|_| \___| /_/ /_/ /_/
|
||||
*** *** *****
|
||||
*******************************************************************
|
||||
::SPRING BOOT:: CNS Version::v1.1.0 RELEASE
|
||||
*******************************************************************
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,108 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} %p %m%n " />
|
||||
<property name="APP_LOG_ROOT" value="logs"/>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="applicationLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${APP_LOG_ROOT}/ExceptionLogs/Error.log</file>
|
||||
<encoder>
|
||||
<pattern>${LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<fileNamePattern>${APP_LOG_ROOT}/ExceptionLogs/Error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<minIndex>1</minIndex>
|
||||
<maxIndex>10</maxIndex>
|
||||
</rollingPolicy>
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
|
||||
<!-- <appender name="aopLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> -->
|
||||
<!-- <file>${APP_LOG_ROOT}/application-aop.log</file> -->
|
||||
<!-- <encoder> -->
|
||||
<!-- <pattern>${LOG_PATTERN}</pattern> -->
|
||||
<!-- </encoder> -->
|
||||
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> -->
|
||||
<!-- <fileNamePattern>${APP_LOG_ROOT}/application-aop-%i.log</fileNamePattern> -->
|
||||
<!-- <minIndex>1</minIndex> -->
|
||||
<!-- <maxIndex>10</maxIndex> -->
|
||||
<!-- </rollingPolicy> -->
|
||||
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> -->
|
||||
<!-- <maxFileSize>10MB</maxFileSize> -->
|
||||
<!-- </triggeringPolicy> -->
|
||||
<!-- </appender> -->
|
||||
|
||||
<!-- <appender name="springLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> -->
|
||||
<!-- <file>${APP_LOG_ROOT}/spring-framework.log</file> -->
|
||||
<!-- <encoder> -->
|
||||
<!-- <pattern>${LOG_PATTERN}</pattern> -->
|
||||
<!-- </encoder> -->
|
||||
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> -->
|
||||
<!-- <fileNamePattern>${APP_LOG_ROOT}/spring-framework-%i.log</fileNamePattern> -->
|
||||
<!-- <minIndex>1</minIndex> -->
|
||||
<!-- <maxIndex>10</maxIndex> -->
|
||||
<!-- </rollingPolicy> -->
|
||||
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> -->
|
||||
<!-- <maxFileSize>10MB</maxFileSize> -->
|
||||
<!-- </triggeringPolicy> -->
|
||||
<!-- </appender> -->
|
||||
|
||||
<!-- <appender name="hibernateLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> -->
|
||||
<!-- <file>${APP_LOG_ROOT}/database.log</file> -->
|
||||
<!-- <encoder> -->
|
||||
<!-- <pattern>${LOG_PATTERN}</pattern> -->
|
||||
<!-- </encoder> -->
|
||||
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> -->
|
||||
<!-- <fileNamePattern>${APP_LOG_ROOT}/database-%i.log</fileNamePattern> -->
|
||||
<!-- <minIndex>1</minIndex> -->
|
||||
<!-- <maxIndex>10</maxIndex> -->
|
||||
<!-- </rollingPolicy> -->
|
||||
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> -->
|
||||
<!-- <maxFileSize>10MB</maxFileSize> -->
|
||||
<!-- </triggeringPolicy> -->
|
||||
<!-- </appender> -->
|
||||
|
||||
<!-- <appender name="console"
|
||||
class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder name="enc"
|
||||
class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout
|
||||
class="com.realnet.logging1.PatternLayoutWithUserContext">
|
||||
<param name="Pattern"
|
||||
value="%d{HH:mm:ss.SSS} %-5level %logger{10} [%user %session] - %msg%n" />
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender> -->
|
||||
|
||||
<logger name="com.realnet" level="ERROR">
|
||||
<appender-ref ref="applicationLog" />
|
||||
</logger>
|
||||
|
||||
<!-- <logger name="com.realnet" level="INFO"> -->
|
||||
<!-- <appender-ref ref="aopLog" /> -->
|
||||
<!-- <appender-ref ref="console" /> -->
|
||||
<!-- </logger> -->
|
||||
|
||||
<!-- <logger name="org.springframework" level="INFO"> -->
|
||||
<!-- <appender-ref ref="springLog" /> -->
|
||||
<!-- <appender-ref ref="console" /> -->
|
||||
<!-- </logger> -->
|
||||
|
||||
<!-- <logger name="org.hibernate" level="ERROR"> -->
|
||||
<!-- <appender-ref ref="hibernateLog" /> -->
|
||||
<!-- <appender-ref ref="console" /> -->
|
||||
<!-- </logger> -->
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
email.notempty=Please provide valid email id.
|
||||
email.valid=Email should be valid
|
||||
email.regex=Enter a valid email
|
||||
name.minsize=Name should have minimum 3 characters
|
||||
@@ -1,57 +0,0 @@
|
||||
HEADER-LINE FORM :
|
||||
|
||||
GET: http://localhost:9119/api/teacher
|
||||
GET: http://localhost:9119/api/teacher/{id}
|
||||
PUT: http://localhost:9119/api/teacher/{id}
|
||||
DELETE: http://localhost:9119/api/teacher/{id} : NEED TO MODIFY THE INCORRECT ID INPUT ERROR HANDLING
|
||||
POST: http://localhost:9119/api/teacher
|
||||
===EX1===
|
||||
{
|
||||
"name": "niladri",
|
||||
"email": "sen.niladri6@gmail.com",
|
||||
"phoneNumber": 6291,
|
||||
"salary": 1000.0,
|
||||
"students": [{
|
||||
"name": "paku",
|
||||
"depertment": "CSE",
|
||||
"rollNumber": 108
|
||||
}]
|
||||
}
|
||||
===EX2===:
|
||||
{
|
||||
"name": "sandipan",
|
||||
"email": "sandy@gmail.com",
|
||||
"phoneNumber": 9038,
|
||||
"salary": 2000.0,
|
||||
"students": [
|
||||
{
|
||||
"name": "sahil",
|
||||
"depertment": "CSE",
|
||||
"rollNumber": 111
|
||||
},
|
||||
{
|
||||
"name": "tarun",
|
||||
"depertment": "CSE",
|
||||
"rollNumber": 121
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
===== 6.11.36
|
||||
user.java class code changed
|
||||
@Getter @Setter private List<Role> role;
|
||||
TokenUtil class code change
|
||||
|
||||
===== 9.11.20
|
||||
1.8
|
||||
=== SWAGGER UI ====
|
||||
http://localhost:9119/swagger-ui.html
|
||||
|
||||
=========
|
||||
GIT HUB COMMAND
|
||||
=========
|
||||
$ git commit -m "your mesage"
|
||||
$ git push origin main
|
||||
$ git status
|
||||
|
||||
$ git push origin main
|
||||
@@ -1,303 +0,0 @@
|
||||
/**
|
||||
Model : NorthWind
|
||||
**/
|
||||
|
||||
DROP SCHEMA IF EXISTS northwind;
|
||||
|
||||
CREATE SCHEMA northwind;
|
||||
USE northwind;
|
||||
|
||||
/* Table: user (Application Users) */
|
||||
CREATE TABLE user (
|
||||
user_id NVARCHAR(20) NOT NULL,
|
||||
password NVARCHAR(255) NOT NULL,
|
||||
first_name NVARCHAR(50) ,
|
||||
last_name NVARCHAR(50) ,
|
||||
email NVARCHAR(70) ,
|
||||
security_provider_id INT ,
|
||||
default_customer_id INT ,
|
||||
company NVARCHAR(50) ,
|
||||
phone NVARCHAR(20) ,
|
||||
address1 NVARCHAR(100),
|
||||
address2 NVARCHAR(100),
|
||||
country NVARCHAR(20) ,
|
||||
postal NVARCHAR(20) ,
|
||||
role NVARCHAR(20) ,
|
||||
other_roles NVARCHAR(80) ,
|
||||
is_active TINYINT ,
|
||||
is_blocked TINYINT ,
|
||||
secret_question NVARCHAR(100),
|
||||
secret_answer NVARCHAR(100),
|
||||
enable_beta_testing TINYINT,
|
||||
enable_renewal TINYINT,
|
||||
CONSTRAINT user_id PRIMARY KEY(user_id)
|
||||
);
|
||||
|
||||
/* Table: customers */
|
||||
CREATE TABLE customers (
|
||||
id INT NOT NULL,
|
||||
last_name VARCHAR(50) ,
|
||||
first_name VARCHAR(50) ,
|
||||
email VARCHAR(50) ,
|
||||
company VARCHAR(50) ,
|
||||
phone VARCHAR(25) ,
|
||||
address1 VARCHAR(150),
|
||||
address2 VARCHAR(150),
|
||||
city VARCHAR(50) ,
|
||||
state VARCHAR(50) ,
|
||||
postal_code VARCHAR(15) ,
|
||||
country VARCHAR(50) ,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
/* Table: employees */
|
||||
CREATE TABLE employees (
|
||||
id INT NOT NULL,
|
||||
last_name VARCHAR(50) ,
|
||||
first_name VARCHAR(50) ,
|
||||
email VARCHAR(50) ,
|
||||
avatar VARCHAR(250) ,
|
||||
job_title VARCHAR(50) ,
|
||||
department VARCHAR(50) ,
|
||||
manager_id INT ,
|
||||
phone VARCHAR(25) ,
|
||||
address1 VARCHAR(150),
|
||||
address2 VARCHAR(150),
|
||||
city VARCHAR(50) ,
|
||||
state VARCHAR(50) ,
|
||||
postal_code VARCHAR(15) ,
|
||||
country VARCHAR(50) ,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
/* Table: orders */
|
||||
CREATE TABLE orders (
|
||||
id INT NOT NULL,
|
||||
employee_id INT ,
|
||||
customer_id INT ,
|
||||
order_date DATETIME ,
|
||||
shipped_date DATETIME ,
|
||||
ship_name VARCHAR(50) ,
|
||||
ship_address1 VARCHAR(150) ,
|
||||
ship_address2 VARCHAR(150) ,
|
||||
ship_city VARCHAR(50) ,
|
||||
ship_state VARCHAR(50) ,
|
||||
ship_postal_code VARCHAR(50) ,
|
||||
ship_country VARCHAR(50) ,
|
||||
shipping_fee DECIMAL(19,4) NULL DEFAULT '0.0000',
|
||||
payment_type VARCHAR(50) ,
|
||||
paid_date DATETIME ,
|
||||
order_status VARCHAR(25),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
/* Table: order_details */
|
||||
CREATE TABLE order_items (
|
||||
order_id INT NOT NULL,
|
||||
product_id INT ,
|
||||
quantity DECIMAL(18,4) NOT NULL DEFAULT '0.0000',
|
||||
unit_price DECIMAL(19,4) NULL DEFAULT '0.0000',
|
||||
discount DECIMAL(19,4) NULL DEFAULT '0.0000',
|
||||
order_item_status VARCHAR(25),
|
||||
date_allocated DATETIME ,
|
||||
PRIMARY KEY (order_id, product_id)
|
||||
);
|
||||
|
||||
/* Table: products */
|
||||
CREATE TABLE products (
|
||||
id INT NOT NULL,
|
||||
product_code VARCHAR(25) ,
|
||||
product_name VARCHAR(50) ,
|
||||
description VARCHAR(250),
|
||||
standard_cost DECIMAL(19,4) NULL DEFAULT '0.0000',
|
||||
list_price DECIMAL(19,4) NOT NULL DEFAULT '0.0000',
|
||||
target_level INT ,
|
||||
reorder_level INT ,
|
||||
minimum_reorder_quantity INT ,
|
||||
quantity_per_unit VARCHAR(50) ,
|
||||
discontinued TINYINT NOT NULL DEFAULT '0',
|
||||
category VARCHAR(50),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
/* Foreign Key: orders */
|
||||
ALTER TABLE orders ADD CONSTRAINT fk_orders__customers FOREIGN KEY (customer_id) REFERENCES customers(id);
|
||||
ALTER TABLE orders ADD CONSTRAINT fk_orders__employees FOREIGN KEY (employee_id) REFERENCES employees(id);
|
||||
/* Foreign Key: order_items */
|
||||
ALTER TABLE order_items ADD CONSTRAINT fk_order_items__orders FOREIGN KEY (order_id) REFERENCES orders(id);
|
||||
ALTER TABLE order_items ADD CONSTRAINT fk_order_items__products FOREIGN KEY (product_id) REFERENCES products(id);
|
||||
|
||||
/* Views */
|
||||
CREATE OR REPLACE VIEW order_info AS
|
||||
select o.id as order_id
|
||||
, o.order_date
|
||||
, o.order_status
|
||||
, o.paid_date
|
||||
, o.payment_type
|
||||
, o.shipped_date
|
||||
, o.shipping_fee
|
||||
, o.ship_name
|
||||
, o.ship_address1
|
||||
, o.ship_address2
|
||||
, o.ship_city
|
||||
, o.ship_state
|
||||
, o.ship_postal_code
|
||||
, o.ship_country
|
||||
, o.customer_id
|
||||
, o.employee_id
|
||||
, concat(c.first_name, ' ', c.last_name) as customer_name
|
||||
, c.phone customer_phone
|
||||
, c.email customer_email
|
||||
, c.company as customer_company
|
||||
, concat(e.first_name, ' ', e.last_name) as employee_name
|
||||
, e.department employee_department
|
||||
, e.job_title employee_job_title
|
||||
From orders o
|
||||
, employees e
|
||||
, customers c
|
||||
where o.employee_id = e.id
|
||||
and o.customer_id = c.id;
|
||||
|
||||
CREATE OR REPLACE VIEW order_details AS
|
||||
select oi.order_id
|
||||
, oi.product_id
|
||||
, oi.quantity
|
||||
, oi.unit_price
|
||||
, oi.discount
|
||||
, oi.date_allocated
|
||||
, oi.order_item_status
|
||||
, o.order_date
|
||||
, o.order_status
|
||||
, o.paid_date
|
||||
, o.payment_type
|
||||
, o.shipped_date
|
||||
, o.shipping_fee
|
||||
, o.ship_name
|
||||
, o.ship_address1
|
||||
, o.ship_address2
|
||||
, o.ship_city
|
||||
, o.ship_state
|
||||
, o.ship_postal_code
|
||||
, o.ship_country
|
||||
, p.product_code
|
||||
, p.product_name
|
||||
, p.category
|
||||
, p.description
|
||||
, p.list_price
|
||||
, o.customer_id
|
||||
, concat(c.first_name, ' ', c.last_name) as customer_name
|
||||
, c.phone as customer_phone
|
||||
, c.email as customer_email
|
||||
, c.company as customer_company
|
||||
, o.employee_id
|
||||
, concat(e.first_name, ' ', e.last_name) as employee_name
|
||||
, e.department as employee_department
|
||||
, e.job_title as employee_job_title
|
||||
From orders o
|
||||
, products p
|
||||
, order_items oi
|
||||
, employees e
|
||||
, customers c
|
||||
where oi.order_id = o.id
|
||||
and oi.product_id = p.id
|
||||
and o.employee_id = e.id
|
||||
and o.customer_id = c.id;
|
||||
|
||||
CREATE OR REPLACE VIEW customer_orders AS
|
||||
select o.order_date, o.order_status, o.paid_date, o.payment_type, o.shipping_fee, o.customer_id
|
||||
, c.first_name customer_first_name, c.last_name customer_last_name, c.phone customer_phone, c.email customer_email, c.company
|
||||
from orders o,customers c
|
||||
where o.customer_id = c.id;
|
||||
|
||||
CREATE OR REPLACE VIEW employee_orders AS
|
||||
select o.order_date, o.order_status, o.paid_date, o.payment_type, o.shipping_fee, o.employee_id
|
||||
, e.first_name employee_first_name, e.last_name employee_last_name, e.email employee_email, e.department
|
||||
from orders o,employees e
|
||||
where o.customer_id = e.id;
|
||||
|
||||
|
||||
/* REAL_NET */
|
||||
CREATE TABLE RN_INSTRUCTOR (
|
||||
ID VARCHAR(20) NOT NULL AUTO_INCREMENT,
|
||||
FIRST_NAME VARCHAR(20) NOT NULL,
|
||||
LAST_NAME VARCHAR(20) NOT NULL,
|
||||
EMAIL VARCHAR(20) NOT NULL,
|
||||
CREATED_AT DATETIME,
|
||||
UPDATED_AT DATETIME,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
/*==== EXTENSION FIELD ===*/
|
||||
CREATE TABLE RN_EXT_FIELD_T (
|
||||
ID int(11) NOT NULL AUTO_INCREMENT,
|
||||
TYPE VARCHAR(20),
|
||||
DATA_TYPE VARCHAR(20),
|
||||
FIELD_NAME VARCHAR(20),
|
||||
MAPPING VARCHAR(20),
|
||||
FORM_CODE VARCHAR(20),
|
||||
IS_ACTIVE BOOLEAN,
|
||||
ACCOUNT_ID VARCHAR(20),
|
||||
CREATED_AT DATETIME,
|
||||
UPDATED_AT DATETIME,
|
||||
CREATED_BY VARCHAR(20),
|
||||
UPDATED_BY VARCHAR(20),
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
/*========= lookup ========
|
||||
CREATE TABLE `rn_lookup_values_t` (
|
||||
`ID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`LOOKUP_CODE` longtext,
|
||||
`MEANING` longtext,
|
||||
`DESCRIPTION` longtext,
|
||||
`LOOKUP_TYPE` longtext,
|
||||
`ACTIVE_START_DATE` datetime DEFAULT NULL,
|
||||
`ACTIVE_END_DATE` datetime DEFAULT NULL,
|
||||
`ENABLED_FLAG` longtext,
|
||||
`CREATED_BY` int(11) DEFAULT NULL,
|
||||
`CREATION_DATE` datetime DEFAULT NULL,
|
||||
`LAST_UPDATED_BY` int(11) DEFAULT NULL,
|
||||
`LAST_UPDATE_DATE` datetime DEFAULT NULL
|
||||
PRIMARY KEY (`ID`)
|
||||
); */
|
||||
|
||||
|
||||
|
||||
/*========= LOGGING ========
|
||||
|
||||
DROP TABLE logging_event_exception IF EXISTS;
|
||||
DROP TABLE logging_event_property IF EXISTS;
|
||||
DROP TABLE logging_event IF EXISTS;
|
||||
|
||||
CREATE TABLE logging_event (
|
||||
timestmp BIGINT NOT NULL,
|
||||
formatted_message LONGVARCHAR NOT NULL,
|
||||
logger_name VARCHAR(256) NOT NULL,
|
||||
level_string VARCHAR(256) NOT NULL,
|
||||
thread_name VARCHAR(256),
|
||||
reference_flag SMALLINT,
|
||||
arg0 VARCHAR(256),
|
||||
arg1 VARCHAR(256),
|
||||
arg2 VARCHAR(256),
|
||||
arg3 VARCHAR(256),
|
||||
caller_filename VARCHAR(256),
|
||||
caller_class VARCHAR(256),
|
||||
caller_method VARCHAR(256),
|
||||
caller_line CHAR(4),
|
||||
event_id IDENTITY NOT NULL);
|
||||
|
||||
|
||||
CREATE TABLE logging_event_property (
|
||||
event_id BIGINT NOT NULL,
|
||||
mapped_key VARCHAR(254) NOT NULL,
|
||||
mapped_value LONGVARCHAR,
|
||||
PRIMARY KEY(event_id, mapped_key),
|
||||
FOREIGN KEY (event_id) REFERENCES logging_event(event_id));
|
||||
|
||||
CREATE TABLE logging_event_exception (
|
||||
event_id BIGINT NOT NULL,
|
||||
i SMALLINT NOT NULL,
|
||||
trace_line VARCHAR(256) NOT NULL,
|
||||
PRIMARY KEY(event_id, i),
|
||||
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)); */
|
||||
Reference in New Issue
Block a user