adding base Project
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
package com.realnet.Abc_1665647440047_back.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Abc{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private int name_id;
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.realnet.Abc_1665647440047_back.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
import com.realnet.Abc_1665647440047_back.Services.AbcService ;
|
||||
@RequestMapping(value = "/_1665647440047_back")
|
||||
@RestController
|
||||
public class AbcController {
|
||||
|
||||
@Autowired
|
||||
private AbcService Service;
|
||||
|
||||
@PostMapping("/Abc")
|
||||
|
||||
public Abc Savedata(@RequestBody Abc data) {
|
||||
Abc save = Service.Savedata(data) ;
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/Abc")
|
||||
public List<Abc> getdetails() {
|
||||
List<Abc> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Abc/{id}")
|
||||
public Abc getdetailsbyId(@PathVariable Long id ) {
|
||||
Abc get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Abc/{id}")
|
||||
public void delete_by_id(@PathVariable Long id ) {
|
||||
Service.delete_by_id(id);
|
||||
|
||||
}
|
||||
@PutMapping("/Abc/{id}")
|
||||
public Abc update(@RequestBody Abc data,@PathVariable Long id ) {
|
||||
Abc update = Service.update(data,id);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.realnet.Abc_1665647440047_back.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
|
||||
@Repository
|
||||
public interface AbcRepository extends JpaRepository<Abc, Long> {
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.realnet.Abc_1665647440047_back.Services;
|
||||
import com.realnet.Abc_1665647440047_back.Repository.AbcRepository;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AbcService {
|
||||
@Autowired
|
||||
private AbcRepository Repository;
|
||||
public Abc Savedata(Abc data) {
|
||||
return Repository.save(data);
|
||||
}
|
||||
|
||||
|
||||
public List<Abc> getdetails() {
|
||||
return (List<Abc>) Repository.findAll();
|
||||
}
|
||||
|
||||
|
||||
public Abc getdetailsbyId(Long id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Long id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Abc update(Abc data,Long id) {
|
||||
Abc old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
old.setName_id(data.getName_id());
|
||||
final Abc test = Repository.save(old);
|
||||
return test;}}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"package com.realnet.+"<repo_name>"+.Entity;" + "\r\n" +
|
||||
" import lombok.*;" + "\r\n" +
|
||||
" import javax.persistence.*;" + "\r\n" +
|
||||
" import java.time.LocalDateTime;" + "\r\n" +
|
||||
" import java.util.*;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Entity " + "\r\n" +
|
||||
" @Data" + "\r\n" +
|
||||
" public class Abc{ " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Id" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private String name;" + "\r\n" +
|
||||
" private int name_id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }"
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"package com.realnet.+"<repo_name>"+.Controllers;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.web.bind.annotation.*;" + "\r\n" +
|
||||
"import com.realnet.+"<repo_name>"+.Entity.Abc;" + "\r\n" +
|
||||
"import com.realnet.+"<repo_name>"+.Services.AbcService ;" + "\r\n" +
|
||||
"@RequestMapping(value = \"/_1665647440047_back\")" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"public class AbcController {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private AbcService Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @PostMapping(\"/Abc\")" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public Abc Savedata(@RequestBody Abc data) {" + "\r\n" +
|
||||
" Abc save = Service.Savedata(data) ;" + "\r\n" +
|
||||
" return save;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @GetMapping(\"/Abc\")" + "\r\n" +
|
||||
" public List<Abc> getdetails() {" + "\r\n" +
|
||||
" List<Abc> get = Service.getdetails(); " + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"@GetMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public Abc getdetailsbyId(@PathVariable Long id ) {" + "\r\n" +
|
||||
" Abc get = Service.getdetailsbyId(id);" + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@DeleteMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public void delete_by_id(@PathVariable Long id ) {" + "\r\n" +
|
||||
" Service.delete_by_id(id);" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@PutMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public Abc update(@RequestBody Abc data,@PathVariable Long id ) {" + "\r\n" +
|
||||
" Abc update = Service.update(data,id);" + "\r\n" +
|
||||
" return update;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"}"
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"package com.realnet.+"<repo_name>"+.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.stereotype.Repository;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.+"<repo_name>"+.Entity.Abc;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Repository" + "\r\n" +
|
||||
"public interface AbcRepository extends JpaRepository<Abc, Long> { " + "\r\n" +
|
||||
"}"
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"package com.realnet.+"<repo_name>"+.Services;" + "\r\n" +
|
||||
"import com.realnet.+"<repo_name>"+.Repository.AbcRepository;" + "\r\n" +
|
||||
"import com.realnet.+"<repo_name>"+.Entity.Abc;import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
" public class AbcService {" + "\r\n" +
|
||||
"@Autowired" + "\r\n" +
|
||||
"private AbcRepository Repository;" + "\r\n" +
|
||||
"public Abc Savedata(Abc data) {" + "\r\n" +
|
||||
" return Repository.save(data); " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"public List<Abc> getdetails() {" + "\r\n" +
|
||||
" return (List<Abc>) Repository.findAll();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public Abc getdetailsbyId(Long id) {" + "\r\n" +
|
||||
" return Repository.findById(id).get();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public void delete_by_id(Long id) {" + "\r\n" +
|
||||
" Repository.deleteById(id);" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public Abc update(Abc data,Long id) {" + "\r\n" +
|
||||
" Abc old = Repository.findById(id).get();" + "\r\n" +
|
||||
"old.setName(data.getName());" + "\r\n" +
|
||||
"old.setName_id(data.getName_id());" + "\r\n" +
|
||||
"final Abc test = Repository.save(old);" + "\r\n" +
|
||||
" return test;}}"
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.realnet.Abc_1665647440047_back.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Abc{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private int name_id;
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.realnet.Abc_1665647440047_back.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
import com.realnet.Abc_1665647440047_back.Services.AbcService ;
|
||||
@RequestMapping(value = "/_1665647440047_back")
|
||||
@RestController
|
||||
public class AbcController {
|
||||
|
||||
@Autowired
|
||||
private AbcService Service;
|
||||
|
||||
@PostMapping("/Abc")
|
||||
|
||||
public Abc Savedata(@RequestBody Abc data) {
|
||||
Abc save = Service.Savedata(data) ;
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/Abc")
|
||||
public List<Abc> getdetails() {
|
||||
List<Abc> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Abc/{id}")
|
||||
public Abc getdetailsbyId(@PathVariable Long id ) {
|
||||
Abc get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Abc/{id}")
|
||||
public void delete_by_id(@PathVariable Long id ) {
|
||||
Service.delete_by_id(id);
|
||||
|
||||
}
|
||||
@PutMapping("/Abc/{id}")
|
||||
public Abc update(@RequestBody Abc data,@PathVariable Long id ) {
|
||||
Abc update = Service.update(data,id);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.realnet.Abc_1665647440047_back.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
|
||||
@Repository
|
||||
public interface AbcRepository extends JpaRepository<Abc, Long> {
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.realnet.Abc_1665647440047_back.Services;
|
||||
import com.realnet.Abc_1665647440047_back.Repository.AbcRepository;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AbcService {
|
||||
@Autowired
|
||||
private AbcRepository Repository;
|
||||
public Abc Savedata(Abc data) {
|
||||
return Repository.save(data);
|
||||
}
|
||||
|
||||
|
||||
public List<Abc> getdetails() {
|
||||
return (List<Abc>) Repository.findAll();
|
||||
}
|
||||
|
||||
|
||||
public Abc getdetailsbyId(Long id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Long id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Abc update(Abc data,Long id) {
|
||||
Abc old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
old.setName_id(data.getName_id());
|
||||
final Abc test = Repository.save(old);
|
||||
return test;}}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"package com.realnet.+repo_name+.Entity;" + "\r\n" +
|
||||
" import lombok.*;" + "\r\n" +
|
||||
" import javax.persistence.*;" + "\r\n" +
|
||||
" import java.time.LocalDateTime;" + "\r\n" +
|
||||
" import java.util.*;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Entity " + "\r\n" +
|
||||
" @Data" + "\r\n" +
|
||||
" public class Abc{ " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Id" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private String name;" + "\r\n" +
|
||||
" private int name_id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }"
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"package com.realnet.+repo_name+.Controllers;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.web.bind.annotation.*;" + "\r\n" +
|
||||
"import com.realnet.+repo_name+.Entity.Abc;" + "\r\n" +
|
||||
"import com.realnet.+repo_name+.Services.AbcService ;" + "\r\n" +
|
||||
"@RequestMapping(value = \"/_1665647440047_back\")" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"public class AbcController {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private AbcService Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @PostMapping(\"/Abc\")" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public Abc Savedata(@RequestBody Abc data) {" + "\r\n" +
|
||||
" Abc save = Service.Savedata(data) ;" + "\r\n" +
|
||||
" return save;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @GetMapping(\"/Abc\")" + "\r\n" +
|
||||
" public List<Abc> getdetails() {" + "\r\n" +
|
||||
" List<Abc> get = Service.getdetails(); " + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"@GetMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public Abc getdetailsbyId(@PathVariable Long id ) {" + "\r\n" +
|
||||
" Abc get = Service.getdetailsbyId(id);" + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@DeleteMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public void delete_by_id(@PathVariable Long id ) {" + "\r\n" +
|
||||
" Service.delete_by_id(id);" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@PutMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public Abc update(@RequestBody Abc data,@PathVariable Long id ) {" + "\r\n" +
|
||||
" Abc update = Service.update(data,id);" + "\r\n" +
|
||||
" return update;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"}"
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"package com.realnet.+repo_name+.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.stereotype.Repository;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.+repo_name+.Entity.Abc;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Repository" + "\r\n" +
|
||||
"public interface AbcRepository extends JpaRepository<Abc, Long> { " + "\r\n" +
|
||||
"}"
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"package com.realnet.+repo_name+.Services;" + "\r\n" +
|
||||
"import com.realnet.+repo_name+.Repository.AbcRepository;" + "\r\n" +
|
||||
"import com.realnet.+repo_name+.Entity.Abc;import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
" public class AbcService {" + "\r\n" +
|
||||
"@Autowired" + "\r\n" +
|
||||
"private AbcRepository Repository;" + "\r\n" +
|
||||
"public Abc Savedata(Abc data) {" + "\r\n" +
|
||||
" return Repository.save(data); " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"public List<Abc> getdetails() {" + "\r\n" +
|
||||
" return (List<Abc>) Repository.findAll();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public Abc getdetailsbyId(Long id) {" + "\r\n" +
|
||||
" return Repository.findById(id).get();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public void delete_by_id(Long id) {" + "\r\n" +
|
||||
" Repository.deleteById(id);" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public Abc update(Abc data,Long id) {" + "\r\n" +
|
||||
" Abc old = Repository.findById(id).get();" + "\r\n" +
|
||||
"old.setName(data.getName());" + "\r\n" +
|
||||
"old.setName_id(data.getName_id());" + "\r\n" +
|
||||
"final Abc test = Repository.save(old);" + "\r\n" +
|
||||
" return test;}}"
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.realnet.Abc_1665647440047_back.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Abc{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private int name_id;
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.realnet.Abc_1665647440047_back.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
import com.realnet.Abc_1665647440047_back.Services.AbcService ;
|
||||
@RequestMapping(value = "/_1665647440047_back")
|
||||
@RestController
|
||||
public class AbcController {
|
||||
|
||||
@Autowired
|
||||
private AbcService Service;
|
||||
|
||||
@PostMapping("/Abc")
|
||||
|
||||
public Abc Savedata(@RequestBody Abc data) {
|
||||
Abc save = Service.Savedata(data) ;
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/Abc")
|
||||
public List<Abc> getdetails() {
|
||||
List<Abc> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Abc/{id}")
|
||||
public Abc getdetailsbyId(@PathVariable Long id ) {
|
||||
Abc get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Abc/{id}")
|
||||
public void delete_by_id(@PathVariable Long id ) {
|
||||
Service.delete_by_id(id);
|
||||
|
||||
}
|
||||
@PutMapping("/Abc/{id}")
|
||||
public Abc update(@RequestBody Abc data,@PathVariable Long id ) {
|
||||
Abc update = Service.update(data,id);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.realnet.Abc_1665647440047_back.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
|
||||
@Repository
|
||||
public interface AbcRepository extends JpaRepository<Abc, Long> {
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.realnet.Abc_1665647440047_back.Services;
|
||||
import com.realnet.Abc_1665647440047_back.Repository.AbcRepository;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AbcService {
|
||||
@Autowired
|
||||
private AbcRepository Repository;
|
||||
public Abc Savedata(Abc data) {
|
||||
return Repository.save(data);
|
||||
}
|
||||
|
||||
|
||||
public List<Abc> getdetails() {
|
||||
return (List<Abc>) Repository.findAll();
|
||||
}
|
||||
|
||||
|
||||
public Abc getdetailsbyId(Long id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Long id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Abc update(Abc data,Long id) {
|
||||
Abc old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
old.setName_id(data.getName_id());
|
||||
final Abc test = Repository.save(old);
|
||||
return test;}}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
"package com.realnet."+repo_name+".Entity;" + "\r\n" +
|
||||
" import lombok.*;" + "\r\n" +
|
||||
" import javax.persistence.*;" + "\r\n" +
|
||||
" import java.time.LocalDateTime;" + "\r\n" +
|
||||
" import java.util.*;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Entity " + "\r\n" +
|
||||
" @Data" + "\r\n" +
|
||||
" public class "+table_name+"{ " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" "+ for (Entry<String, String> e : entrySet) {
|
||||
|
||||
String string = e.getKey().toLowerCase();
|
||||
String datatype = e.getValue().toString();
|
||||
String lowerCase = string.replaceAll(" ", "_").toLowerCase();
|
||||
String add = "n private " + datatype + " " + lowerCase + ";";
|
||||
"+table_name+"1Code.append(add);
|
||||
}
|
||||
"+table_name+"1Code.append("n}nr"); +"" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private String name;" + "\r\n" +
|
||||
" private int name_id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }"
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"package com.realnet."+repo_name+".Controllers;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.web.bind.annotation.*;" + "\r\n" +
|
||||
"import com.realnet."+repo_name+".Entity."+table_name+";" + "\r\n" +
|
||||
"import com.realnet."+repo_name+".Services."+table_name+"Service ;" + "\r\n" +
|
||||
"@RequestMapping(value = \"/_1665647440047_back\")" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"public class "+table_name+"Controller {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private "+table_name+"Service Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @PostMapping(\"/"+table_name+"\")" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public "+table_name+" Savedata(@RequestBody "+table_name+" data) {" + "\r\n" +
|
||||
" "+table_name+" save = Service.Savedata(data) ;" + "\r\n" +
|
||||
" return save;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @GetMapping(\"/"+table_name+"\")" + "\r\n" +
|
||||
" public List<"+table_name+"> getdetails() {" + "\r\n" +
|
||||
" List<"+table_name+"> get = Service.getdetails(); " + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"@GetMapping(\"/"+table_name+"/{id}\")" + "\r\n" +
|
||||
" public "+table_name+" getdetailsbyId(@PathVariable Long id ) {" + "\r\n" +
|
||||
" "+table_name+" get = Service.getdetailsbyId(id);" + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@DeleteMapping(\"/"+table_name+"/{id}\")" + "\r\n" +
|
||||
" public void delete_by_id(@PathVariable Long id ) {" + "\r\n" +
|
||||
" Service.delete_by_id(id);" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@PutMapping(\"/"+table_name+"/{id}\")" + "\r\n" +
|
||||
" public "+table_name+" update(@RequestBody "+table_name+" data,@PathVariable Long id ) {" + "\r\n" +
|
||||
" "+table_name+" update = Service.update(data,id);" + "\r\n" +
|
||||
" return update;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"}"
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"package com.realnet."+repo_name+".Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.stereotype.Repository;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet."+repo_name+".Entity."+table_name+";" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Repository" + "\r\n" +
|
||||
"public interface "+table_name+"Repository extends JpaRepository<"+table_name+", Long> { " + "\r\n" +
|
||||
"}"
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"package com.realnet."+repo_name+".Services;" + "\r\n" +
|
||||
"import com.realnet."+repo_name+".Repository."+table_name+"Repository;" + "\r\n" +
|
||||
"import com.realnet."+repo_name+".Entity."+table_name+";import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
" public class "+table_name+"Service {" + "\r\n" +
|
||||
"@Autowired" + "\r\n" +
|
||||
"private "+table_name+"Repository Repository;" + "\r\n" +
|
||||
"public "+table_name+" Savedata("+table_name+" data) {" + "\r\n" +
|
||||
" return Repository.save(data); " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"public List<"+table_name+"> getdetails() {" + "\r\n" +
|
||||
" return (List<"+table_name+">) Repository.findAll();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public "+table_name+" getdetailsbyId(Long id) {" + "\r\n" +
|
||||
" return Repository.findById(id).get();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public void delete_by_id(Long id) {" + "\r\n" +
|
||||
" Repository.deleteById(id);" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public "+table_name+" update("+table_name+" data,Long id) {" + "\r\n" +
|
||||
" "+table_name+" old = Repository.findById(id).get();" + "\r\n" +
|
||||
"old.setName(data.getName());" + "\r\n" +
|
||||
"old.setName_id(data.getName_id());" + "\r\n" +
|
||||
"final "+table_name+" test = Repository.save(old);" + "\r\n" +
|
||||
" return test;}}"
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.realnet.Abc_1665647440047_back.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Abc{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private int name_id;
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.realnet.Abc_1665647440047_back.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
import com.realnet.Abc_1665647440047_back.Services.AbcService ;
|
||||
@RequestMapping(value = "/_1665647440047_back")
|
||||
@RestController
|
||||
public class AbcController {
|
||||
|
||||
@Autowired
|
||||
private AbcService Service;
|
||||
|
||||
@PostMapping("/Abc")
|
||||
|
||||
public Abc Savedata(@RequestBody Abc data) {
|
||||
Abc save = Service.Savedata(data) ;
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/Abc")
|
||||
public List<Abc> getdetails() {
|
||||
List<Abc> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Abc/{id}")
|
||||
public Abc getdetailsbyId(@PathVariable Long id ) {
|
||||
Abc get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Abc/{id}")
|
||||
public void delete_by_id(@PathVariable Long id ) {
|
||||
Service.delete_by_id(id);
|
||||
|
||||
}
|
||||
@PutMapping("/Abc/{id}")
|
||||
public Abc update(@RequestBody Abc data,@PathVariable Long id ) {
|
||||
Abc update = Service.update(data,id);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.realnet.Abc_1665647440047_back.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;
|
||||
|
||||
@Repository
|
||||
public interface AbcRepository extends JpaRepository<Abc, Long> {
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.realnet.Abc_1665647440047_back.Services;
|
||||
import com.realnet.Abc_1665647440047_back.Repository.AbcRepository;
|
||||
import com.realnet.Abc_1665647440047_back.Entity.Abc;import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AbcService {
|
||||
@Autowired
|
||||
private AbcRepository Repository;
|
||||
public Abc Savedata(Abc data) {
|
||||
return Repository.save(data);
|
||||
}
|
||||
|
||||
|
||||
public List<Abc> getdetails() {
|
||||
return (List<Abc>) Repository.findAll();
|
||||
}
|
||||
|
||||
|
||||
public Abc getdetailsbyId(Long id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Long id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Abc update(Abc data,Long id) {
|
||||
Abc old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
old.setName_id(data.getName_id());
|
||||
final Abc test = Repository.save(old);
|
||||
return test;}}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
"package com.realnet.Abc_1665647440047_back.Entity;" + "\r\n" +
|
||||
" import lombok.*;" + "\r\n" +
|
||||
" import javax.persistence.*;" + "\r\n" +
|
||||
" import java.time.LocalDateTime;" + "\r\n" +
|
||||
" import java.util.*;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Entity " + "\r\n" +
|
||||
" @Data" + "\r\n" +
|
||||
" public class Abc{ " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Id" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private String name;" + "\r\n" +
|
||||
" private int name_id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }"
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"package com.realnet.Abc_1665647440047_back.Controllers;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.web.bind.annotation.*;" + "\r\n" +
|
||||
"import com.realnet.Abc_1665647440047_back.Entity.Abc;" + "\r\n" +
|
||||
"import com.realnet.Abc_1665647440047_back.Services.AbcService ;" + "\r\n" +
|
||||
"@RequestMapping(value = \"/_1665647440047_back\")" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"public class AbcController {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private AbcService Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @PostMapping(\"/Abc\")" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public Abc Savedata(@RequestBody Abc data) {" + "\r\n" +
|
||||
" Abc save = Service.Savedata(data) ;" + "\r\n" +
|
||||
" return save;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @GetMapping(\"/Abc\")" + "\r\n" +
|
||||
" public List<Abc> getdetails() {" + "\r\n" +
|
||||
" List<Abc> get = Service.getdetails(); " + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"@GetMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public Abc getdetailsbyId(@PathVariable Long id ) {" + "\r\n" +
|
||||
" Abc get = Service.getdetailsbyId(id);" + "\r\n" +
|
||||
" return get;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@DeleteMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public void delete_by_id(@PathVariable Long id ) {" + "\r\n" +
|
||||
" Service.delete_by_id(id);" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"@PutMapping(\"/Abc/{id}\")" + "\r\n" +
|
||||
" public Abc update(@RequestBody Abc data,@PathVariable Long id ) {" + "\r\n" +
|
||||
" Abc update = Service.update(data,id);" + "\r\n" +
|
||||
" return update;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"}"
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"package com.realnet.Abc_1665647440047_back.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.stereotype.Repository;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.Abc_1665647440047_back.Entity.Abc;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Repository" + "\r\n" +
|
||||
"public interface AbcRepository extends JpaRepository<Abc, Long> { " + "\r\n" +
|
||||
"}"
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"package com.realnet.Abc_1665647440047_back.Services;" + "\r\n" +
|
||||
"import com.realnet.Abc_1665647440047_back.Repository.AbcRepository;" + "\r\n" +
|
||||
"import com.realnet.Abc_1665647440047_back.Entity.Abc;import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
" import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
" public class AbcService {" + "\r\n" +
|
||||
"@Autowired" + "\r\n" +
|
||||
"private AbcRepository Repository;" + "\r\n" +
|
||||
"public Abc Savedata(Abc data) {" + "\r\n" +
|
||||
" return Repository.save(data); " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"public List<Abc> getdetails() {" + "\r\n" +
|
||||
" return (List<Abc>) Repository.findAll();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public Abc getdetailsbyId(Long id) {" + "\r\n" +
|
||||
" return Repository.findById(id).get();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public void delete_by_id(Long id) {" + "\r\n" +
|
||||
" Repository.deleteById(id);" + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public Abc update(Abc data,Long id) {" + "\r\n" +
|
||||
" Abc old = Repository.findById(id).get();" + "\r\n" +
|
||||
"old.setName(data.getName());" + "\r\n" +
|
||||
"old.setName_id(data.getName_id());" + "\r\n" +
|
||||
"final Abc test = Repository.save(old);" + "\r\n" +
|
||||
" return test;}}"
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.realnet.bugTracker.Entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.realnet.incident.entity.WhooColomns;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
|
||||
public class BugTracker extends WhooColomns {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String type;
|
||||
private String key_no;
|
||||
private String summary;
|
||||
private String assignee;
|
||||
private String reporter;
|
||||
|
||||
private String select_project;
|
||||
private String title;
|
||||
private String select_status;
|
||||
private String select_priority;
|
||||
private String steps;
|
||||
private String description;
|
||||
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String fileType;
|
||||
|
||||
@Lob
|
||||
private byte[] data;
|
||||
|
||||
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package com.realnet.bugTracker.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.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.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.realnet.activity.service.ActivityService;
|
||||
import com.realnet.bugTracker.Entity.BugTracker;
|
||||
import com.realnet.bugTracker.Service.BugTrackerService;
|
||||
import com.realnet.fileupload.helper.Fileuploadhelper;
|
||||
import com.realnet.incident.entity.IncidentEntity;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sureserve/bugtracker")
|
||||
public class BugTrackerController {
|
||||
|
||||
@Autowired
|
||||
private BugTrackerService bugTrackerService;
|
||||
|
||||
@Autowired
|
||||
private Fileuploadhelper fileuploadhelper;
|
||||
|
||||
@PostMapping("/bugtracker")
|
||||
public ResponseEntity<String> createIssue(@RequestParam String data, @RequestParam MultipartFile file)
|
||||
throws JsonMappingException, JsonProcessingException {
|
||||
|
||||
// Deserialize the "data" parameter to a BugTracker object using Jackson's
|
||||
// ObjectMapper
|
||||
BugTracker bugTracker = new ObjectMapper().readValue(data, BugTracker.class);
|
||||
|
||||
// Check if a file was uploaded
|
||||
if (!file.isEmpty()) {
|
||||
System.out.println(file.getOriginalFilename());
|
||||
|
||||
// Use a file upload helper method to upload the file and return a boolean
|
||||
// indicating success or failure
|
||||
boolean isUploaded = fileuploadhelper.uploadFile(file);
|
||||
|
||||
if (isUploaded) {
|
||||
System.out.println("File uploaded successfully");
|
||||
bugTracker.setFileName(file.getOriginalFilename());
|
||||
}
|
||||
} else {
|
||||
bugTracker.setFileName("No file");
|
||||
}
|
||||
|
||||
// Pass the updated BugTracker object to the bugTrackerService's createIssue
|
||||
// method to create a new BugTracker object
|
||||
BugTracker createdTracker = bugTrackerService.createIssue(bugTracker);
|
||||
|
||||
return ResponseEntity.ok("addded successfully");
|
||||
}
|
||||
|
||||
@GetMapping("/bugtracker/{id}")
|
||||
public ResponseEntity<BugTracker> getIssueById(@PathVariable Long id) {
|
||||
BugTracker tracker = bugTrackerService.getIssueById(id);
|
||||
return ResponseEntity.ok(tracker);
|
||||
}
|
||||
|
||||
@GetMapping("/bugtracker")
|
||||
public ResponseEntity<List<BugTracker>> getAllIssues() {
|
||||
List<BugTracker> allIssues = bugTrackerService.getAllIssues();
|
||||
return ResponseEntity.ok(allIssues);
|
||||
}
|
||||
|
||||
@PutMapping("/bugtracker/{id}")
|
||||
public ResponseEntity<String> updateIssue(@RequestParam String data, @PathVariable Long id,
|
||||
@RequestParam MultipartFile file) throws Exception {
|
||||
|
||||
BugTracker bugTracker = new ObjectMapper().readValue(data, BugTracker.class);
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
System.out.println(file.getOriginalFilename());
|
||||
boolean f = fileuploadhelper.uploadFile(file);
|
||||
|
||||
if (f) {
|
||||
System.out.println("file uploaded successfully");
|
||||
bugTracker.setFileName(file.getOriginalFilename());
|
||||
}
|
||||
} else {
|
||||
bugTracker.setFileName("No file");
|
||||
}
|
||||
|
||||
// Update the bug tracker with the new incident entity
|
||||
bugTrackerService.updateIssue(id, bugTracker);
|
||||
|
||||
return ResponseEntity.ok("Update successfully");
|
||||
}
|
||||
|
||||
@DeleteMapping("/bugtracker/{id}")
|
||||
public ResponseEntity<String> deleteIssue(@PathVariable Long id) {
|
||||
bugTrackerService.deleteIssue(id);
|
||||
String message = "Issue with ID " + id + " has been deleted";
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.realnet.bugTracker.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.bugTracker.Entity.BugTracker;
|
||||
|
||||
@Repository
|
||||
public interface BugTrackerRepository extends JpaRepository<BugTracker, Long> {
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.realnet.bugTracker.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.bugTracker.Entity.BugTracker;
|
||||
import com.realnet.bugTracker.Repository.BugTrackerRepository;
|
||||
|
||||
@Service
|
||||
public class BugTrackerService {
|
||||
|
||||
@Autowired
|
||||
private BugTrackerRepository bugTrackerRepository;
|
||||
|
||||
public BugTracker createIssue(BugTracker tracker) {
|
||||
return bugTrackerRepository.save(tracker);
|
||||
}
|
||||
|
||||
public BugTracker getIssueById(Long id) {
|
||||
return bugTrackerRepository.findById(id).orElseThrow(() -> new EntityNotFoundException("Issue not found"));
|
||||
}
|
||||
|
||||
public List<BugTracker> getAllIssues() {
|
||||
return bugTrackerRepository.findAll();
|
||||
}
|
||||
|
||||
public BugTracker updateIssue(Long id, BugTracker tracker) {
|
||||
BugTracker existingIssue = getIssueById(id);
|
||||
existingIssue.setType(tracker.getType());
|
||||
existingIssue.setKey_no(tracker.getKey_no());
|
||||
existingIssue.setSummary(tracker.getSummary());
|
||||
existingIssue.setAssignee(tracker.getAssignee());
|
||||
existingIssue.setReporter(tracker.getReporter());
|
||||
existingIssue.setSelect_project(tracker.getSelect_project());
|
||||
existingIssue.setTitle(tracker.getTitle());
|
||||
existingIssue.setSelect_status(tracker.getSelect_status());
|
||||
existingIssue.setSelect_priority(tracker.getSelect_priority());
|
||||
existingIssue.setSteps(tracker.getSteps());
|
||||
existingIssue.setDescription(tracker.getDescription());
|
||||
existingIssue.setFileName(tracker.getFileName());
|
||||
existingIssue.setFileType(tracker.getFileType());
|
||||
existingIssue.setData(tracker.getData());
|
||||
|
||||
return bugTrackerRepository.save(existingIssue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void deleteIssue(Long id) {
|
||||
bugTrackerRepository.deleteById(id);
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
"package com.realnet.bugTracker.Entity;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import javax.persistence.Entity;" + "\r\n" +
|
||||
"import javax.persistence.GeneratedValue;" + "\r\n" +
|
||||
"import javax.persistence.GenerationType;" + "\r\n" +
|
||||
"import javax.persistence.Id;" + "\r\n" +
|
||||
"import javax.persistence.Lob;" + "\r\n" +
|
||||
"import javax.persistence.Table;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.incident.entity.WhooColomns;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import lombok.Data;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Entity" + "\r\n" +
|
||||
"@Data" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public class BugTracker extends WhooColomns {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Id" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private String type;" + "\r\n" +
|
||||
" private String key_no;" + "\r\n" +
|
||||
" private String summary;" + "\r\n" +
|
||||
" private String assignee;" + "\r\n" +
|
||||
" private String reporter;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" private String select_project;" + "\r\n" +
|
||||
" private String title;" + "\r\n" +
|
||||
" private String select_status;" + "\r\n" +
|
||||
" private String select_priority;" + "\r\n" +
|
||||
" private String steps;" + "\r\n" +
|
||||
" private String description;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" private String fileName;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" private String fileType;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Lob" + "\r\n" +
|
||||
" private byte[] data;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"}"
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
"package com.realnet.bugTracker.Controller;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.http.HttpStatus;" + "\r\n" +
|
||||
"import org.springframework.http.ResponseEntity;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.DeleteMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.GetMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PathVariable;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PostMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PutMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestBody;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestParam;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RestController;" + "\r\n" +
|
||||
"import org.springframework.web.multipart.MultipartFile;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.fasterxml.jackson.core.JsonProcessingException;" + "\r\n" +
|
||||
"import com.fasterxml.jackson.databind.JsonMappingException;" + "\r\n" +
|
||||
"import com.fasterxml.jackson.databind.ObjectMapper;" + "\r\n" +
|
||||
"import com.realnet.activity.service.ActivityService;" + "\r\n" +
|
||||
"import com.realnet.bugTracker.Entity.BugTracker;" + "\r\n" +
|
||||
"import com.realnet.bugTracker.Service.BugTrackerService;" + "\r\n" +
|
||||
"import com.realnet.fileupload.helper.Fileuploadhelper;" + "\r\n" +
|
||||
"import com.realnet.incident.entity.IncidentEntity;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"@RequestMapping(\"/sureserve/bugtracker\")" + "\r\n" +
|
||||
"public class BugTrackerController {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private BugTrackerService bugTrackerService;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private Fileuploadhelper fileuploadhelper;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @PostMapping(\"/bugtracker\")" + "\r\n" +
|
||||
" public ResponseEntity<String> createIssue(@RequestParam String data, @RequestParam MultipartFile file)" + "\r\n" +
|
||||
" throws JsonMappingException, JsonProcessingException {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Deserialize the \"data\" parameter to a BugTracker object using Jackson's" + "\r\n" +
|
||||
" // ObjectMapper" + "\r\n" +
|
||||
" BugTracker bugTracker = new ObjectMapper().readValue(data, BugTracker.class);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Check if a file was uploaded" + "\r\n" +
|
||||
" if (!file.isEmpty()) {" + "\r\n" +
|
||||
" System.out.println(file.getOriginalFilename());" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Use a file upload helper method to upload the file and return a boolean" + "\r\n" +
|
||||
" // indicating success or failure" + "\r\n" +
|
||||
" boolean isUploaded = fileuploadhelper.uploadFile(file);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (isUploaded) {" + "\r\n" +
|
||||
" System.out.println(\"File uploaded successfully\");" + "\r\n" +
|
||||
" bugTracker.setFileName(file.getOriginalFilename());" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" } else {" + "\r\n" +
|
||||
" bugTracker.setFileName(\"No file\");" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Pass the updated BugTracker object to the bugTrackerService's createIssue" + "\r\n" +
|
||||
" // method to create a new BugTracker object" + "\r\n" +
|
||||
" BugTracker createdTracker = bugTrackerService.createIssue(bugTracker);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return ResponseEntity.ok(\"addded successfully\");" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @GetMapping(\"/bugtracker/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<BugTracker> getIssueById(@PathVariable Long id) {" + "\r\n" +
|
||||
" BugTracker tracker = bugTrackerService.getIssueById(id);" + "\r\n" +
|
||||
" return ResponseEntity.ok(tracker);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @GetMapping(\"/bugtracker\")" + "\r\n" +
|
||||
" public ResponseEntity<List<BugTracker>> getAllIssues() {" + "\r\n" +
|
||||
" List<BugTracker> allIssues = bugTrackerService.getAllIssues();" + "\r\n" +
|
||||
" return ResponseEntity.ok(allIssues);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @PutMapping(\"/bugtracker/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<String> updateIssue(@RequestParam String data, @PathVariable Long id," + "\r\n" +
|
||||
" @RequestParam MultipartFile file) throws Exception {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" BugTracker bugTracker = new ObjectMapper().readValue(data, BugTracker.class);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (!file.isEmpty()) {" + "\r\n" +
|
||||
" System.out.println(file.getOriginalFilename());" + "\r\n" +
|
||||
" boolean f = fileuploadhelper.uploadFile(file);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (f) {" + "\r\n" +
|
||||
" System.out.println(\"file uploaded successfully\");" + "\r\n" +
|
||||
" bugTracker.setFileName(file.getOriginalFilename());" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" } else {" + "\r\n" +
|
||||
" bugTracker.setFileName(\"No file\");" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Update the bug tracker with the new incident entity" + "\r\n" +
|
||||
" bugTrackerService.updateIssue(id, bugTracker);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return ResponseEntity.ok(\"Update successfully\");" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @DeleteMapping(\"/bugtracker/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<String> deleteIssue(@PathVariable Long id) {" + "\r\n" +
|
||||
" bugTrackerService.deleteIssue(id);" + "\r\n" +
|
||||
" String message = \"Issue with ID \" + id + \" has been deleted\";" + "\r\n" +
|
||||
" return ResponseEntity.ok(message);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"}"
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
"package com.realnet.bugTracker.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"import org.springframework.stereotype.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.bugTracker.Entity.BugTracker;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Repository" + "\r\n" +
|
||||
"public interface BugTrackerRepository extends JpaRepository<BugTracker, Long> {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"}"
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
"package com.realnet.bugTracker.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import javax.persistence.EntityNotFoundException;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.bugTracker.Entity.BugTracker;" + "\r\n" +
|
||||
"import com.realnet.bugTracker.Repository.BugTrackerRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
"public class BugTrackerService {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private BugTrackerRepository bugTrackerRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public BugTracker createIssue(BugTracker tracker) {" + "\r\n" +
|
||||
" return bugTrackerRepository.save(tracker);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public BugTracker getIssueById(Long id) {" + "\r\n" +
|
||||
" return bugTrackerRepository.findById(id).orElseThrow(() -> new EntityNotFoundException(\"Issue not found\"));" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public List<BugTracker> getAllIssues() {" + "\r\n" +
|
||||
" return bugTrackerRepository.findAll();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public BugTracker updateIssue(Long id, BugTracker tracker) {" + "\r\n" +
|
||||
" BugTracker existingIssue = getIssueById(id);" + "\r\n" +
|
||||
" existingIssue.setType(tracker.getType());" + "\r\n" +
|
||||
" existingIssue.setKey_no(tracker.getKey_no());" + "\r\n" +
|
||||
" existingIssue.setSummary(tracker.getSummary());" + "\r\n" +
|
||||
" existingIssue.setAssignee(tracker.getAssignee());" + "\r\n" +
|
||||
" existingIssue.setReporter(tracker.getReporter());" + "\r\n" +
|
||||
" existingIssue.setSelect_project(tracker.getSelect_project());" + "\r\n" +
|
||||
" existingIssue.setTitle(tracker.getTitle());" + "\r\n" +
|
||||
" existingIssue.setSelect_status(tracker.getSelect_status());" + "\r\n" +
|
||||
" existingIssue.setSelect_priority(tracker.getSelect_priority());" + "\r\n" +
|
||||
" existingIssue.setSteps(tracker.getSteps());" + "\r\n" +
|
||||
" existingIssue.setDescription(tracker.getDescription());" + "\r\n" +
|
||||
" existingIssue.setFileName(tracker.getFileName());" + "\r\n" +
|
||||
" existingIssue.setFileType(tracker.getFileType());" + "\r\n" +
|
||||
" existingIssue.setData(tracker.getData());" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return bugTrackerRepository.save(existingIssue);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public void deleteIssue(Long id) {" + "\r\n" +
|
||||
" bugTrackerRepository.deleteById(id);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"}"
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.realnet.entityevents.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.*;
|
||||
|
||||
import com.realnet.entityevents.Entity.Entity_events_t;
|
||||
import com.realnet.entityevents.Service.Entity_eventsService;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/entityevents")
|
||||
public class Entity_eventsController {
|
||||
|
||||
@Autowired
|
||||
private Entity_eventsService entity_eventsService;
|
||||
|
||||
// Get all entity events
|
||||
@GetMapping("/entityevents")
|
||||
public ResponseEntity<List<Entity_events_t>> getAllEntityEvents() {
|
||||
List<Entity_events_t> entityEvents = entity_eventsService.getAllEntityEvents();
|
||||
return new ResponseEntity<List<Entity_events_t>>(entityEvents, HttpStatus.OK);
|
||||
}
|
||||
|
||||
// Get entity event by ID
|
||||
@GetMapping("/entityevents/{id}")
|
||||
public ResponseEntity<Entity_events_t> getEntityEventById(@PathVariable Long id) {
|
||||
Entity_events_t entityEvent = entity_eventsService.getEntityEventById(id);
|
||||
if (entityEvent != null) {
|
||||
return new ResponseEntity<Entity_events_t>(entityEvent, HttpStatus.OK);
|
||||
} else {
|
||||
return new ResponseEntity<Entity_events_t>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
// Create entity event
|
||||
@PostMapping("/entityevents")
|
||||
public ResponseEntity<Entity_events_t> createEntityEvent(@RequestBody Entity_events_t entityEvent) {
|
||||
Entity_events_t createdEntityEvent = entity_eventsService.createEntityEvent(entityEvent);
|
||||
return new ResponseEntity<Entity_events_t>(createdEntityEvent, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
// Update entity event
|
||||
@PutMapping("/entityevents/{id}")
|
||||
public ResponseEntity<Entity_events_t> updateEntityEvent(@PathVariable Long id, @RequestBody Entity_events_t entityEvent) {
|
||||
Entity_events_t updatedEntityEvent = entity_eventsService.updateEntityEvent(id, entityEvent);
|
||||
if (updatedEntityEvent != null) {
|
||||
return new ResponseEntity<Entity_events_t>(updatedEntityEvent, HttpStatus.OK);
|
||||
} else {
|
||||
return new ResponseEntity<Entity_events_t>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Delete entity event
|
||||
@DeleteMapping("/entityevents/{id}")
|
||||
public ResponseEntity<String> deleteEntityEvent(@PathVariable Long id) {
|
||||
entity_eventsService.deleteEntityEvent(id);
|
||||
String message = "ID " + id + " has been deleted";
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// @GetMapping("/entityevents/name-type")
|
||||
// public ResponseEntity<Boolean> getEntityEventByName(@RequestParam("entity_name") String entity_name, @RequestParam("event_type") String event_type) {
|
||||
// boolean exists = entity_eventsService.existsByEntityNameAndEventType(entity_name, event_type);
|
||||
// return new ResponseEntity<Boolean>(exists, HttpStatus.OK);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.realnet.entityevents.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.entityevents.Entity.Entity_events_t;
|
||||
|
||||
@Repository
|
||||
public interface Entity_eventsRepository extends JpaRepository<Entity_events_t, Long> {
|
||||
|
||||
@Query(value = "SELECT * FROM realnet_CNSBE.entity_events_t WHERE entity_name = :entityName", nativeQuery = true)
|
||||
List<Entity_events_t> findByEntityName(@Param("entityName") String entityName);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.realnet.entityevents.Service;
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.realnet.entityevents.Entity.Entity_events_t;
|
||||
import com.realnet.entityevents.Repository.Entity_eventsRepository;
|
||||
|
||||
|
||||
@Service
|
||||
public class Entity_eventsService {
|
||||
|
||||
@Autowired
|
||||
private Entity_eventsRepository entity_eventsRepository;
|
||||
|
||||
public List<Entity_events_t> getAllEntityEvents() {
|
||||
return entity_eventsRepository.findAll();
|
||||
}
|
||||
|
||||
public Entity_events_t getEntityEventById(Long id) {
|
||||
return entity_eventsRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public Entity_events_t createEntityEvent(Entity_events_t entityEvent) {
|
||||
return entity_eventsRepository.save(entityEvent);
|
||||
}
|
||||
|
||||
public Entity_events_t updateEntityEvent(Long id, Entity_events_t entityEvent) {
|
||||
Entity_events_t existingEntityEvent = entity_eventsRepository.findById(id).orElse(null);
|
||||
if (existingEntityEvent != null) {
|
||||
existingEntityEvent.setEntity_name(entityEvent.getEntity_name());
|
||||
existingEntityEvent.setEvent_type(entityEvent.getEvent_type());
|
||||
existingEntityEvent.set_active(entityEvent.is_active());
|
||||
return entity_eventsRepository.save(existingEntityEvent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void deleteEntityEvent(Long id) {
|
||||
entity_eventsRepository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isEntityAllowed(String entity_name) {
|
||||
|
||||
System.out.println("isEntityAllowed called " + entity_name);
|
||||
|
||||
if (entity_name == null || entity_name.isEmpty()) {
|
||||
return true; // Allow unspecified entities
|
||||
}
|
||||
|
||||
List<Entity_events_t> entityEventsList = entity_eventsRepository.findByEntityName(entity_name);
|
||||
if (entityEventsList == null || entityEventsList.isEmpty()) {
|
||||
return false; // Disallow entities not found in entity events
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// public boolean existsByEntityNameAndEventType(String entity_name, String event_type) {
|
||||
// return entity_eventsRepository.existsByEntityNameAndEventType(entity_name, event_type);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.realnet.entityevents.Entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.realnet.fnd.entity.Rn_Who_AccId_Column;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Entity_events_t extends Rn_Who_AccId_Column{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String entity_name;
|
||||
|
||||
private String event_type;
|
||||
|
||||
private boolean is_active = true;
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
"package com.realnet.entityevents.Controller;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.http.HttpStatus;" + "\r\n" +
|
||||
"import org.springframework.http.ResponseEntity;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.*;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.entityevents.Entity.Entity_events_t;" + "\r\n" +
|
||||
"import com.realnet.entityevents.Service.Entity_eventsService;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"@RequestMapping(\"/entityevents\")" + "\r\n" +
|
||||
"public class Entity_eventsController {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private Entity_eventsService entity_eventsService;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Get all entity events" + "\r\n" +
|
||||
" @GetMapping(\"/entityevents\")" + "\r\n" +
|
||||
" public ResponseEntity<List<Entity_events_t>> getAllEntityEvents() {" + "\r\n" +
|
||||
" List<Entity_events_t> entityEvents = entity_eventsService.getAllEntityEvents();" + "\r\n" +
|
||||
" return new ResponseEntity<List<Entity_events_t>>(entityEvents, HttpStatus.OK);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Get entity event by ID" + "\r\n" +
|
||||
" @GetMapping(\"/entityevents/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<Entity_events_t> getEntityEventById(@PathVariable Long id) {" + "\r\n" +
|
||||
" Entity_events_t entityEvent = entity_eventsService.getEntityEventById(id);" + "\r\n" +
|
||||
" if (entityEvent != null) {" + "\r\n" +
|
||||
" return new ResponseEntity<Entity_events_t>(entityEvent, HttpStatus.OK);" + "\r\n" +
|
||||
" } else {" + "\r\n" +
|
||||
" return new ResponseEntity<Entity_events_t>(HttpStatus.NOT_FOUND);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Create entity event" + "\r\n" +
|
||||
" @PostMapping(\"/entityevents\")" + "\r\n" +
|
||||
" public ResponseEntity<Entity_events_t> createEntityEvent(@RequestBody Entity_events_t entityEvent) {" + "\r\n" +
|
||||
" Entity_events_t createdEntityEvent = entity_eventsService.createEntityEvent(entityEvent);" + "\r\n" +
|
||||
" return new ResponseEntity<Entity_events_t>(createdEntityEvent, HttpStatus.CREATED);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Update entity event" + "\r\n" +
|
||||
" @PutMapping(\"/entityevents/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<Entity_events_t> updateEntityEvent(@PathVariable Long id, @RequestBody Entity_events_t entityEvent) {" + "\r\n" +
|
||||
" Entity_events_t updatedEntityEvent = entity_eventsService.updateEntityEvent(id, entityEvent);" + "\r\n" +
|
||||
" if (updatedEntityEvent != null) {" + "\r\n" +
|
||||
" return new ResponseEntity<Entity_events_t>(updatedEntityEvent, HttpStatus.OK);" + "\r\n" +
|
||||
" } else {" + "\r\n" +
|
||||
" return new ResponseEntity<Entity_events_t>(HttpStatus.NOT_FOUND);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" // Delete entity event" + "\r\n" +
|
||||
" @DeleteMapping(\"/entityevents/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<String> deleteEntityEvent(@PathVariable Long id) {" + "\r\n" +
|
||||
" entity_eventsService.deleteEntityEvent(id);" + "\r\n" +
|
||||
" String message = \"ID \" + id + \" has been deleted\";" + "\r\n" +
|
||||
" return ResponseEntity.ok(message);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"// @GetMapping(\"/entityevents/name-type\")" + "\r\n" +
|
||||
"// public ResponseEntity<Boolean> getEntityEventByName(@RequestParam(\"entity_name\") String entity_name, @RequestParam(\"event_type\") String event_type) {" + "\r\n" +
|
||||
"// boolean exists = entity_eventsService.existsByEntityNameAndEventType(entity_name, event_type);" + "\r\n" +
|
||||
"// return new ResponseEntity<Boolean>(exists, HttpStatus.OK);" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"}"
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"package com.realnet.entityevents.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.Query;" + "\r\n" +
|
||||
"import org.springframework.data.repository.query.Param;" + "\r\n" +
|
||||
"import org.springframework.stereotype.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.entityevents.Entity.Entity_events_t;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Repository" + "\r\n" +
|
||||
"public interface Entity_eventsRepository extends JpaRepository<Entity_events_t, Long> {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Query(value = \"SELECT * FROM realnet_CNSBE.entity_events_t WHERE entity_name = :entityName\", nativeQuery = true)" + "\r\n" +
|
||||
" List<Entity_events_t> findByEntityName(@Param(\"entityName\") String entityName);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"}" + "\r\n" +
|
||||
""
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
"package com.realnet.entityevents.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.util.HashSet;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.util.Set;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.entityevents.Entity.Entity_events_t;" + "\r\n" +
|
||||
"import com.realnet.entityevents.Repository.Entity_eventsRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
"public class Entity_eventsService {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private Entity_eventsRepository entity_eventsRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public List<Entity_events_t> getAllEntityEvents() {" + "\r\n" +
|
||||
" return entity_eventsRepository.findAll();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public Entity_events_t getEntityEventById(Long id) {" + "\r\n" +
|
||||
" return entity_eventsRepository.findById(id).orElse(null);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public Entity_events_t createEntityEvent(Entity_events_t entityEvent) {" + "\r\n" +
|
||||
" return entity_eventsRepository.save(entityEvent);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public Entity_events_t updateEntityEvent(Long id, Entity_events_t entityEvent) {" + "\r\n" +
|
||||
" Entity_events_t existingEntityEvent = entity_eventsRepository.findById(id).orElse(null);" + "\r\n" +
|
||||
" if (existingEntityEvent != null) {" + "\r\n" +
|
||||
" existingEntityEvent.setEntity_name(entityEvent.getEntity_name());" + "\r\n" +
|
||||
" existingEntityEvent.setEvent_type(entityEvent.getEvent_type());" + "\r\n" +
|
||||
" existingEntityEvent.set_active(entityEvent.is_active());" + "\r\n" +
|
||||
" return entity_eventsRepository.save(existingEntityEvent);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" return null;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public void deleteEntityEvent(Long id) {" + "\r\n" +
|
||||
" entity_eventsRepository.deleteById(id);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public boolean isEntityAllowed(String entity_name) {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" System.out.println(\"isEntityAllowed called \" + entity_name);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (entity_name == null || entity_name.isEmpty()) {" + "\r\n" +
|
||||
" return true; // Allow unspecified entities" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" List<Entity_events_t> entityEventsList = entity_eventsRepository.findByEntityName(entity_name);" + "\r\n" +
|
||||
" if (entityEventsList == null || entityEventsList.isEmpty()) {" + "\r\n" +
|
||||
" return false; // Disallow entities not found in entity events" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return true;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
serviceloop1
|
||||
"}"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"package com.realnet.entityevents.Entity;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import javax.persistence.Entity;" + "\r\n" +
|
||||
"import javax.persistence.GeneratedValue;" + "\r\n" +
|
||||
"import javax.persistence.GenerationType;" + "\r\n" +
|
||||
"import javax.persistence.Id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import lombok.Data;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.fnd.entity.Rn_Who_AccId_Column;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Entity" + "\r\n" +
|
||||
"@Data" + "\r\n" +
|
||||
"public class Entity_events_t extends Rn_Who_AccId_Column{" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Id" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private String entity_name;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private String event_type;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" private boolean is_active = true;" + "\r\n" +
|
||||
"}"
|
||||
+1071
File diff suppressed because it is too large
Load Diff
+75
@@ -0,0 +1,75 @@
|
||||
package com.realnet.template.controller;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.realnet.template.repository.DynamicTempRepo;
|
||||
import com.realnet.template.service.DatabaseQueryService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sureserve/template/databasequery")
|
||||
public class DatabaseQueryController {
|
||||
|
||||
@Autowired
|
||||
private DatabaseQueryService rn_table_service;
|
||||
@Autowired
|
||||
private DynamicTempRepo tempRepo;
|
||||
|
||||
@Value("${spring.datasource.username}")
|
||||
private String userName;
|
||||
|
||||
@Value("${spring.datasource.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
private String url;
|
||||
|
||||
// get all databse list available
|
||||
@GetMapping("/Table_list")
|
||||
@ResponseBody
|
||||
public List<Object> getdatabase() {
|
||||
List<Object> list = tempRepo.getdatabaseList();
|
||||
return list;
|
||||
}
|
||||
|
||||
// get all table list available
|
||||
@GetMapping("/Table_list_all")
|
||||
@ResponseBody
|
||||
public List<String> gettableList()
|
||||
|
||||
// @PathVariable String table_schema)
|
||||
{
|
||||
// List<String> list = tempRepo.getListOftables(table_schema);
|
||||
List<String> list = rn_table_service.getListOftable("sureserve");
|
||||
return list;
|
||||
}
|
||||
|
||||
// get all column list available
|
||||
@GetMapping("/Table_list/{table_schema}/{TABLE_NAME}")
|
||||
@ResponseBody
|
||||
public List<String> getallcolumnlist(@PathVariable String table_schema, @PathVariable String TABLE_NAME) {
|
||||
List<String> list = rn_table_service.getColumnAliasList1(table_schema, TABLE_NAME);
|
||||
return list;
|
||||
}
|
||||
|
||||
// create database
|
||||
@GetMapping("/createdatabase/{table_schema}")
|
||||
@ResponseBody
|
||||
public List<Integer> createdatabase(@PathVariable String table_schema) {
|
||||
List<Integer> list = rn_table_service.createdatabase(table_schema);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.realnet.template.service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@Service
|
||||
public class DatabaseQueryService {
|
||||
|
||||
@Value("${spring.datasource.username}")
|
||||
private String userName;
|
||||
|
||||
@Value("${spring.datasource.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.datasource.url}")
|
||||
private String url;
|
||||
|
||||
// get all column
|
||||
|
||||
public List<String> getColumnAliasList1(String table_schema, String tABLE_NAME) {
|
||||
String query = "SELECT column_name FROM information_schema.columns WHERE TABLE_SCHEMA='" + table_schema
|
||||
+ "' and table_name = '" + tABLE_NAME + "' ";
|
||||
List<String> list = new ArrayList<String>();
|
||||
try (Connection con = DriverManager.getConnection(url, userName, password);
|
||||
|
||||
Statement stmt = con.createStatement()) {
|
||||
ResultSet rs = stmt.executeQuery(query);
|
||||
while (rs.next()) {
|
||||
String coffeeName = rs.getString("column_name");
|
||||
list.add(coffeeName);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// get all table list from databse
|
||||
|
||||
public List<String> getListOftable(String table_schema) {
|
||||
String query = "SELECT table_name FROM information_schema.tables WHERE table_schema='" + table_schema + "' ";
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
try (Connection con = DriverManager.getConnection(url, userName, password);
|
||||
|
||||
Statement stmt = con.createStatement()) {
|
||||
ResultSet rs = stmt.executeQuery(query);
|
||||
while (rs.next()) {
|
||||
String coffeeName = rs.getString("table_name");
|
||||
list.add(coffeeName);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<Integer> createdatabase(String table_schema){
|
||||
String query = "CREATE SCHEMA " + table_schema + ";";
|
||||
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
try (Connection con = DriverManager.getConnection(url, userName, password); // conn.str
|
||||
|
||||
Statement stmt = con.createStatement()) {
|
||||
int rs = stmt.executeUpdate(query);
|
||||
|
||||
list.add(rs);
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.realnet.template.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.realnet.template.entity.Dynamic_template;
|
||||
|
||||
@Repository
|
||||
public interface DynamicTempRepo extends JpaRepository<Dynamic_template, Long>{
|
||||
|
||||
|
||||
@Query(value= "select schema_name from information_schema.schemata",nativeQuery = true)
|
||||
List<Object> getdatabaseList();
|
||||
|
||||
@Query(value= "SELECT table_name FROM information_schema.tables WHERE table_schema =?1",nativeQuery = true)
|
||||
List<String> getListOftables(String table_schema);
|
||||
|
||||
@Query(value= "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE `TABLE_SCHEMA`=:'TABLE_SCHEMA' AND `TABLE_NAME`='TABLE_NAME';",nativeQuery = true)
|
||||
List<Object> getallcolumnlist(@Param("TABLE_SCHEMA") Object table_schema, @Param("TABLE_NAME") Object tABLE_NAME);
|
||||
}
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
package com.realnet.template.controller;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.json.simple.JSONObject;
|
||||
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.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.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.realnet.Notification.Notification.Entity.NotEntity;
|
||||
import com.realnet.fileupload.helper.Fileuploadhelper;
|
||||
import com.realnet.incident.entity.IncidentEntity;
|
||||
import com.realnet.template.entity.Dynamic_template;
|
||||
import com.realnet.template.repository.DynamicTempRepo;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sureserve/template/dynamic")
|
||||
public class DynamicTemplateController {
|
||||
|
||||
@Autowired
|
||||
private DynamicTempRepo tempRepo;
|
||||
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
|
||||
@Autowired
|
||||
private Fileuploadhelper fileuploadhelper;
|
||||
|
||||
@GetMapping("/templatetojson")
|
||||
public ResponseEntity<?> saveTemplateInJson(@RequestParam MultipartFile file) throws IOException {
|
||||
|
||||
BufferedReader br;
|
||||
InputStream is = file.getInputStream();
|
||||
br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
Workbook workbook = WorkbookFactory.create(is);
|
||||
|
||||
// Create a DataFormatter to format and get each cell's value as String
|
||||
DataFormatter dataFormatter = new DataFormatter();
|
||||
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
// Getting number of columns in the Sheet
|
||||
int cols = sheet.getRow(0).getLastCellNum();
|
||||
int firstRowNum = sheet.getFirstRowNum();
|
||||
|
||||
List<String> keys = new ArrayList<String>();
|
||||
List<JSONObject> jsonList = new ArrayList<JSONObject>();
|
||||
|
||||
for (Row row : sheet) {
|
||||
JSONObject object = new JSONObject();
|
||||
if (row.getRowNum() == 0) {
|
||||
for (int i = 0; i < cols; i++) {
|
||||
String value = dataFormatter.formatCellValue(row.getCell(i));
|
||||
keys.add(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (row.getRowNum() != 0) {
|
||||
|
||||
for (int i = 0; i < cols; i++) {
|
||||
String key = keys.get(i);
|
||||
String value = dataFormatter.formatCellValue(row.getCell(i));
|
||||
|
||||
object.put(key, value);
|
||||
|
||||
jsonList.add(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
workbook.close();
|
||||
|
||||
return new ResponseEntity<>(jsonList, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@GetMapping("/jsonkeychange")
|
||||
|
||||
public ResponseEntity<?> changeKeysOfJson(@RequestParam String newjson, @RequestParam String body)
|
||||
throws IOException {
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement element = parser.parse(newjson);
|
||||
JsonElement element2 = parser.parse(body);
|
||||
JsonObject object2 = element.getAsJsonObject();
|
||||
JsonArray array = element2.getAsJsonArray();
|
||||
Iterator iterator = array.iterator();
|
||||
|
||||
List<Map> jsonList = new ArrayList<Map>();
|
||||
|
||||
Set<String> keySet = object2.keySet();
|
||||
Iterator<String> it = keySet.iterator();
|
||||
|
||||
// String key = it.next();
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Object next = iterator.next();
|
||||
JsonElement parse = parser.parse(next.toString());
|
||||
JsonObject jsonObject = parse.getAsJsonObject();
|
||||
for (String k : keySet) {
|
||||
String next2 = object2.get(k).getAsString();
|
||||
String value2 = jsonObject.get(k).getAsString();
|
||||
map.put(next2, value2);
|
||||
}
|
||||
|
||||
jsonList.add(map);
|
||||
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(jsonList, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
// create data with file upload
|
||||
@PostMapping("/dynamic_temp")
|
||||
public ResponseEntity<?> addIssues(@RequestParam String data, @RequestParam MultipartFile file)
|
||||
throws JsonMappingException, JsonProcessingException {
|
||||
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
String userId = user.getUsername();
|
||||
Dynamic_template dynamic_template;
|
||||
|
||||
dynamic_template = new ObjectMapper().readValue(data, Dynamic_template.class);
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
// for (MultipartFile e : attachmentFile) {
|
||||
System.out.println(file.getOriginalFilename());
|
||||
|
||||
boolean f = fileuploadhelper.uploadFile(file);
|
||||
|
||||
if (f) {
|
||||
System.out.println("file uploaded successfully");
|
||||
dynamic_template.setFile_name(file.getOriginalFilename());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
dynamic_template.setFile_name("No file");
|
||||
|
||||
}
|
||||
|
||||
dynamic_template.setUser_id(userId);
|
||||
|
||||
Dynamic_template save = tempRepo.save(dynamic_template);
|
||||
|
||||
if (save.getId() == 0) {
|
||||
return new ResponseEntity<String>("template Not Added", HttpStatus.BAD_REQUEST);
|
||||
} else {
|
||||
|
||||
return new ResponseEntity<>(save, HttpStatus.ACCEPTED);
|
||||
}
|
||||
}
|
||||
|
||||
// get all
|
||||
@GetMapping("/dynamic_temp")
|
||||
public ResponseEntity<?> getAll() {
|
||||
|
||||
return new ResponseEntity<>(tempRepo.findAll(), HttpStatus.ACCEPTED);
|
||||
|
||||
}
|
||||
|
||||
// get by id
|
||||
@GetMapping("/dynamic_temp/{id}")
|
||||
public ResponseEntity<?> getIssueById(@PathVariable Long id) {
|
||||
|
||||
return new ResponseEntity<>(tempRepo.findById(id).get(), HttpStatus.ACCEPTED);
|
||||
|
||||
}
|
||||
|
||||
// delete by id
|
||||
@DeleteMapping("/dynamic_temp/{id}")
|
||||
public ResponseEntity<?> deleteIssue(@PathVariable Long id) {
|
||||
tempRepo.deleteById(id);
|
||||
return new ResponseEntity<String>("Success", HttpStatus.ACCEPTED);
|
||||
|
||||
}
|
||||
|
||||
// update by id
|
||||
@PutMapping("/dynamic_temp/{id}")
|
||||
public ResponseEntity<?> updateIssue(@RequestParam String data, @PathVariable Long id,
|
||||
@RequestParam MultipartFile file) throws Exception {
|
||||
|
||||
Dynamic_template dynamic_template;
|
||||
dynamic_template = new ObjectMapper().readValue(data, Dynamic_template.class);
|
||||
|
||||
Dynamic_template template = tempRepo.findById(id).get();
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
System.out.println(file.getOriginalFilename());
|
||||
|
||||
boolean f = fileuploadhelper.uploadFile(file);
|
||||
|
||||
if (f) {
|
||||
System.out.println("file uploaded successfully");
|
||||
template.setFile_name(file.getOriginalFilename());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
template.setFile_name("No file");
|
||||
|
||||
}
|
||||
|
||||
template.setEntity_name(dynamic_template.getEntity_name());
|
||||
template.setUser_id(dynamic_template.getUser_id());
|
||||
|
||||
Dynamic_template save = tempRepo.save(template);
|
||||
return new ResponseEntity<>(save, HttpStatus.ACCEPTED);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.realnet.template.entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Dynamic_template {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String user_id;
|
||||
private String file_name;
|
||||
private String entity_name;
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
//package com.realnet.excel.service;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.apache.poi.EncryptedDocumentException;
|
||||
//import org.apache.poi.ss.usermodel.Cell;
|
||||
//import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
//import org.apache.poi.ss.usermodel.Row;
|
||||
//import org.apache.poi.ss.usermodel.Sheet;
|
||||
//import org.apache.poi.ss.usermodel.Workbook;
|
||||
//import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import com.realnet.excel.entity.ExcelFileUpload;
|
||||
//
|
||||
//@Service
|
||||
//public class ExcelDataService {
|
||||
//
|
||||
// Workbook workbook;
|
||||
//
|
||||
// public List<ExcelFileUpload> getExcelDataAsList() {
|
||||
//
|
||||
// List<String> list = new ArrayList<String>();
|
||||
//
|
||||
// // Create a DataFormatter to format and get each cell's value as String
|
||||
// DataFormatter dataFormatter = new DataFormatter();
|
||||
//
|
||||
// // Create the Workbook
|
||||
//// try {
|
||||
//// workbook = WorkbookFactory.create();
|
||||
//// } catch (EncryptedDocumentException | IOException e) {
|
||||
//// e.printStackTrace();
|
||||
//// }
|
||||
//
|
||||
// // Retrieving the number of sheets in the Workbook
|
||||
// System.out.println("-------Workbook has '" + workbook.getNumberOfSheets() + "' Sheets-----");
|
||||
//
|
||||
// // Getting the Sheet at index zero
|
||||
// Sheet sheet = workbook.getSheetAt(0);
|
||||
//
|
||||
// // Getting number of columns in the Sheet
|
||||
// int noOfColumns = sheet.getRow(0).getLastCellNum();
|
||||
// System.out.println("-------Sheet has '"+noOfColumns+"' columns------");
|
||||
//
|
||||
// // Using for-each loop to iterate over the rows and columns
|
||||
// for (Row row : sheet) {
|
||||
// for (Cell cell : row) {
|
||||
// String cellValue = dataFormatter.formatCellValue(cell);
|
||||
// list.add(cellValue);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // filling excel data and creating list as List<Invoice>
|
||||
// List<ExcelFileUpload> invList = createList(list, noOfColumns);
|
||||
//
|
||||
// // Closing the workbook
|
||||
// try {
|
||||
// workbook.close();
|
||||
// } catch (IOException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return invList;
|
||||
// }
|
||||
//
|
||||
// private List<ExcelFileUpload> createList(List<String> excelData, int noOfColumns) {
|
||||
//
|
||||
// ArrayList<ExcelFileUpload> invList = new ArrayList<ExcelFileUpload>();
|
||||
//
|
||||
// int i = noOfColumns;
|
||||
// do {
|
||||
// ExcelFileUpload inv = new ExcelFileUpload();
|
||||
//
|
||||
//// inv.setName(excelData.get(i));
|
||||
//// inv.setAmount(Double.valueOf(excelData.get(i + 1)));
|
||||
//// inv.setNumber(excelData.get(i + 2));
|
||||
//// inv.setReceivedDate(excelData.get(i + 3));
|
||||
//
|
||||
// invList.add(inv);
|
||||
// i = i + (noOfColumns);
|
||||
//
|
||||
// } while (i < excelData.size());
|
||||
// return invList;
|
||||
// }
|
||||
//
|
||||
//// public int saveExcelData(List<ExcelFileUpload> invoices) {
|
||||
//// invoices = repo.saveAll(invoices);
|
||||
//// return invoices.size();
|
||||
//// }
|
||||
//
|
||||
|
||||
|
||||
//}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.realnet.template.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.realnet.template.entity.TemplateFileUpload;
|
||||
import com.realnet.template.repository.TemplatedataRepo;
|
||||
|
||||
@Service
|
||||
public class FileUploadService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private TemplatedataRepo repo;
|
||||
|
||||
|
||||
|
||||
public String uploadFile(MultipartFile file,Long user_id,String file_type) {
|
||||
try {
|
||||
|
||||
// String
|
||||
String file_name= file.getOriginalFilename();
|
||||
String substring = file_name.substring(0,file_name.lastIndexOf("."));
|
||||
|
||||
String str = substring+System.currentTimeMillis();
|
||||
String location =System.getProperty("user.dir")+"/src/main/resources";
|
||||
|
||||
|
||||
String file_name2= file.getOriginalFilename();
|
||||
|
||||
|
||||
File staticdir2 = new File(location+"/incomingfile");
|
||||
if(!staticdir2.exists()) {
|
||||
staticdir2.mkdir();
|
||||
}
|
||||
Path copyLocation2 = Paths
|
||||
.get(staticdir2 + File.separator + StringUtils.cleanPath(file_name2));
|
||||
|
||||
Files.copy(file.getInputStream(), copyLocation2, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
|
||||
File staticdir = new File(location+"/processingfile");
|
||||
if(!staticdir.exists()) {
|
||||
staticdir.mkdir();
|
||||
}
|
||||
Path copyLocation = Paths
|
||||
.get(staticdir + File.separator + StringUtils.cleanPath(str+".xlsx"));
|
||||
|
||||
Files.copy(file.getInputStream(), copyLocation, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
|
||||
TemplateFileUpload exceldata= new TemplateFileUpload();
|
||||
exceldata.setFile_location(location);
|
||||
|
||||
exceldata.setFile_name(file.getOriginalFilename());
|
||||
exceldata.setFile_changed_name(str);
|
||||
exceldata.setFile_type(file_type);
|
||||
exceldata.setUser_id(user_id);
|
||||
repo.save(exceldata);
|
||||
|
||||
System.out.println("-----------------------saving data----------------");
|
||||
return location;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Could not store file " + file.getOriginalFilename()
|
||||
+ ". Please try again!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.realnet.template.entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TemplateFileUpload {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private Long user_id;
|
||||
private String file_name;
|
||||
private String file_changed_name;
|
||||
private String file_location;
|
||||
private String file_type;
|
||||
private Integer status;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.realnet.template.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.realnet.template.entity.TemplateFileUpload;
|
||||
|
||||
public interface TemplatedataRepo extends JpaRepository<TemplateFileUpload, Long>{
|
||||
|
||||
}
|
||||
+1071
File diff suppressed because it is too large
Load Diff
+75
@@ -0,0 +1,75 @@
|
||||
"package com.realnet.template.controller;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.sql.Connection;" + "\r\n" +
|
||||
"import java.sql.DriverManager;" + "\r\n" +
|
||||
"import java.sql.SQLException;" + "\r\n" +
|
||||
"import java.sql.Statement;" + "\r\n" +
|
||||
"import java.util.ArrayList;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Value;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.GetMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PathVariable;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.ResponseBody;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RestController;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.template.repository.DynamicTempRepo;" + "\r\n" +
|
||||
"import com.realnet.template.service.DatabaseQueryService;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"@RequestMapping(\"/sureserve/template/databasequery\")" + "\r\n" +
|
||||
"public class DatabaseQueryController {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private DatabaseQueryService rn_table_service;" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private DynamicTempRepo tempRepo;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Value(\"${spring.datasource.username}\")" + "\r\n" +
|
||||
" private String userName;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Value(\"${spring.datasource.password}\")" + "\r\n" +
|
||||
" private String password;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Value(\"${spring.datasource.url}\")" + "\r\n" +
|
||||
" private String url;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"// get all databse list available" + "\r\n" +
|
||||
" @GetMapping(\"/Table_list\")" + "\r\n" +
|
||||
" @ResponseBody" + "\r\n" +
|
||||
" public List<Object> getdatabase() {" + "\r\n" +
|
||||
" List<Object> list = tempRepo.getdatabaseList();" + "\r\n" +
|
||||
" return list;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // get all table list available" + "\r\n" +
|
||||
" @GetMapping(\"/Table_list_all\")" + "\r\n" +
|
||||
" @ResponseBody" + "\r\n" +
|
||||
" public List<String> gettableList()" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"// @PathVariable String table_schema) " + "\r\n" +
|
||||
" {" + "\r\n" +
|
||||
"// List<String> list = tempRepo.getListOftables(table_schema);" + "\r\n" +
|
||||
" List<String> list = rn_table_service.getListOftable(\"sureserve\");" + "\r\n" +
|
||||
" return list;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // get all column list available" + "\r\n" +
|
||||
" @GetMapping(\"/Table_list/{table_schema}/{TABLE_NAME}\")" + "\r\n" +
|
||||
" @ResponseBody" + "\r\n" +
|
||||
" public List<String> getallcolumnlist(@PathVariable String table_schema, @PathVariable String TABLE_NAME) {" + "\r\n" +
|
||||
" List<String> list = rn_table_service.getColumnAliasList1(table_schema, TABLE_NAME);" + "\r\n" +
|
||||
" return list;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // create database" + "\r\n" +
|
||||
" @GetMapping(\"/createdatabase/{table_schema}\")" + "\r\n" +
|
||||
" @ResponseBody" + "\r\n" +
|
||||
" public List<Integer> createdatabase(@PathVariable String table_schema) {" + "\r\n" +
|
||||
" List<Integer> list = rn_table_service.createdatabase(table_schema);" + "\r\n" +
|
||||
" return list;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"}"
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
"package com.realnet.template.service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.sql.Connection;" + "\r\n" +
|
||||
"import java.sql.DriverManager;" + "\r\n" +
|
||||
"import java.sql.ResultSet;" + "\r\n" +
|
||||
"import java.sql.SQLException;" + "\r\n" +
|
||||
"import java.sql.Statement;" + "\r\n" +
|
||||
"import java.util.ArrayList;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Value;" + "\r\n" +
|
||||
"import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PathVariable;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
"public class DatabaseQueryService {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Value(\"${spring.datasource.username}\")" + "\r\n" +
|
||||
" private String userName;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Value(\"${spring.datasource.password}\")" + "\r\n" +
|
||||
" private String password;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Value(\"${spring.datasource.url}\")" + "\r\n" +
|
||||
" private String url;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // get all column" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public List<String> getColumnAliasList1(String table_schema, String tABLE_NAME) {" + "\r\n" +
|
||||
" String query = \"SELECT column_name FROM information_schema.columns WHERE TABLE_SCHEMA='\" + table_schema" + "\r\n" +
|
||||
" + \"' and table_name = '\" + tABLE_NAME + \"' \";" + "\r\n" +
|
||||
" List<String> list = new ArrayList<String>();" + "\r\n" +
|
||||
" try (Connection con = DriverManager.getConnection(url, userName, password);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Statement stmt = con.createStatement()) {" + "\r\n" +
|
||||
" ResultSet rs = stmt.executeQuery(query);" + "\r\n" +
|
||||
" while (rs.next()) {" + "\r\n" +
|
||||
" String coffeeName = rs.getString(\"column_name\");" + "\r\n" +
|
||||
" list.add(coffeeName);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" } catch (SQLException e) {" + "\r\n" +
|
||||
" e.printStackTrace();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" return list;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // get all table list from databse" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public List<String> getListOftable(String table_schema) {" + "\r\n" +
|
||||
" String query = \"SELECT table_name FROM information_schema.tables WHERE table_schema='\" + table_schema + \"' \";" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" List<String> list = new ArrayList<String>();" + "\r\n" +
|
||||
" try (Connection con = DriverManager.getConnection(url, userName, password);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Statement stmt = con.createStatement()) {" + "\r\n" +
|
||||
" ResultSet rs = stmt.executeQuery(query);" + "\r\n" +
|
||||
" while (rs.next()) {" + "\r\n" +
|
||||
" String coffeeName = rs.getString(\"table_name\");" + "\r\n" +
|
||||
" list.add(coffeeName);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" } catch (SQLException e) {" + "\r\n" +
|
||||
" e.printStackTrace();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" return list;" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public List<Integer> createdatabase(String table_schema){" + "\r\n" +
|
||||
" String query = \"CREATE SCHEMA \" + table_schema + \";\";" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" List<Integer> list = new ArrayList<Integer>();" + "\r\n" +
|
||||
" try (Connection con = DriverManager.getConnection(url, userName, password); // conn.str" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Statement stmt = con.createStatement()) {" + "\r\n" +
|
||||
" int rs = stmt.executeUpdate(query);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" list.add(rs);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" } catch (SQLException e) {" + "\r\n" +
|
||||
" e.printStackTrace();" + "\r\n" +
|
||||
" } finally {" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" return list;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"}"
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"package com.realnet.template.repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.Query;" + "\r\n" +
|
||||
"import org.springframework.data.repository.query.Param;" + "\r\n" +
|
||||
"import org.springframework.stereotype.Repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.template.entity.Dynamic_template;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Repository" + "\r\n" +
|
||||
"public interface DynamicTempRepo extends JpaRepository<Dynamic_template, Long>{" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Query(value= \"select schema_name from information_schema.schemata\",nativeQuery = true)" + "\r\n" +
|
||||
" List<Object> getdatabaseList();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Query(value= \"SELECT table_name FROM information_schema.tables WHERE table_schema =?1\",nativeQuery = true)" + "\r\n" +
|
||||
" List<String> getListOftables(String table_schema);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Query(value= \"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE `TABLE_SCHEMA`=:'TABLE_SCHEMA' AND `TABLE_NAME`='TABLE_NAME';\",nativeQuery = true)" + "\r\n" +
|
||||
" List<Object> getallcolumnlist(@Param(\"TABLE_SCHEMA\") Object table_schema, @Param(\"TABLE_NAME\") Object tABLE_NAME);" + "\r\n" +
|
||||
"}"
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
"package com.realnet.template.controller;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.io.BufferedReader;" + "\r\n" +
|
||||
"import java.io.IOException;" + "\r\n" +
|
||||
"import java.io.InputStream;" + "\r\n" +
|
||||
"import java.io.InputStreamReader;" + "\r\n" +
|
||||
"import java.text.DateFormat;" + "\r\n" +
|
||||
"import java.text.SimpleDateFormat;" + "\r\n" +
|
||||
"import java.util.ArrayList;" + "\r\n" +
|
||||
"import java.util.Calendar;" + "\r\n" +
|
||||
"import java.util.HashMap;" + "\r\n" +
|
||||
"import java.util.Iterator;" + "\r\n" +
|
||||
"import java.util.List;" + "\r\n" +
|
||||
"import java.util.Map;" + "\r\n" +
|
||||
"import java.util.Set;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.apache.poi.ss.usermodel.DataFormatter;" + "\r\n" +
|
||||
"import org.apache.poi.ss.usermodel.Row;" + "\r\n" +
|
||||
"import org.apache.poi.ss.usermodel.Sheet;" + "\r\n" +
|
||||
"import org.apache.poi.ss.usermodel.Workbook;" + "\r\n" +
|
||||
"import org.apache.poi.ss.usermodel.WorkbookFactory;" + "\r\n" +
|
||||
"import org.json.simple.JSONObject;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.http.HttpStatus;" + "\r\n" +
|
||||
"import org.springframework.http.ResponseEntity;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.DeleteMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.GetMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PathVariable;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PostMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.PutMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestParam;" + "\r\n" +
|
||||
"import org.springframework.web.bind.annotation.RestController;" + "\r\n" +
|
||||
"import org.springframework.web.multipart.MultipartFile;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.fasterxml.jackson.core.JsonProcessingException;" + "\r\n" +
|
||||
"import com.fasterxml.jackson.databind.JsonMappingException;" + "\r\n" +
|
||||
"import com.fasterxml.jackson.databind.ObjectMapper;" + "\r\n" +
|
||||
"import com.google.gson.JsonArray;" + "\r\n" +
|
||||
"import com.google.gson.JsonElement;" + "\r\n" +
|
||||
"import com.google.gson.JsonObject;" + "\r\n" +
|
||||
"import com.google.gson.JsonParser;" + "\r\n" +
|
||||
"import com.realnet.Notification.Notification.Entity.NotEntity;" + "\r\n" +
|
||||
"import com.realnet.fileupload.helper.Fileuploadhelper;" + "\r\n" +
|
||||
"import com.realnet.incident.entity.IncidentEntity;" + "\r\n" +
|
||||
"import com.realnet.template.entity.Dynamic_template;" + "\r\n" +
|
||||
"import com.realnet.template.repository.DynamicTempRepo;" + "\r\n" +
|
||||
"import com.realnet.users.entity1.AppUser;" + "\r\n" +
|
||||
"import com.realnet.users.service1.AppUserServiceImpl;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@RestController" + "\r\n" +
|
||||
"@RequestMapping(\"/sureserve/template/dynamic\")" + "\r\n" +
|
||||
"public class DynamicTemplateController {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private DynamicTempRepo tempRepo;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private AppUserServiceImpl userService;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private Fileuploadhelper fileuploadhelper;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @GetMapping(\"/templatetojson\")" + "\r\n" +
|
||||
" public ResponseEntity<?> saveTemplateInJson(@RequestParam MultipartFile file) throws IOException {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" BufferedReader br;" + "\r\n" +
|
||||
" InputStream is = file.getInputStream();" + "\r\n" +
|
||||
" br = new BufferedReader(new InputStreamReader(is));" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Workbook workbook = WorkbookFactory.create(is);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"// Create a DataFormatter to format and get each cell's value as String" + "\r\n" +
|
||||
" DataFormatter dataFormatter = new DataFormatter();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Sheet sheet = workbook.getSheetAt(0);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // Getting number of columns in the Sheet" + "\r\n" +
|
||||
" int cols = sheet.getRow(0).getLastCellNum();" + "\r\n" +
|
||||
" int firstRowNum = sheet.getFirstRowNum();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" List<String> keys = new ArrayList<String>();" + "\r\n" +
|
||||
" List<JSONObject> jsonList = new ArrayList<JSONObject>();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" for (Row row : sheet) {" + "\r\n" +
|
||||
" JSONObject object = new JSONObject();" + "\r\n" +
|
||||
" if (row.getRowNum() == 0) {" + "\r\n" +
|
||||
" for (int i = 0; i < cols; i++) {" + "\r\n" +
|
||||
" String value = dataFormatter.formatCellValue(row.getCell(i));" + "\r\n" +
|
||||
" keys.add(value);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (row.getRowNum() != 0) {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" for (int i = 0; i < cols; i++) {" + "\r\n" +
|
||||
" String key = keys.get(i);" + "\r\n" +
|
||||
" String value = dataFormatter.formatCellValue(row.getCell(i));" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" object.put(key, value);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" jsonList.add(object);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" workbook.close();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return new ResponseEntity<>(jsonList, HttpStatus.BAD_REQUEST);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @GetMapping(\"/jsonkeychange\")" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" public ResponseEntity<?> changeKeysOfJson(@RequestParam String newjson, @RequestParam String body)" + "\r\n" +
|
||||
" throws IOException {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" JsonParser parser = new JsonParser();" + "\r\n" +
|
||||
" JsonElement element = parser.parse(newjson);" + "\r\n" +
|
||||
" JsonElement element2 = parser.parse(body);" + "\r\n" +
|
||||
" JsonObject object2 = element.getAsJsonObject();" + "\r\n" +
|
||||
" JsonArray array = element2.getAsJsonArray();" + "\r\n" +
|
||||
" Iterator iterator = array.iterator();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" List<Map> jsonList = new ArrayList<Map>();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Set<String> keySet = object2.keySet();" + "\r\n" +
|
||||
" Iterator<String> it = keySet.iterator();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"// String key = it.next();" + "\r\n" +
|
||||
" while (iterator.hasNext()) {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Map<String, String> map = new HashMap<String, String>();" + "\r\n" +
|
||||
" Object next = iterator.next();" + "\r\n" +
|
||||
" JsonElement parse = parser.parse(next.toString());" + "\r\n" +
|
||||
" JsonObject jsonObject = parse.getAsJsonObject();" + "\r\n" +
|
||||
" for (String k : keySet) {" + "\r\n" +
|
||||
" String next2 = object2.get(k).getAsString();" + "\r\n" +
|
||||
" String value2 = jsonObject.get(k).getAsString();" + "\r\n" +
|
||||
" map.put(next2, value2);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" jsonList.add(map);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return new ResponseEntity<>(jsonList, HttpStatus.BAD_REQUEST);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // create data with file upload" + "\r\n" +
|
||||
" @PostMapping(\"/dynamic_temp\")" + "\r\n" +
|
||||
" public ResponseEntity<?> addIssues(@RequestParam String data, @RequestParam MultipartFile file)" + "\r\n" +
|
||||
" throws JsonMappingException, JsonProcessingException {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" AppUser user = userService.getLoggedInUser();" + "\r\n" +
|
||||
" String userId = user.getUsername();" + "\r\n" +
|
||||
" Dynamic_template dynamic_template;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" dynamic_template = new ObjectMapper().readValue(data, Dynamic_template.class);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (!file.isEmpty()) {" + "\r\n" +
|
||||
"// for (MultipartFile e : attachmentFile) {" + "\r\n" +
|
||||
" System.out.println(file.getOriginalFilename());" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" boolean f = fileuploadhelper.uploadFile(file);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (f) {" + "\r\n" +
|
||||
" System.out.println(\"file uploaded successfully\");" + "\r\n" +
|
||||
" dynamic_template.setFile_name(file.getOriginalFilename());" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" } else {" + "\r\n" +
|
||||
" dynamic_template.setFile_name(\"No file\");" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" dynamic_template.setUser_id(userId);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Dynamic_template save = tempRepo.save(dynamic_template);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (save.getId() == 0) {" + "\r\n" +
|
||||
" return new ResponseEntity<String>(\"template Not Added\", HttpStatus.BAD_REQUEST);" + "\r\n" +
|
||||
" } else {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return new ResponseEntity<>(save, HttpStatus.ACCEPTED);" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // get all" + "\r\n" +
|
||||
" @GetMapping(\"/dynamic_temp\")" + "\r\n" +
|
||||
" public ResponseEntity<?> getAll() {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return new ResponseEntity<>(tempRepo.findAll(), HttpStatus.ACCEPTED);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // get by id" + "\r\n" +
|
||||
" @GetMapping(\"/dynamic_temp/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<?> getIssueById(@PathVariable Long id) {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" return new ResponseEntity<>(tempRepo.findById(id).get(), HttpStatus.ACCEPTED);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // delete by id" + "\r\n" +
|
||||
" @DeleteMapping(\"/dynamic_temp/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<?> deleteIssue(@PathVariable Long id) {" + "\r\n" +
|
||||
" tempRepo.deleteById(id);" + "\r\n" +
|
||||
" return new ResponseEntity<String>(\"Success\", HttpStatus.ACCEPTED);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" // update by id" + "\r\n" +
|
||||
" @PutMapping(\"/dynamic_temp/{id}\")" + "\r\n" +
|
||||
" public ResponseEntity<?> updateIssue(@RequestParam String data, @PathVariable Long id," + "\r\n" +
|
||||
" @RequestParam MultipartFile file) throws Exception {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Dynamic_template dynamic_template;" + "\r\n" +
|
||||
" dynamic_template = new ObjectMapper().readValue(data, Dynamic_template.class);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Dynamic_template template = tempRepo.findById(id).get();" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (!file.isEmpty()) {" + "\r\n" +
|
||||
" System.out.println(file.getOriginalFilename());" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" boolean f = fileuploadhelper.uploadFile(file);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" if (f) {" + "\r\n" +
|
||||
" System.out.println(\"file uploaded successfully\");" + "\r\n" +
|
||||
" template.setFile_name(file.getOriginalFilename());" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" } else {" + "\r\n" +
|
||||
" template.setFile_name(\"No file\");" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" template.setEntity_name(dynamic_template.getEntity_name());" + "\r\n" +
|
||||
" template.setUser_id(dynamic_template.getUser_id());" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" Dynamic_template save = tempRepo.save(template);" + "\r\n" +
|
||||
" return new ResponseEntity<>(save, HttpStatus.ACCEPTED);" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"}"
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"package com.realnet.template.entity;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import javax.persistence.Entity;" + "\r\n" +
|
||||
"import javax.persistence.GeneratedValue;" + "\r\n" +
|
||||
"import javax.persistence.GenerationType;" + "\r\n" +
|
||||
"import javax.persistence.Id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import lombok.AllArgsConstructor;" + "\r\n" +
|
||||
"import lombok.Data;" + "\r\n" +
|
||||
"import lombok.NoArgsConstructor;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Data" + "\r\n" +
|
||||
"@Entity" + "\r\n" +
|
||||
"@AllArgsConstructor" + "\r\n" +
|
||||
"@NoArgsConstructor" + "\r\n" +
|
||||
"public class Dynamic_template {" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" @Id" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" private String user_id;" + "\r\n" +
|
||||
" private String file_name;" + "\r\n" +
|
||||
" private String entity_name;" + "\r\n" +
|
||||
"}"
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
"//package com.realnet.excel.service;" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"//import java.io.IOException;" + "\r\n" +
|
||||
"//import java.util.ArrayList;" + "\r\n" +
|
||||
"//import java.util.List;" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"//import org.apache.poi.EncryptedDocumentException;" + "\r\n" +
|
||||
"//import org.apache.poi.ss.usermodel.Cell;" + "\r\n" +
|
||||
"//import org.apache.poi.ss.usermodel.DataFormatter;" + "\r\n" +
|
||||
"//import org.apache.poi.ss.usermodel.Row;" + "\r\n" +
|
||||
"//import org.apache.poi.ss.usermodel.Sheet;" + "\r\n" +
|
||||
"//import org.apache.poi.ss.usermodel.Workbook;" + "\r\n" +
|
||||
"//import org.apache.poi.ss.usermodel.WorkbookFactory;" + "\r\n" +
|
||||
"//import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"//import com.realnet.excel.entity.ExcelFileUpload;" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"//@Service" + "\r\n" +
|
||||
"//public class ExcelDataService {" + "\r\n" +
|
||||
"// " + "\r\n" +
|
||||
"// Workbook workbook;" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// public List<ExcelFileUpload> getExcelDataAsList() {" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// List<String> list = new ArrayList<String>();" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // Create a DataFormatter to format and get each cell's value as String" + "\r\n" +
|
||||
"// DataFormatter dataFormatter = new DataFormatter();" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // Create the Workbook" + "\r\n" +
|
||||
"//// try {" + "\r\n" +
|
||||
"//// workbook = WorkbookFactory.create();" + "\r\n" +
|
||||
"//// } catch (EncryptedDocumentException | IOException e) {" + "\r\n" +
|
||||
"//// e.printStackTrace();" + "\r\n" +
|
||||
"//// }" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // Retrieving the number of sheets in the Workbook" + "\r\n" +
|
||||
"// System.out.println(\"-------Workbook has '\" + workbook.getNumberOfSheets() + \"' Sheets-----\");" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // Getting the Sheet at index zero" + "\r\n" +
|
||||
"// Sheet sheet = workbook.getSheetAt(0);" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // Getting number of columns in the Sheet" + "\r\n" +
|
||||
"// int noOfColumns = sheet.getRow(0).getLastCellNum();" + "\r\n" +
|
||||
"// System.out.println(\"-------Sheet has '\"+noOfColumns+\"' columns------\");" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // Using for-each loop to iterate over the rows and columns" + "\r\n" +
|
||||
"// for (Row row : sheet) {" + "\r\n" +
|
||||
"// for (Cell cell : row) {" + "\r\n" +
|
||||
"// String cellValue = dataFormatter.formatCellValue(cell);" + "\r\n" +
|
||||
"// list.add(cellValue);" + "\r\n" +
|
||||
"// }" + "\r\n" +
|
||||
"// }" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // filling excel data and creating list as List<Invoice>" + "\r\n" +
|
||||
"// List<ExcelFileUpload> invList = createList(list, noOfColumns);" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// // Closing the workbook" + "\r\n" +
|
||||
"// try {" + "\r\n" +
|
||||
"// workbook.close();" + "\r\n" +
|
||||
"// } catch (IOException e) {" + "\r\n" +
|
||||
"// // TODO Auto-generated catch block" + "\r\n" +
|
||||
"// e.printStackTrace();" + "\r\n" +
|
||||
"// }" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// return invList;" + "\r\n" +
|
||||
"// }" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// private List<ExcelFileUpload> createList(List<String> excelData, int noOfColumns) {" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// ArrayList<ExcelFileUpload> invList = new ArrayList<ExcelFileUpload>();" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// int i = noOfColumns;" + "\r\n" +
|
||||
"// do {" + "\r\n" +
|
||||
"// ExcelFileUpload inv = new ExcelFileUpload();" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"//// inv.setName(excelData.get(i));" + "\r\n" +
|
||||
"//// inv.setAmount(Double.valueOf(excelData.get(i + 1)));" + "\r\n" +
|
||||
"//// inv.setNumber(excelData.get(i + 2));" + "\r\n" +
|
||||
"//// inv.setReceivedDate(excelData.get(i + 3));" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// invList.add(inv);" + "\r\n" +
|
||||
"// i = i + (noOfColumns);" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"// } while (i < excelData.size());" + "\r\n" +
|
||||
"// return invList;" + "\r\n" +
|
||||
"// }" + "\r\n" +
|
||||
"//" + "\r\n" +
|
||||
"//// public int saveExcelData(List<ExcelFileUpload> invoices) {" + "\r\n" +
|
||||
"//// invoices = repo.saveAll(invoices);" + "\r\n" +
|
||||
"//// return invoices.size();" + "\r\n" +
|
||||
"//// }" + "\r\n" +
|
||||
"// " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"//}"
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
"package com.realnet.template.service;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import java.io.File;" + "\r\n" +
|
||||
"import java.nio.file.Files;" + "\r\n" +
|
||||
"import java.nio.file.Path;" + "\r\n" +
|
||||
"import java.nio.file.Paths;" + "\r\n" +
|
||||
"import java.nio.file.StandardCopyOption;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Autowired;" + "\r\n" +
|
||||
"import org.springframework.beans.factory.annotation.Value;" + "\r\n" +
|
||||
"import org.springframework.stereotype.Service;" + "\r\n" +
|
||||
"import org.springframework.util.StringUtils;" + "\r\n" +
|
||||
"import org.springframework.web.multipart.MultipartFile;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.template.entity.TemplateFileUpload;" + "\r\n" +
|
||||
"import com.realnet.template.repository.TemplatedataRepo;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Service" + "\r\n" +
|
||||
"public class FileUploadService {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" @Autowired" + "\r\n" +
|
||||
" private TemplatedataRepo repo;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" public String uploadFile(MultipartFile file,Long user_id,String file_type) {" + "\r\n" +
|
||||
" try {" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
"// String " + "\r\n" +
|
||||
" String file_name= file.getOriginalFilename();" + "\r\n" +
|
||||
" String substring = file_name.substring(0,file_name.lastIndexOf(\".\"));" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" String str = substring+System.currentTimeMillis();" + "\r\n" +
|
||||
" String location =System.getProperty(\"user.dir\")+\"/src/main/resources\";" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" String file_name2= file.getOriginalFilename();" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" File staticdir2 = new File(location+\"/incomingfile\");" + "\r\n" +
|
||||
" if(!staticdir2.exists()) {" + "\r\n" +
|
||||
" staticdir2.mkdir();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" Path copyLocation2 = Paths" + "\r\n" +
|
||||
" .get(staticdir2 + File.separator + StringUtils.cleanPath(file_name2));" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" Files.copy(file.getInputStream(), copyLocation2, StandardCopyOption.REPLACE_EXISTING); " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" File staticdir = new File(location+\"/processingfile\");" + "\r\n" +
|
||||
" if(!staticdir.exists()) {" + "\r\n" +
|
||||
" staticdir.mkdir();" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" Path copyLocation = Paths" + "\r\n" +
|
||||
" .get(staticdir + File.separator + StringUtils.cleanPath(str+\".xlsx\"));" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" Files.copy(file.getInputStream(), copyLocation, StandardCopyOption.REPLACE_EXISTING);" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" TemplateFileUpload exceldata= new TemplateFileUpload();" + "\r\n" +
|
||||
" exceldata.setFile_location(location);" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" exceldata.setFile_name(file.getOriginalFilename());" + "\r\n" +
|
||||
" exceldata.setFile_changed_name(str);" + "\r\n" +
|
||||
" exceldata.setFile_type(file_type);" + "\r\n" +
|
||||
" exceldata.setUser_id(user_id);" + "\r\n" +
|
||||
" repo.save(exceldata);" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" System.out.println(\"-----------------------saving data----------------\");" + "\r\n" +
|
||||
" return location;" + "\r\n" +
|
||||
" } catch (Exception e) {" + "\r\n" +
|
||||
" e.printStackTrace();" + "\r\n" +
|
||||
" throw new RuntimeException(\"Could not store file \" + file.getOriginalFilename()" + "\r\n" +
|
||||
" + \". Please try again!\");" + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" }" + "\r\n" +
|
||||
"}"
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
"package com.realnet.template.entity;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import javax.persistence.Entity;" + "\r\n" +
|
||||
"import javax.persistence.GeneratedValue;" + "\r\n" +
|
||||
"import javax.persistence.GenerationType;" + "\r\n" +
|
||||
"import javax.persistence.Id;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import lombok.AllArgsConstructor;" + "\r\n" +
|
||||
"import lombok.Data;" + "\r\n" +
|
||||
"import lombok.NoArgsConstructor;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"@Data" + "\r\n" +
|
||||
"@Entity" + "\r\n" +
|
||||
"@AllArgsConstructor" + "\r\n" +
|
||||
"@NoArgsConstructor" + "\r\n" +
|
||||
"public class TemplateFileUpload {" + "\r\n" +
|
||||
" @Id" + "\r\n" +
|
||||
" @GeneratedValue(strategy = GenerationType.IDENTITY)" + "\r\n" +
|
||||
" private Long id;" + "\r\n" +
|
||||
" " + "\r\n" +
|
||||
" private Long user_id;" + "\r\n" +
|
||||
" private String file_name;" + "\r\n" +
|
||||
" private String file_changed_name;" + "\r\n" +
|
||||
" private String file_location;" + "\r\n" +
|
||||
" private String file_type;" + "\r\n" +
|
||||
" private Integer status;" + "\r\n" +
|
||||
"}"
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
"package com.realnet.template.repository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import org.springframework.data.jpa.repository.JpaRepository;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"import com.realnet.template.entity.TemplateFileUpload;" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"public interface TemplatedataRepo extends JpaRepository<TemplateFileUpload, Long>{" + "\r\n" +
|
||||
"" + "\r\n" +
|
||||
"}"
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user