build_app
This commit is contained in:
parent
4d871baff1
commit
216475c48b
@ -69,6 +69,27 @@ public class BuilderService {
|
||||
executeDump(true);
|
||||
|
||||
// ADD OTHER SERVICE
|
||||
addCustomMenu( "Products","Products", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Rides","Rides", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Custom_setting","Custom_setting", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Vehicle_add_on","Vehicle_add_on", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Car_category","Car_category", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Office","Office", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Feature","Feature", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Custom_setting","Custom_setting", "Transcations");
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Car_category_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Car_category_ListFilter1Service ;
|
||||
@RequestMapping(value = "/Car_category_ListFilter1")
|
||||
@RestController
|
||||
public class Car_category_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Car_category_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Car_category_ListFilter1")
|
||||
public List<Car_category_ListFilter1> getlist() {
|
||||
List<Car_category_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Car_category_ListFilter11")
|
||||
public List<Car_category_ListFilter1> getlistwithparam( ) {
|
||||
List<Car_category_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Custom_feature_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Custom_feature_ListFilter1Service ;
|
||||
@RequestMapping(value = "/Custom_feature_ListFilter1")
|
||||
@RestController
|
||||
public class Custom_feature_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Custom_feature_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Custom_feature_ListFilter1")
|
||||
public List<Custom_feature_ListFilter1> getlist() {
|
||||
List<Custom_feature_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Custom_feature_ListFilter11")
|
||||
public List<Custom_feature_ListFilter1> getlistwithparam( ) {
|
||||
List<Custom_feature_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Custom_setting_ListFilter1Service ;
|
||||
@RequestMapping(value = "/Custom_setting_ListFilter1")
|
||||
@RestController
|
||||
public class Custom_setting_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Custom_setting_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Custom_setting_ListFilter1")
|
||||
public List<Custom_setting_ListFilter1> getlist() {
|
||||
List<Custom_setting_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Custom_setting_ListFilter11")
|
||||
public List<Custom_setting_ListFilter1> getlistwithparam( ) {
|
||||
List<Custom_setting_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Feature_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Feature_ListFilter1Service ;
|
||||
@RequestMapping(value = "/Feature_ListFilter1")
|
||||
@RestController
|
||||
public class Feature_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Feature_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Feature_ListFilter1")
|
||||
public List<Feature_ListFilter1> getlist() {
|
||||
List<Feature_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Feature_ListFilter11")
|
||||
public List<Feature_ListFilter1> getlistwithparam( ) {
|
||||
List<Feature_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Office_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Office_ListFilter1Service ;
|
||||
@RequestMapping(value = "/Office_ListFilter1")
|
||||
@RestController
|
||||
public class Office_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Office_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Office_ListFilter1")
|
||||
public List<Office_ListFilter1> getlist() {
|
||||
List<Office_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Office_ListFilter11")
|
||||
public List<Office_ListFilter1> getlistwithparam( ) {
|
||||
List<Office_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Products;
|
||||
import com.realnet.taxi_rental.Services.ProductsService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Products")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class ProductsController {
|
||||
@Autowired
|
||||
private ProductsService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Products")
|
||||
public Products Savedata(@RequestBody Products data) {
|
||||
Products save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Products/{id}")
|
||||
public Products update(@RequestBody Products data,@PathVariable Integer id ) {
|
||||
Products update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Products/getall/page")
|
||||
public Page<Products> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Products> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Products")
|
||||
public List<Products> getdetails() {
|
||||
List<Products> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Products")
|
||||
public List<Products> getallwioutsec() {
|
||||
List<Products> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Products/{id}")
|
||||
public Products getdetailsbyId(@PathVariable Integer id ) {
|
||||
Products get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Products/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Products_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Products_ListFilter1Service ;
|
||||
@RequestMapping(value = "/Products_ListFilter1")
|
||||
@RestController
|
||||
public class Products_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Products_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Products_ListFilter1")
|
||||
public List<Products_ListFilter1> getlist() {
|
||||
List<Products_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Products_ListFilter11")
|
||||
public List<Products_ListFilter1> getlistwithparam( ) {
|
||||
List<Products_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Rides;
|
||||
import com.realnet.taxi_rental.Services.RidesService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Rides")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class RidesController {
|
||||
@Autowired
|
||||
private RidesService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Rides")
|
||||
public Rides Savedata(@RequestBody Rides data) {
|
||||
Rides save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Rides/{id}")
|
||||
public Rides update(@RequestBody Rides data,@PathVariable Integer id ) {
|
||||
Rides update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Rides/getall/page")
|
||||
public Page<Rides> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Rides> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Rides")
|
||||
public List<Rides> getdetails() {
|
||||
List<Rides> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Rides")
|
||||
public List<Rides> getallwioutsec() {
|
||||
List<Rides> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Rides/{id}")
|
||||
public Rides getdetailsbyId(@PathVariable Integer id ) {
|
||||
Rides get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Rides/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Vehicle_add_on_ListFilter1Service ;
|
||||
@RequestMapping(value = "/Vehicle_add_on_ListFilter1")
|
||||
@RestController
|
||||
public class Vehicle_add_on_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Vehicle_add_on_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Vehicle_add_on_ListFilter1")
|
||||
public List<Vehicle_add_on_ListFilter1> getlist() {
|
||||
List<Vehicle_add_on_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Vehicle_add_on_ListFilter11")
|
||||
public List<Vehicle_add_on_ListFilter1> getlistwithparam( ) {
|
||||
List<Vehicle_add_on_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Car_category_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Car_category_ListFilter1Service ;
|
||||
@RequestMapping(value = "/token/Car_category_ListFilter1")
|
||||
@RestController
|
||||
public class tokenFree_Car_category_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Car_category_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Car_category_ListFilter1")
|
||||
public List<Car_category_ListFilter1> getlist() {
|
||||
List<Car_category_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Car_category_ListFilter11")
|
||||
public List<Car_category_ListFilter1> getlistwithparam( ) {
|
||||
List<Car_category_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Custom_feature_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Custom_feature_ListFilter1Service ;
|
||||
@RequestMapping(value = "/token/Custom_feature_ListFilter1")
|
||||
@RestController
|
||||
public class tokenFree_Custom_feature_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Custom_feature_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Custom_feature_ListFilter1")
|
||||
public List<Custom_feature_ListFilter1> getlist() {
|
||||
List<Custom_feature_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Custom_feature_ListFilter11")
|
||||
public List<Custom_feature_ListFilter1> getlistwithparam( ) {
|
||||
List<Custom_feature_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Custom_setting_ListFilter1Service ;
|
||||
@RequestMapping(value = "/token/Custom_setting_ListFilter1")
|
||||
@RestController
|
||||
public class tokenFree_Custom_setting_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Custom_setting_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Custom_setting_ListFilter1")
|
||||
public List<Custom_setting_ListFilter1> getlist() {
|
||||
List<Custom_setting_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Custom_setting_ListFilter11")
|
||||
public List<Custom_setting_ListFilter1> getlistwithparam( ) {
|
||||
List<Custom_setting_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Feature_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Feature_ListFilter1Service ;
|
||||
@RequestMapping(value = "/token/Feature_ListFilter1")
|
||||
@RestController
|
||||
public class tokenFree_Feature_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Feature_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Feature_ListFilter1")
|
||||
public List<Feature_ListFilter1> getlist() {
|
||||
List<Feature_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Feature_ListFilter11")
|
||||
public List<Feature_ListFilter1> getlistwithparam( ) {
|
||||
List<Feature_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Office_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Office_ListFilter1Service ;
|
||||
@RequestMapping(value = "/token/Office_ListFilter1")
|
||||
@RestController
|
||||
public class tokenFree_Office_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Office_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Office_ListFilter1")
|
||||
public List<Office_ListFilter1> getlist() {
|
||||
List<Office_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Office_ListFilter11")
|
||||
public List<Office_ListFilter1> getlistwithparam( ) {
|
||||
List<Office_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Products;
|
||||
import com.realnet.taxi_rental.Services.ProductsService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/token/Products")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class tokenFree_ProductsController {
|
||||
@Autowired
|
||||
private ProductsService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Products")
|
||||
public Products Savedata(@RequestBody Products data) {
|
||||
Products save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Products/{id}")
|
||||
public Products update(@RequestBody Products data,@PathVariable Integer id ) {
|
||||
Products update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Products/getall/page")
|
||||
public Page<Products> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Products> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Products")
|
||||
public List<Products> getdetails() {
|
||||
List<Products> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Products")
|
||||
public List<Products> getallwioutsec() {
|
||||
List<Products> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Products/{id}")
|
||||
public Products getdetailsbyId(@PathVariable Integer id ) {
|
||||
Products get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Products/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Products_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Products_ListFilter1Service ;
|
||||
@RequestMapping(value = "/token/Products_ListFilter1")
|
||||
@RestController
|
||||
public class tokenFree_Products_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Products_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Products_ListFilter1")
|
||||
public List<Products_ListFilter1> getlist() {
|
||||
List<Products_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Products_ListFilter11")
|
||||
public List<Products_ListFilter1> getlistwithparam( ) {
|
||||
List<Products_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.realnet.config.EmailService;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.*;
|
||||
import com.realnet.fnd.response.EntityResponse;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Rides;
|
||||
import com.realnet.taxi_rental.Services.RidesService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/token/Rides")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class tokenFree_RidesController {
|
||||
@Autowired
|
||||
private RidesService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Rides")
|
||||
public Rides Savedata(@RequestBody Rides data) {
|
||||
Rides save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Rides/{id}")
|
||||
public Rides update(@RequestBody Rides data,@PathVariable Integer id ) {
|
||||
Rides update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Rides/getall/page")
|
||||
public Page<Rides> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Rides> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Rides")
|
||||
public List<Rides> getdetails() {
|
||||
List<Rides> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Rides")
|
||||
public List<Rides> getallwioutsec() {
|
||||
List<Rides> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Rides/{id}")
|
||||
public Rides getdetailsbyId(@PathVariable Integer id ) {
|
||||
Rides get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Rides/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.realnet.taxi_rental.Controllers;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on_ListFilter1;
|
||||
import com.realnet.taxi_rental.Services.Vehicle_add_on_ListFilter1Service ;
|
||||
@RequestMapping(value = "/token/Vehicle_add_on_ListFilter1")
|
||||
@RestController
|
||||
public class tokenFree_Vehicle_add_on_ListFilter1Controller {
|
||||
|
||||
@Autowired
|
||||
private Vehicle_add_on_ListFilter1Service Service;
|
||||
|
||||
@GetMapping("/Vehicle_add_on_ListFilter1")
|
||||
public List<Vehicle_add_on_ListFilter1> getlist() {
|
||||
List<Vehicle_add_on_ListFilter1> get = Service.getlistbuilder();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Vehicle_add_on_ListFilter11")
|
||||
public List<Vehicle_add_on_ListFilter1> getlistwithparam( ) {
|
||||
List<Vehicle_add_on_ListFilter1> get = Service.getlistbuilderparam( );
|
||||
return get;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class Car_category_ListFilter1 {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class Custom_feature_ListFilter1 {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class Custom_setting_ListFilter1 {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String yound_driver_surcharge;
|
||||
private String free_km;
|
||||
private String extra_km_charge;
|
||||
private String gst_rate;
|
||||
private String pst_rate;
|
||||
private String age_threshold;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class Feature_ListFilter1 {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class Office_ListFilter1 {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Products extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String description;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
private String category;
|
||||
private String categoryidentifier;
|
||||
|
||||
private String product_imagesname;
|
||||
private String product_imagespath ;
|
||||
|
||||
private String features;
|
||||
private String featuresidentifier;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class Products_ListFilter1 {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
private String category;
|
||||
private String features;
|
||||
private String description;
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Rides extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String description;
|
||||
|
||||
private Boolean active;
|
||||
|
||||
private String pick_up;
|
||||
private String pick_upidentifier;
|
||||
|
||||
private Boolean return_to_same_location;
|
||||
|
||||
private String return_address;
|
||||
private String return_addressidentifier;
|
||||
|
||||
private String product;
|
||||
private String productidentifier;
|
||||
|
||||
private String vehicle_add_on;
|
||||
|
||||
private Boolean iscompleted;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.realnet.taxi_rental.Entity;
|
||||
import lombok.*;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class Vehicle_add_on_ListFilter1 {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String price_per_day;
|
||||
private String price_per_trip;
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.realnet.taxi_rental.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Products;
|
||||
|
||||
@Repository
|
||||
public interface ProductsRepository extends JpaRepository<Products, Integer> {
|
||||
|
||||
@Query(value = "select * from products where created_by=?1", nativeQuery = true)
|
||||
List<Products> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from products where created_by=?1", nativeQuery = true)
|
||||
Page<Products> findAll( Long creayedBy,Pageable page);
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.realnet.taxi_rental.Repository;
|
||||
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Rides;
|
||||
|
||||
@Repository
|
||||
public interface RidesRepository extends JpaRepository<Rides, Integer> {
|
||||
|
||||
@Query(value = "select * from rides where created_by=?1", nativeQuery = true)
|
||||
List<Rides> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from rides where created_by=?1", nativeQuery = true)
|
||||
Page<Rides> findAll( Long creayedBy,Pageable page);
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import java.util.*;
|
||||
import com.realnet.taxi_rental.Repository.Car_categoryRepository;
|
||||
import com.realnet.taxi_rental.Entity.Car_category;
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Car_category_ListFilter1;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Car_category_ListFilter1Service {
|
||||
@Autowired
|
||||
private Car_categoryRepository Repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Car_category_ListFilter1> getlistbuilder() {
|
||||
List<Car_category> list= Repository.findAll();
|
||||
ArrayList<Car_category_ListFilter1> l = new ArrayList<>();
|
||||
for (Car_category data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Car_category_ListFilter1 dummy = new Car_category_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
|
||||
|
||||
|
||||
public List<Car_category_ListFilter1> getlistbuilderparam( ) {
|
||||
List<Car_category> list= Repository.findAll();
|
||||
ArrayList<Car_category_ListFilter1> l = new ArrayList<>();
|
||||
for (Car_category data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Car_category_ListFilter1 dummy = new Car_category_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import java.util.*;
|
||||
import com.realnet.taxi_rental.Repository.Custom_featureRepository;
|
||||
import com.realnet.taxi_rental.Entity.Custom_feature;
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Custom_feature_ListFilter1;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Custom_feature_ListFilter1Service {
|
||||
@Autowired
|
||||
private Custom_featureRepository Repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Custom_feature_ListFilter1> getlistbuilder() {
|
||||
List<Custom_feature> list= Repository.findAll();
|
||||
ArrayList<Custom_feature_ListFilter1> l = new ArrayList<>();
|
||||
for (Custom_feature data : list) {
|
||||
{
|
||||
Custom_feature_ListFilter1 dummy = new Custom_feature_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}
|
||||
}
|
||||
return l;}
|
||||
|
||||
|
||||
|
||||
public List<Custom_feature_ListFilter1> getlistbuilderparam( ) {
|
||||
List<Custom_feature> list= Repository.findAll();
|
||||
ArrayList<Custom_feature_ListFilter1> l = new ArrayList<>();
|
||||
for (Custom_feature data : list) {
|
||||
{
|
||||
Custom_feature_ListFilter1 dummy = new Custom_feature_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}
|
||||
}
|
||||
return l;}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import java.util.*;
|
||||
import com.realnet.taxi_rental.Repository.Custom_settingRepository;
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting;
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Custom_setting_ListFilter1;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Custom_setting_ListFilter1Service {
|
||||
@Autowired
|
||||
private Custom_settingRepository Repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Custom_setting_ListFilter1> getlistbuilder() {
|
||||
List<Custom_setting> list= Repository.findAll();
|
||||
ArrayList<Custom_setting_ListFilter1> l = new ArrayList<>();
|
||||
for (Custom_setting data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
dummy.setYound_driver_surcharge(data.getYound_driver_surcharge());
|
||||
dummy.setFree_km(data.getFree_km());
|
||||
dummy.setExtra_km_charge(data.getExtra_km_charge());
|
||||
dummy.setGst_rate(data.getGst_rate());
|
||||
dummy.setPst_rate(data.getPst_rate());
|
||||
dummy.setAge_threshold(data.getAge_threshold());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
|
||||
|
||||
|
||||
public List<Custom_setting_ListFilter1> getlistbuilderparam( ) {
|
||||
List<Custom_setting> list= Repository.findAll();
|
||||
ArrayList<Custom_setting_ListFilter1> l = new ArrayList<>();
|
||||
for (Custom_setting data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
dummy.setYound_driver_surcharge(data.getYound_driver_surcharge());
|
||||
dummy.setFree_km(data.getFree_km());
|
||||
dummy.setExtra_km_charge(data.getExtra_km_charge());
|
||||
dummy.setGst_rate(data.getGst_rate());
|
||||
dummy.setPst_rate(data.getPst_rate());
|
||||
dummy.setAge_threshold(data.getAge_threshold());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import java.util.*;
|
||||
import com.realnet.taxi_rental.Repository.FeatureRepository;
|
||||
import com.realnet.taxi_rental.Entity.Feature;
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Feature_ListFilter1;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Feature_ListFilter1Service {
|
||||
@Autowired
|
||||
private FeatureRepository Repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Feature_ListFilter1> getlistbuilder() {
|
||||
List<Feature> list= Repository.findAll();
|
||||
ArrayList<Feature_ListFilter1> l = new ArrayList<>();
|
||||
for (Feature data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Feature_ListFilter1 dummy = new Feature_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
|
||||
|
||||
|
||||
public List<Feature_ListFilter1> getlistbuilderparam( ) {
|
||||
List<Feature> list= Repository.findAll();
|
||||
ArrayList<Feature_ListFilter1> l = new ArrayList<>();
|
||||
for (Feature data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Feature_ListFilter1 dummy = new Feature_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import java.util.*;
|
||||
import com.realnet.taxi_rental.Repository.OfficeRepository;
|
||||
import com.realnet.taxi_rental.Entity.Office;
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Office_ListFilter1;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Office_ListFilter1Service {
|
||||
@Autowired
|
||||
private OfficeRepository Repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Office_ListFilter1> getlistbuilder() {
|
||||
List<Office> list= Repository.findAll();
|
||||
ArrayList<Office_ListFilter1> l = new ArrayList<>();
|
||||
for (Office data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Office_ListFilter1 dummy = new Office_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
|
||||
|
||||
|
||||
public List<Office_ListFilter1> getlistbuilderparam( ) {
|
||||
List<Office> list= Repository.findAll();
|
||||
ArrayList<Office_ListFilter1> l = new ArrayList<>();
|
||||
for (Office data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Office_ListFilter1 dummy = new Office_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import com.realnet.taxi_rental.Repository.ProductsRepository;
|
||||
import com.realnet.taxi_rental.Entity.Products
|
||||
;import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import com.realnet.realm.Entity.Realm;
|
||||
import com.realnet.realm.Services.RealmService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.*;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Car_category;
|
||||
import com.realnet.taxi_rental.Services.Car_categoryService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Feature;
|
||||
import com.realnet.taxi_rental.Services.FeatureService;
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ProductsService {
|
||||
@Autowired
|
||||
private ProductsRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private Car_categoryService categoryserv;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private FeatureService featuresserv;
|
||||
|
||||
public Products Savedata(Products data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (data.getCategory() != null) {
|
||||
try {
|
||||
int categoryId = Integer.valueOf(data.getCategory());
|
||||
Car_category get = categoryserv.getdetailsbyId(categoryId);
|
||||
if (get != null) {
|
||||
|
||||
data.setCategoryidentifier(get.getName());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println(" categoryId is not integer..");
|
||||
// Invalid integer string — ignore or log
|
||||
data.setCategoryidentifier(data.getCategory());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (data.getFeatures() != null) {
|
||||
try {
|
||||
int featuresId = Integer.valueOf(data.getFeatures());
|
||||
Feature get = featuresserv.getdetailsbyId(featuresId);
|
||||
if (get != null) {
|
||||
|
||||
data.setFeaturesidentifier(get.getName());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println(" featuresId is not integer..");
|
||||
// Invalid integer string — ignore or log
|
||||
data.setFeaturesidentifier(data.getFeatures());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Products save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Products> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll( getUser().getUserId(),page);
|
||||
}
|
||||
public List<Products> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Products> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Products getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Products update(Products data,Integer id) {
|
||||
Products old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setDescription(data.getDescription());
|
||||
|
||||
old.setActive (data.getActive());
|
||||
|
||||
old.setCategory(data.getCategory());
|
||||
|
||||
|
||||
|
||||
old.setFeatures(data.getFeatures());
|
||||
|
||||
final Products test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import java.util.*;
|
||||
import com.realnet.taxi_rental.Repository.ProductsRepository;
|
||||
import com.realnet.taxi_rental.Entity.Products;
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Products_ListFilter1;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Products_ListFilter1Service {
|
||||
@Autowired
|
||||
private ProductsRepository Repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Products_ListFilter1> getlistbuilder() {
|
||||
List<Products> list= Repository.findAll();
|
||||
ArrayList<Products_ListFilter1> l = new ArrayList<>();
|
||||
for (Products data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Products_ListFilter1 dummy = new Products_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setCategory(data.getCategory());
|
||||
dummy.setFeatures(data.getFeatures());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
|
||||
|
||||
|
||||
public List<Products_ListFilter1> getlistbuilderparam( ) {
|
||||
List<Products> list= Repository.findAll();
|
||||
ArrayList<Products_ListFilter1> l = new ArrayList<>();
|
||||
for (Products data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Products_ListFilter1 dummy = new Products_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setCategory(data.getCategory());
|
||||
dummy.setFeatures(data.getFeatures());
|
||||
dummy.setDescription(data.getDescription());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
}
|
||||
@ -0,0 +1,222 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import com.realnet.taxi_rental.Repository.RidesRepository;
|
||||
import com.realnet.taxi_rental.Entity.Rides
|
||||
;import java.util.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.realnet.SequenceGenerator.Service.SequenceService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import com.realnet.realm.Entity.Realm;
|
||||
import com.realnet.realm.Services.RealmService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.*;
|
||||
import com.realnet.users.service1.AppUserServiceImpl;
|
||||
import com.realnet.users.entity1.AppUser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Office;
|
||||
import com.realnet.taxi_rental.Services.OfficeService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Office;
|
||||
import com.realnet.taxi_rental.Services.OfficeService;
|
||||
|
||||
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Products;
|
||||
import com.realnet.taxi_rental.Services.ProductsService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RidesService {
|
||||
@Autowired
|
||||
private RidesRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private OfficeService pick_upserv;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private OfficeService return_addressserv;
|
||||
|
||||
@Autowired
|
||||
private ProductsService productserv;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Rides Savedata(Rides data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (data.getPick_up() != null) {
|
||||
try {
|
||||
int pick_upId = Integer.valueOf(data.getPick_up());
|
||||
Office get = pick_upserv.getdetailsbyId(pick_upId);
|
||||
if (get != null) {
|
||||
|
||||
data.setPick_upidentifier(get.getName());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println(" pick_upId is not integer..");
|
||||
// Invalid integer string — ignore or log
|
||||
data.setPick_upidentifier(data.getPick_up());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (data.getReturn_address() != null) {
|
||||
try {
|
||||
int return_addressId = Integer.valueOf(data.getReturn_address());
|
||||
Office get = return_addressserv.getdetailsbyId(return_addressId);
|
||||
if (get != null) {
|
||||
|
||||
data.setReturn_addressidentifier(get.getName());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println(" return_addressId is not integer..");
|
||||
// Invalid integer string — ignore or log
|
||||
data.setReturn_addressidentifier(data.getReturn_address());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (data.getProduct() != null) {
|
||||
try {
|
||||
int productId = Integer.valueOf(data.getProduct());
|
||||
Products get = productserv.getdetailsbyId(productId);
|
||||
if (get != null) {
|
||||
|
||||
data.setProductidentifier(get.getName());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println(" productId is not integer..");
|
||||
// Invalid integer string — ignore or log
|
||||
data.setProductidentifier(data.getProduct());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Rides save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Rides> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll( getUser().getUserId(),page);
|
||||
}
|
||||
public List<Rides> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Rides> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Rides getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Rides update(Rides data,Integer id) {
|
||||
Rides old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setDescription(data.getDescription());
|
||||
|
||||
old.setActive (data.getActive());
|
||||
|
||||
old.setPick_up(data.getPick_up());
|
||||
|
||||
old.setReturn_to_same_location (data.getReturn_to_same_location());
|
||||
|
||||
old.setReturn_address(data.getReturn_address());
|
||||
|
||||
old.setProduct(data.getProduct());
|
||||
|
||||
old.setVehicle_add_on(data.getVehicle_add_on());
|
||||
|
||||
old.setIscompleted (data.getIscompleted());
|
||||
|
||||
final Rides test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.realnet.taxi_rental.Services;
|
||||
import java.util.*;
|
||||
import com.realnet.taxi_rental.Repository.Vehicle_add_onRepository;
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on;
|
||||
|
||||
import com.realnet.taxi_rental.Entity.Vehicle_add_on_ListFilter1;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Vehicle_add_on_ListFilter1Service {
|
||||
@Autowired
|
||||
private Vehicle_add_onRepository Repository;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Vehicle_add_on_ListFilter1> getlistbuilder() {
|
||||
List<Vehicle_add_on> list= Repository.findAll();
|
||||
ArrayList<Vehicle_add_on_ListFilter1> l = new ArrayList<>();
|
||||
for (Vehicle_add_on data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
dummy.setPrice_per_day(data.getPrice_per_day());
|
||||
dummy.setPrice_per_trip(data.getPrice_per_trip());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
|
||||
|
||||
|
||||
public List<Vehicle_add_on_ListFilter1> getlistbuilderparam( ) {
|
||||
List<Vehicle_add_on> list= Repository.findAll();
|
||||
ArrayList<Vehicle_add_on_ListFilter1> l = new ArrayList<>();
|
||||
for (Vehicle_add_on data : list) {
|
||||
boolean isactive = data.getActive();
|
||||
|
||||
if (isactive) {{
|
||||
Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
||||
dummy.setId(data.getId());
|
||||
dummy.setName(data.getName());
|
||||
dummy.setDescription(data.getDescription());
|
||||
dummy.setPrice_per_day(data.getPrice_per_day());
|
||||
dummy.setPrice_per_trip(data.getPrice_per_trip());
|
||||
l.add(dummy);
|
||||
}}
|
||||
}
|
||||
return l;}
|
||||
}
|
||||
@ -8,3 +8,7 @@ CREATE TABLE fdb.Vehicle_add_on(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHA
|
||||
|
||||
CREATE TABLE fdb.Custom_setting(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), pst_rate int, age_threshold int, free_km int, gst_rate int, yound_driver_surcharge int, extra_km_charge int, name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE fdb.Rides(id BIGINT NOT NULL AUTO_INCREMENT, return_address int, active VARCHAR(400), description VARCHAR(400), return_to_same_location VARCHAR(400), vehicle_add_on VARCHAR(400), product int, pick_up int, iscompleted VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE fdb.Products(id BIGINT NOT NULL AUTO_INCREMENT, product_images VARCHAR(400), active VARCHAR(400), description VARCHAR(400), category int, features int, name VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
|
||||
class ProductsApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Products/Products');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Products/Products/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Products/Products', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Products/Products/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Products/Products/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Products_viewModel/Products_view_model_screen.dart';
|
||||
import 'Products_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import '../../../../widgets/custom_dropdown_field.dart';
|
||||
import 'dart:math';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
|
||||
;import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'dart:io';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ProductsCreateEntityScreen extends StatefulWidget {
|
||||
const ProductsCreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_ProductsCreateEntityScreenState createState() => _ProductsCreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _ProductsCreateEntityScreenState extends State<ProductsCreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ProductsViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityCreateScreen(
|
||||
fields: ProductsFields.getFields(context),
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Products',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
final success = await provider.createEntity(formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../BuilderField/shared/ui/entity_details.dart';
|
||||
import '../Products_viewModel/Products_view_model_screen.dart';
|
||||
import 'Products_update_entity_screen.dart';
|
||||
|
||||
class ProductsDetailsScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
const ProductsDetailsScreen({
|
||||
super.key,
|
||||
required this.entity,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ProductsDetailsScreen> createState() => _ProductsDetailsScreenState();
|
||||
}
|
||||
|
||||
class _ProductsDetailsScreenState extends State<ProductsDetailsScreen> {
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => ProductsViewModelScreen(),
|
||||
child: ProductsUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Refresh the details screen with updated data
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Products?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
final success = await vm.deleteEntity(entity['id']);
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context); // Go back to list
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ProductsViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityDetails(
|
||||
entity: widget.entity,
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
title: 'Products',
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'category', 'label': 'Category', 'type': 'select'},
|
||||
|
||||
|
||||
|
||||
{'key': 'features', 'label': 'Features', 'type': 'select'},
|
||||
|
||||
],
|
||||
isLoading: viewModel.isLoading,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,155 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_list.dart';
|
||||
import 'Products_create_entity_screen.dart';
|
||||
import 'Products_update_entity_screen.dart';
|
||||
import '../Products_viewModel/Products_view_model_screen.dart';
|
||||
import 'Products_details_screen.dart';import 'package:flutter/services.dart';
|
||||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../widgets/custom_icon_button.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../theme/app_decoration.dart';
|
||||
import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class Products_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_Products_entity_list_screenState createState() => _Products_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _Products_entity_list_screenState extends State<Products_entity_list_screen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
final vm = Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
vm.getAllWithPagination(refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToCreateScreen() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => ProductsViewModelScreen(),
|
||||
child: const ProductsCreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => ProductsViewModelScreen(),
|
||||
child: ProductsUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => ProductsViewModelScreen(),
|
||||
child: ProductsDetailsScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Products?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
await vm.deleteEntity(entity['id']);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ProductsViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityList(
|
||||
entities: viewModel.filteredList,
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
hasMoreData: viewModel.hasMoreData,
|
||||
searchQuery: viewModel.searchQuery,
|
||||
onSearchChanged: (query) => viewModel.searchproducts(query),
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||
onRefresh: () => viewModel.refreshData(),
|
||||
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||
title: 'Products',
|
||||
onAddNew: _navigateToCreateScreen,
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'category', 'label': 'Category', 'type': 'select'},
|
||||
|
||||
|
||||
|
||||
{'key': 'features', 'label': 'Features', 'type': 'select'},
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
import 'package:base_project/BuilderField/shared/fields/number_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/password_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/phone_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/base_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/date_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/datetime_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/email_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/url_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/captcha_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/switch_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/url_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/audio_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/checkbox_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/file_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/image_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/radio_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/video_upload_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Products_viewModel/Products_view_model_screen.dart';/// Field definitions for Products entity
|
||||
/// This defines the structure and validation for Products forms
|
||||
class ProductsFields {
|
||||
/// Get field definitions for Products entity
|
||||
static List<BaseField> getFields(BuildContext context) {
|
||||
final viewModel =
|
||||
Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
return [
|
||||
// Basic Information
|
||||
CustomTextField(
|
||||
fieldKey: 'name',
|
||||
label: 'Name',
|
||||
hint: 'Enter Name',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'description',
|
||||
label: 'Description',
|
||||
hint: 'Enter Description',
|
||||
isRequired: false,
|
||||
maxLength: 1000,
|
||||
),
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'active',
|
||||
label: 'Active',
|
||||
),
|
||||
|
||||
DynamicDropdownField(
|
||||
fieldKey: 'category',
|
||||
label: 'Select Category',
|
||||
hint: 'Search and select',
|
||||
optionsLoader: () => viewModel.getcategory(),
|
||||
|
||||
|
||||
valueKey: 'id',
|
||||
displayKey: 'name',
|
||||
|
||||
|
||||
),
|
||||
|
||||
|
||||
ImageUploadField(
|
||||
fieldKey: 'product_images',
|
||||
label: 'product images',
|
||||
isRequired: false,
|
||||
),
|
||||
|
||||
DynamicDropdownField(
|
||||
fieldKey: 'features',
|
||||
label: 'Select Features',
|
||||
hint: 'Search and select',
|
||||
optionsLoader: () => viewModel.getfeatures(),
|
||||
|
||||
|
||||
valueKey: 'id',
|
||||
displayKey: 'name',
|
||||
|
||||
|
||||
),
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Products_viewModel/Products_view_model_screen.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import 'Products_fields.dart';import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
class ProductsUpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
ProductsUpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_ProductsUpdateEntityScreenState createState() => _ProductsUpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _ProductsUpdateEntityScreenState extends State<ProductsUpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<ProductsViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||
final Set<String> hiddenKeys = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'product_images',
|
||||
|
||||
|
||||
|
||||
};
|
||||
final fields = ProductsFields.getFields(context)
|
||||
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||
.toList(); return EntityUpdateScreen(
|
||||
fields: fields,
|
||||
initialData: widget.entity,
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Products',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<ProductsViewModelScreen>(context, listen: false);
|
||||
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import 'package:base_project/data/response/api_response.dart';
|
||||
|
||||
class ProductsRepoScreen {
|
||||
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
final String _endpointPath = '/Products/Products';
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl$_endpointPath/getall/page?page=$page&size=$size');
|
||||
|
||||
if (response is Map<String, dynamic> && response['content'] is List) {
|
||||
final List<Map<String, dynamic>> entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>().toList();
|
||||
return ApiResponse.success(entities);
|
||||
} else {
|
||||
return ApiResponse.error('Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> updateEntity(
|
||||
int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final response = await _helper.getPutApiResponse(
|
||||
'$baseUrl$_endpointPath/$entityId', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<void>> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId');
|
||||
return ApiResponse.success(null);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<dynamic> getcategory() async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/Car_category_ListFilter1/Car_category_ListFilter1";
|
||||
final response = await _helper.getGetApiResponse(apiUrl);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Get: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> product_imagesUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload product images: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getfeatures() async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/Feature_ListFilter1/Feature_ListFilter1";
|
||||
final response = await _helper.getGetApiResponse(apiUrl);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Get: $e');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,466 @@
|
||||
import 'package:base_project/data/response/status.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Products_Repo/Products_repo_screen.dart';
|
||||
|
||||
class ProductsViewModelScreen extends ChangeNotifier{
|
||||
final ProductsRepoScreen repo = ProductsRepoScreen();
|
||||
|
||||
|
||||
// State variables
|
||||
List<Map<String, dynamic>> _productsList = [];
|
||||
List<Map<String, dynamic>> _filteredList = [];
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
int _currentPage = 0;
|
||||
int _pageSize = 10;
|
||||
bool _hasMoreData = true;
|
||||
String _searchQuery = '';
|
||||
|
||||
// Getters
|
||||
List<Map<String, dynamic>> get productsList => _productsList;
|
||||
List<Map<String, dynamic>> get filteredList => _filteredList;
|
||||
bool get isLoading => _isLoading;
|
||||
String get errorMessage => _errorMessage;
|
||||
bool get hasMoreData => _hasMoreData;
|
||||
String get searchQuery => _searchQuery;
|
||||
|
||||
// Set loading state
|
||||
void _setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Set error message
|
||||
void _setError(String error) {
|
||||
_errorMessage = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear error
|
||||
void clearError() {
|
||||
_errorMessage = '';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Get products list
|
||||
Future<void> getEntities() async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
_productsList = response.data ?? [];
|
||||
_filteredList = List.from(_productsList);
|
||||
_currentPage = 0;
|
||||
_hasMoreData = true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch products list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch products list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Get products list with pagination
|
||||
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||
if (refresh) {
|
||||
_currentPage = 0;
|
||||
_productsList.clear();
|
||||
_filteredList.clear();
|
||||
_hasMoreData = true;
|
||||
}
|
||||
|
||||
if (!_hasMoreData || _isLoading) return;
|
||||
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getAllWithPagination(_currentPage, _pageSize);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
final newItems = response.data ?? [];
|
||||
|
||||
if (refresh) {
|
||||
_productsList = newItems;
|
||||
} else {
|
||||
_productsList.addAll(newItems);
|
||||
}
|
||||
|
||||
_filteredList = List.from(_productsList);
|
||||
_currentPage++;
|
||||
|
||||
// Check if we have more data
|
||||
_hasMoreData = newItems.length == _pageSize;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch Products list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch products list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Variable to store image files
|
||||
List<Map<String, dynamic>> _product_imagesimageFiles = [];
|
||||
|
||||
|
||||
|
||||
// Create Products
|
||||
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Always source image selections from EntityFieldStore for simplicity
|
||||
final List<UploadItem> storeImgsproduct_images = EntityFieldStore.instance
|
||||
.get<List<UploadItem>>('product_images') ??
|
||||
<UploadItem>[];
|
||||
|
||||
_product_imagesimageFiles = storeImgsproduct_images
|
||||
.map((u) => {'path': u.fileName, 'bytes': u.bytes})
|
||||
.toList();
|
||||
|
||||
|
||||
entity.remove('product_images');
|
||||
|
||||
|
||||
|
||||
|
||||
final response = await repo.createEntity(entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
// Get the response ID for image upload
|
||||
|
||||
final responseId = response.data!['id'].toString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Upload images if available
|
||||
if (_product_imagesimageFiles.isNotEmpty) {
|
||||
await _uploadproduct_images(responseId, _product_imagesimageFiles);
|
||||
_product_imagesimageFiles.clear(); // Clear after upload
|
||||
}
|
||||
|
||||
|
||||
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'products created successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Refresh the list
|
||||
await getEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EntityFieldStore.instance.remove('product_images');
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to create Products');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to create Products',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to create products: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to create Products: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update products
|
||||
Future<bool> updateEntity(int id, Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.updateEntity(id, entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Products updated successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Update the item in the list
|
||||
final index = _productsList.indexWhere((item) => item['id'] == id);
|
||||
if (index != -1) {
|
||||
_productsList[index] = response.data!;
|
||||
_filteredList = List.from(_productsList);
|
||||
notifyListeners();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to update Products');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to update Products',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to update products: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to update Products: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete products
|
||||
Future<bool> deleteEntity(int id) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.deleteEntity(id);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Products deleted successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Remove the item from the list
|
||||
_productsList.removeWhere((item) => item['id'] == id);
|
||||
_filteredList = List.from(_productsList);
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to delete Products');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to delete Products',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to delete products: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to delete Products: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Search products
|
||||
void searchproducts(String query) {
|
||||
_searchQuery = query;
|
||||
|
||||
if (query.isEmpty) {
|
||||
_filteredList = List.from(_productsList);
|
||||
} else {
|
||||
_filteredList = _productsList.where((item) {
|
||||
return
|
||||
|
||||
|
||||
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['category']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['features']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||
|
||||
|
||||
;
|
||||
}).toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear search
|
||||
void clearSearch() {
|
||||
_searchQuery = '';
|
||||
_filteredList = List.from(_productsList);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Refresh data
|
||||
Future<void> refreshData() async {
|
||||
await getAllWithPagination(refresh: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
List<Map<String, dynamic>> categoryItems = [];
|
||||
|
||||
Future<List<Map<String, dynamic>>> getcategory() async {
|
||||
|
||||
try {
|
||||
final value = await repo.getcategory();
|
||||
categoryItems = (value as List)
|
||||
.map((item) => item as Map<String, dynamic>)
|
||||
.toList();
|
||||
|
||||
return categoryItems;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Helper method to upload multiple image files
|
||||
Future<void> _uploadproduct_images(
|
||||
String responseId, List<dynamic> imageFiles) async {
|
||||
try {
|
||||
for (var imageFile in imageFiles) {
|
||||
if (imageFile is Map<String, dynamic> &&
|
||||
imageFile.containsKey('path')) {
|
||||
String filePath = imageFile['path'];
|
||||
Uint8List fileBytes = imageFile['bytes'];
|
||||
|
||||
// Upload each image file
|
||||
await uploadproduct_images(
|
||||
responseId, 'Products', filePath, fileBytes);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
print('Error uploading image files: $error');
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload images", toastType: ToastType.error);
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the uploadproduct_imagesimage function
|
||||
Future<void> uploadproduct_images(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = product_imageslookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
await repo.product_imagesUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String product_imageslookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last;
|
||||
switch (ext) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> featuresItems = [];
|
||||
|
||||
Future<List<Map<String, dynamic>>> getfeatures() async {
|
||||
|
||||
try {
|
||||
final value = await repo.getfeatures();
|
||||
featuresItems = (value as List)
|
||||
.map((item) => item as Map<String, dynamic>)
|
||||
.toList();
|
||||
|
||||
return featuresItems;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all: $e');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
|
||||
class RidesApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Rides/Rides');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Rides/Rides/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Rides/Rides', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Rides/Rides/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Rides/Rides/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Rides_viewModel/Rides_view_model_screen.dart';
|
||||
import 'Rides_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import '../../../../widgets/custom_dropdown_field.dart';
|
||||
import 'dart:math';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
|
||||
;import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'dart:io';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class RidesCreateEntityScreen extends StatefulWidget {
|
||||
const RidesCreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_RidesCreateEntityScreenState createState() => _RidesCreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _RidesCreateEntityScreenState extends State<RidesCreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<RidesViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityCreateScreen(
|
||||
fields: RidesFields.getFields(context),
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Rides',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
final success = await provider.createEntity(formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../BuilderField/shared/ui/entity_details.dart';
|
||||
import '../Rides_viewModel/Rides_view_model_screen.dart';
|
||||
import 'Rides_update_entity_screen.dart';
|
||||
|
||||
class RidesDetailsScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
const RidesDetailsScreen({
|
||||
super.key,
|
||||
required this.entity,
|
||||
});
|
||||
|
||||
@override
|
||||
State<RidesDetailsScreen> createState() => _RidesDetailsScreenState();
|
||||
}
|
||||
|
||||
class _RidesDetailsScreenState extends State<RidesDetailsScreen> {
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => RidesViewModelScreen(),
|
||||
child: RidesUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
// Refresh the details screen with updated data
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Rides?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
final success = await vm.deleteEntity(entity['id']);
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context); // Go back to list
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<RidesViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityDetails(
|
||||
entity: widget.entity,
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
title: 'Rides',
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'pick_up', 'label': 'Pick Up', 'type': 'select'},
|
||||
|
||||
{'key': 'return_to_same_location', 'label': 'return to same location', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'return_address', 'label': 'RETURN Address', 'type': 'select'},
|
||||
|
||||
{'key': 'product', 'label': 'Product', 'type': 'select'},
|
||||
|
||||
{'key': 'vehicle_add_on', 'label': 'Vehicle Add On', 'type': 'select'},
|
||||
|
||||
{'key': 'iscompleted', 'label': 'iscompleted', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
isLoading: viewModel.isLoading,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_list.dart';
|
||||
import 'Rides_create_entity_screen.dart';
|
||||
import 'Rides_update_entity_screen.dart';
|
||||
import '../Rides_viewModel/Rides_view_model_screen.dart';
|
||||
import 'Rides_details_screen.dart';import 'package:flutter/services.dart';
|
||||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../widgets/custom_icon_button.dart';
|
||||
import '../../../../utils/image_constant.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import '../../../../theme/app_decoration.dart';
|
||||
import 'package:multi_select_flutter/multi_select_flutter.dart';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class Rides_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_Rides_entity_list_screenState createState() => _Rides_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _Rides_entity_list_screenState extends State<Rides_entity_list_screen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadData();
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
final vm = Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
vm.getAllWithPagination(refresh: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToCreateScreen() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => RidesViewModelScreen(),
|
||||
child: const RidesCreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => RidesViewModelScreen(),
|
||||
child: RidesUpdateEntityScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
final vm = Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
vm.refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => RidesViewModelScreen(),
|
||||
child: RidesDetailsScreen(entity: entity),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Confirm Deletion'),
|
||||
content: const Text('Are you sure you want to delete this Rides?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final vm =
|
||||
Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
await vm.deleteEntity(entity['id']);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<RidesViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
return EntityList(
|
||||
entities: viewModel.filteredList,
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
hasMoreData: viewModel.hasMoreData,
|
||||
searchQuery: viewModel.searchQuery,
|
||||
onSearchChanged: (query) => viewModel.searchrides(query),
|
||||
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||
onDelete: (entity) => _showDeleteDialog(entity),
|
||||
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||
onRefresh: () => viewModel.refreshData(),
|
||||
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||
title: 'Rides',
|
||||
onAddNew: _navigateToCreateScreen,
|
||||
displayFields: [
|
||||
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||
|
||||
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||
|
||||
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'pick_up', 'label': 'Pick Up', 'type': 'select'},
|
||||
|
||||
{'key': 'return_to_same_location', 'label': 'return to same location', 'type': 'toggle_switch'},
|
||||
|
||||
{'key': 'return_address', 'label': 'RETURN Address', 'type': 'select'},
|
||||
|
||||
{'key': 'product', 'label': 'Product', 'type': 'select'},
|
||||
|
||||
{'key': 'vehicle_add_on', 'label': 'Vehicle Add On', 'type': 'select'},
|
||||
|
||||
{'key': 'iscompleted', 'label': 'iscompleted', 'type': 'toggle_switch'},
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
import 'package:base_project/BuilderField/shared/fields/number_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/password_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/phone_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/base_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/date_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/datetime_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/email_field.dart';
|
||||
import 'package:base_project/BuilderField/shared/fields/url_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text;
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/calculated_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_many_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/value_list_picker_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/captcha_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/switch_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/url_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/audio_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/checkbox_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/file_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/image_upload_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/radio_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/video_upload_field.dart';
|
||||
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Rides_viewModel/Rides_view_model_screen.dart';/// Field definitions for Rides entity
|
||||
/// This defines the structure and validation for Rides forms
|
||||
class RidesFields {
|
||||
/// Get field definitions for Rides entity
|
||||
static List<BaseField> getFields(BuildContext context) {
|
||||
final viewModel =
|
||||
Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
return [
|
||||
// Basic Information
|
||||
CustomTextField(
|
||||
fieldKey: 'name',
|
||||
label: 'Name',
|
||||
hint: 'Enter Name',
|
||||
isRequired: true,
|
||||
maxLength: 50,
|
||||
),
|
||||
|
||||
CustomTextField(
|
||||
fieldKey: 'description',
|
||||
label: 'Description',
|
||||
hint: 'Enter Description',
|
||||
isRequired: false,
|
||||
maxLength: 1000,
|
||||
),
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'active',
|
||||
label: 'Active',
|
||||
),
|
||||
|
||||
DynamicDropdownField(
|
||||
fieldKey: 'pick_up',
|
||||
label: 'Select Pick Up',
|
||||
hint: 'Search and select',
|
||||
optionsLoader: () => viewModel.getpick_up(),
|
||||
|
||||
|
||||
valueKey: 'id',
|
||||
displayKey: 'name',
|
||||
|
||||
|
||||
),
|
||||
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'return_to_same_location',
|
||||
label: 'return to same location',
|
||||
),
|
||||
|
||||
DynamicDropdownField(
|
||||
fieldKey: 'return_address',
|
||||
label: 'Select RETURN Address',
|
||||
hint: 'Search and select',
|
||||
optionsLoader: () => viewModel.getreturn_address(),
|
||||
|
||||
|
||||
valueKey: 'id',
|
||||
displayKey: 'name',
|
||||
|
||||
|
||||
),
|
||||
|
||||
|
||||
DynamicDropdownField(
|
||||
fieldKey: 'product',
|
||||
label: 'Select Product',
|
||||
hint: 'Search and select',
|
||||
optionsLoader: () => viewModel.getproduct(),
|
||||
|
||||
|
||||
valueKey: 'id',
|
||||
displayKey: 'name',
|
||||
|
||||
|
||||
),
|
||||
|
||||
|
||||
DynamicMultiSelectDropdownField(
|
||||
fieldKey: 'vehicle_add_on',
|
||||
label: 'Vehicle Add On',
|
||||
hint: 'Type to search and press enter',
|
||||
optionsLoader: () async {
|
||||
final list = await viewModel.getvehicle_add_on();
|
||||
return list
|
||||
|
||||
|
||||
.map((e) => e['name']?.toString() ?? '')
|
||||
.where((e) => e.isNotEmpty)
|
||||
.toList();
|
||||
|
||||
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
SwitchField(
|
||||
fieldKey: 'iscompleted',
|
||||
label: 'iscompleted',
|
||||
),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Rides_viewModel/Rides_view_model_screen.dart';
|
||||
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||
import 'Rides_fields.dart';import '../../../../utils/image_constant.dart';
|
||||
import '../../../../utils/size_utils.dart';
|
||||
import '../../../../theme/app_style.dart';
|
||||
import '../../../../widgets/app_bar/appbar_image.dart';
|
||||
import '../../../../widgets/app_bar/appbar_title.dart';
|
||||
import '../../../../widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import '../../../../widgets/custom_button.dart';
|
||||
import '../../../../widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import '../../../../Reuseable/reusable_text_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_date_time_picker_field.dart';
|
||||
import '../../../../Reuseable/reusable_dropdown_field.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
class RidesUpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
RidesUpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_RidesUpdateEntityScreenState createState() => _RidesUpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _RidesUpdateEntityScreenState extends State<RidesUpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<RidesViewModelScreen>(
|
||||
builder: (context, viewModel, child) {
|
||||
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||
final Set<String> hiddenKeys = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
final fields = RidesFields.getFields(context)
|
||||
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||
.toList(); return EntityUpdateScreen(
|
||||
fields: fields,
|
||||
initialData: widget.entity,
|
||||
onSubmit: (data) => _handleSubmit(data),
|
||||
title: 'Rides',
|
||||
isLoading: viewModel.isLoading,
|
||||
errorMessage:
|
||||
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||
final provider =
|
||||
Provider.of<RidesViewModelScreen>(context, listen: false);
|
||||
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
import 'package:base_project/data/response/api_response.dart';
|
||||
|
||||
class RidesRepoScreen {
|
||||
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
final String _endpointPath = '/Rides/Rides';
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl$_endpointPath/getall/page?page=$page&size=$size');
|
||||
|
||||
if (response is Map<String, dynamic> && response['content'] is List) {
|
||||
final List<Map<String, dynamic>> entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>().toList();
|
||||
return ApiResponse.success(entities);
|
||||
} else {
|
||||
return ApiResponse.error('Invalid response format');
|
||||
}
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<Map<String, dynamic>>> updateEntity(
|
||||
int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final response = await _helper.getPutApiResponse(
|
||||
'$baseUrl$_endpointPath/$entityId', entity);
|
||||
return ApiResponse.success(response as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<ApiResponse<void>> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId');
|
||||
return ApiResponse.success(null);
|
||||
} catch (e) {
|
||||
return ApiResponse.error('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<dynamic> getpick_up() async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/Office_ListFilter1/Office_ListFilter1";
|
||||
final response = await _helper.getGetApiResponse(apiUrl);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Get: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<dynamic> getreturn_address() async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/Office_ListFilter1/Office_ListFilter1";
|
||||
final response = await _helper.getGetApiResponse(apiUrl);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Get: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getproduct() async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/Products_ListFilter1/Products_ListFilter1";
|
||||
final response = await _helper.getGetApiResponse(apiUrl);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Get: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getvehicle_add_on() async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/Vehicle_add_on_ListFilter1/Vehicle_add_on_ListFilter1";
|
||||
final response = await _helper.getGetApiResponse(apiUrl);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Get: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,451 @@
|
||||
import 'package:base_project/data/response/status.dart';
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import '../../../../utils/toast_messages/toast_message_util.dart';
|
||||
import '../../../../BuilderField/shared/utils/entity_field_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../Rides_Repo/Rides_repo_screen.dart';
|
||||
|
||||
class RidesViewModelScreen extends ChangeNotifier{
|
||||
final RidesRepoScreen repo = RidesRepoScreen();
|
||||
|
||||
|
||||
// State variables
|
||||
List<Map<String, dynamic>> _ridesList = [];
|
||||
List<Map<String, dynamic>> _filteredList = [];
|
||||
bool _isLoading = false;
|
||||
String _errorMessage = '';
|
||||
int _currentPage = 0;
|
||||
int _pageSize = 10;
|
||||
bool _hasMoreData = true;
|
||||
String _searchQuery = '';
|
||||
|
||||
// Getters
|
||||
List<Map<String, dynamic>> get ridesList => _ridesList;
|
||||
List<Map<String, dynamic>> get filteredList => _filteredList;
|
||||
bool get isLoading => _isLoading;
|
||||
String get errorMessage => _errorMessage;
|
||||
bool get hasMoreData => _hasMoreData;
|
||||
String get searchQuery => _searchQuery;
|
||||
|
||||
// Set loading state
|
||||
void _setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Set error message
|
||||
void _setError(String error) {
|
||||
_errorMessage = error;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear error
|
||||
void clearError() {
|
||||
_errorMessage = '';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Get rides list
|
||||
Future<void> getEntities() async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
_ridesList = response.data ?? [];
|
||||
_filteredList = List.from(_ridesList);
|
||||
_currentPage = 0;
|
||||
_hasMoreData = true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch rides list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch rides list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Get rides list with pagination
|
||||
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||
if (refresh) {
|
||||
_currentPage = 0;
|
||||
_ridesList.clear();
|
||||
_filteredList.clear();
|
||||
_hasMoreData = true;
|
||||
}
|
||||
|
||||
if (!_hasMoreData || _isLoading) return;
|
||||
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.getAllWithPagination(_currentPage, _pageSize);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
final newItems = response.data ?? [];
|
||||
|
||||
if (refresh) {
|
||||
_ridesList = newItems;
|
||||
} else {
|
||||
_ridesList.addAll(newItems);
|
||||
}
|
||||
|
||||
_filteredList = List.from(_ridesList);
|
||||
_currentPage++;
|
||||
|
||||
// Check if we have more data
|
||||
_hasMoreData = newItems.length == _pageSize;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to fetch Rides list');
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to fetch rides list: $e');
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create Rides
|
||||
Future<bool> createEntity(Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final response = await repo.createEntity(entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
// Get the response ID for image upload
|
||||
|
||||
final responseId = response.data!['id'].toString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'rides created successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Refresh the list
|
||||
await getEntities();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to create Rides');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to create Rides',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to create rides: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to create Rides: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Update rides
|
||||
Future<bool> updateEntity(int id, Map<String, dynamic> entity) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.updateEntity(id, entity);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Rides updated successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Update the item in the list
|
||||
final index = _ridesList.indexWhere((item) => item['id'] == id);
|
||||
if (index != -1) {
|
||||
_ridesList[index] = response.data!;
|
||||
_filteredList = List.from(_ridesList);
|
||||
notifyListeners();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to update Rides');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to update Rides',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to update rides: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to update Rides: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete rides
|
||||
Future<bool> deleteEntity(int id) async {
|
||||
_setLoading(true);
|
||||
_setError('');
|
||||
|
||||
try {
|
||||
final response = await repo.deleteEntity(id);
|
||||
|
||||
if (response.status == Status.SUCCESS) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Rides deleted successfully',
|
||||
toastType: ToastType.success,
|
||||
);
|
||||
|
||||
// Remove the item from the list
|
||||
_ridesList.removeWhere((item) => item['id'] == id);
|
||||
_filteredList = List.from(_ridesList);
|
||||
notifyListeners();
|
||||
return true;
|
||||
} else {
|
||||
_setError(response.message ?? 'Failed to delete Rides');
|
||||
ToastMessageUtil.showToast(
|
||||
message: response.message ?? 'Failed to delete Rides',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
_setError('Failed to delete rides: $e');
|
||||
ToastMessageUtil.showToast(
|
||||
message: 'Failed to delete Rides: $e',
|
||||
toastType: ToastType.error,
|
||||
);
|
||||
return false;
|
||||
} finally {
|
||||
_setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Search rides
|
||||
void searchrides(String query) {
|
||||
_searchQuery = query;
|
||||
|
||||
if (query.isEmpty) {
|
||||
_filteredList = List.from(_ridesList);
|
||||
} else {
|
||||
_filteredList = _ridesList.where((item) {
|
||||
return
|
||||
|
||||
|
||||
(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['description']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['pick_up']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['return_to_same_location']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['return_address']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['product']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(item['vehicle_add_on']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||
|
||||
|
||||
(item['iscompleted']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||
|
||||
|
||||
;
|
||||
}).toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Clear search
|
||||
void clearSearch() {
|
||||
_searchQuery = '';
|
||||
_filteredList = List.from(_ridesList);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Refresh data
|
||||
Future<void> refreshData() async {
|
||||
await getAllWithPagination(refresh: true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
List<Map<String, dynamic>> pick_upItems = [];
|
||||
|
||||
Future<List<Map<String, dynamic>>> getpick_up() async {
|
||||
|
||||
try {
|
||||
final value = await repo.getpick_up();
|
||||
pick_upItems = (value as List)
|
||||
.map((item) => item as Map<String, dynamic>)
|
||||
.toList();
|
||||
|
||||
return pick_upItems;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<Map<String, dynamic>> return_addressItems = [];
|
||||
|
||||
Future<List<Map<String, dynamic>>> getreturn_address() async {
|
||||
|
||||
try {
|
||||
final value = await repo.getreturn_address();
|
||||
return_addressItems = (value as List)
|
||||
.map((item) => item as Map<String, dynamic>)
|
||||
.toList();
|
||||
|
||||
return return_addressItems;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all: $e');
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> productItems = [];
|
||||
|
||||
Future<List<Map<String, dynamic>>> getproduct() async {
|
||||
|
||||
try {
|
||||
final value = await repo.getproduct();
|
||||
productItems = (value as List)
|
||||
.map((item) => item as Map<String, dynamic>)
|
||||
.toList();
|
||||
|
||||
return productItems;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all: $e');
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> vehicle_add_onItems = [];
|
||||
|
||||
Future<List<Map<String, dynamic>>> getvehicle_add_on() async {
|
||||
|
||||
try {
|
||||
final value = await repo.getvehicle_add_on();
|
||||
vehicle_add_onItems = (value as List)
|
||||
.map((item) => item as Map<String, dynamic>)
|
||||
.toList();
|
||||
|
||||
return vehicle_add_onItems;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,5 +1,16 @@
|
||||
import '../../Entity/taxi_rental/Custom_setting/Custom_settingView/Custom_setting_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Custom_setting/Custom_setting_viewModel/Custom_setting_view_model_screen.dart';
|
||||
import '../../Entity/taxi_rental/Products/ProductsView/Products_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Products/Products_viewModel/Products_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/taxi_rental/Rides/RidesView/Rides_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Rides/Rides_viewModel/Rides_view_model_screen.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import '../../Entity/taxi_rental/Custom_setting/Custom_settingView/Custom_setting_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Custom_setting/Custom_setting_viewModel/Custom_setting_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/taxi_rental/Vehicle_add_on/Vehicle_add_onView/Vehicle_add_on_entity_list_screen.dart';
|
||||
import '../../Entity/taxi_rental/Vehicle_add_on/Vehicle_add_on_viewModel/Vehicle_add_on_view_model_screen.dart';
|
||||
@ -105,21 +116,65 @@ Navigator.pushNamed(context, RouteNames.changePasswordView);
|
||||
// NEW MENU
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Custom_setting Management',
|
||||
subtitle: 'Manage Custom_setting entities',
|
||||
title: 'Products Management',
|
||||
subtitle: 'Manage Products entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Custom_settingViewModelScreen(),
|
||||
child: Custom_setting_entity_list_screen(),
|
||||
create: (context) => ProductsViewModelScreen(),
|
||||
child: Products_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Rides Management',
|
||||
subtitle: 'Manage Rides entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => RidesViewModelScreen(),
|
||||
child: Rides_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Custom_setting Management',
|
||||
subtitle: 'Manage Custom_setting entities',
|
||||
onTap: (context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Custom_settingViewModelScreen(),
|
||||
child: Custom_setting_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.data_object,
|
||||
title: 'Vehicle_add_on Management',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user