build_app
This commit is contained in:
parent
4c40852677
commit
9a99b63a92
@ -69,6 +69,15 @@ public class BuilderService {
|
|||||||
executeDump(true);
|
executeDump(true);
|
||||||
|
|
||||||
// ADD OTHER SERVICE
|
// ADD OTHER SERVICE
|
||||||
|
addCustomMenu( "Guestuser","Guestuser", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
addCustomMenu( "Coupon","Coupon", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
addCustomMenu( "Feature","Feature", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
addCustomMenu( "Products","Products", "Transcations");
|
addCustomMenu( "Products","Products", "Transcations");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,99 @@
|
|||||||
|
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.Coupon;
|
||||||
|
import com.realnet.taxi_rental.Services.CouponService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Coupon")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class CouponController {
|
||||||
|
@Autowired
|
||||||
|
private CouponService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Coupon")
|
||||||
|
public Coupon Savedata(@RequestBody Coupon data) {
|
||||||
|
Coupon save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Coupon/{id}")
|
||||||
|
public Coupon update(@RequestBody Coupon data,@PathVariable Integer id ) {
|
||||||
|
Coupon update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Coupon/getall/page")
|
||||||
|
public Page<Coupon> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Coupon> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Coupon")
|
||||||
|
public List<Coupon> getdetails() {
|
||||||
|
List<Coupon> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Coupon")
|
||||||
|
public List<Coupon> getallwioutsec() {
|
||||||
|
List<Coupon> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Coupon/{id}")
|
||||||
|
public Coupon getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Coupon get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Coupon/{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,131 @@
|
|||||||
|
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.Guestuser;
|
||||||
|
import com.realnet.taxi_rental.Services.GuestuserService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Guestuser")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class GuestuserController {
|
||||||
|
@Autowired
|
||||||
|
private GuestuserService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Guestuser")
|
||||||
|
public Guestuser Savedata(@RequestBody Guestuser data) {
|
||||||
|
Guestuser save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Guestuser/{id}")
|
||||||
|
public Guestuser update(@RequestBody Guestuser data,@PathVariable Integer id ) {
|
||||||
|
Guestuser update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Guestuser/getall/page")
|
||||||
|
public Page<Guestuser> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Guestuser> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Guestuser")
|
||||||
|
public List<Guestuser> getdetails() {
|
||||||
|
List<Guestuser> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Guestuser")
|
||||||
|
public List<Guestuser> getallwioutsec() {
|
||||||
|
List<Guestuser> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Guestuser/{id}")
|
||||||
|
public Guestuser getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Guestuser get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Guestuser/{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,99 @@
|
|||||||
|
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.Coupon;
|
||||||
|
import com.realnet.taxi_rental.Services.CouponService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Coupon")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_CouponController {
|
||||||
|
@Autowired
|
||||||
|
private CouponService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Coupon")
|
||||||
|
public Coupon Savedata(@RequestBody Coupon data) {
|
||||||
|
Coupon save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Coupon/{id}")
|
||||||
|
public Coupon update(@RequestBody Coupon data,@PathVariable Integer id ) {
|
||||||
|
Coupon update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Coupon/getall/page")
|
||||||
|
public Page<Coupon> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Coupon> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Coupon")
|
||||||
|
public List<Coupon> getdetails() {
|
||||||
|
List<Coupon> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Coupon")
|
||||||
|
public List<Coupon> getallwioutsec() {
|
||||||
|
List<Coupon> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Coupon/{id}")
|
||||||
|
public Coupon getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Coupon get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Coupon/{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,131 @@
|
|||||||
|
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.Guestuser;
|
||||||
|
import com.realnet.taxi_rental.Services.GuestuserService ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Guestuser")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_GuestuserController {
|
||||||
|
@Autowired
|
||||||
|
private GuestuserService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/Guestuser")
|
||||||
|
public Guestuser Savedata(@RequestBody Guestuser data) {
|
||||||
|
Guestuser save = Service.Savedata(data) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
@PutMapping("/Guestuser/{id}")
|
||||||
|
public Guestuser update(@RequestBody Guestuser data,@PathVariable Integer id ) {
|
||||||
|
Guestuser update = Service.update(data,id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Guestuser/getall/page")
|
||||||
|
public Page<Guestuser> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Guestuser> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/Guestuser")
|
||||||
|
public List<Guestuser> getdetails() {
|
||||||
|
List<Guestuser> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Guestuser")
|
||||||
|
public List<Guestuser> getallwioutsec() {
|
||||||
|
List<Guestuser> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@GetMapping("/Guestuser/{id}")
|
||||||
|
public Guestuser getdetailsbyId(@PathVariable Integer id ) {
|
||||||
|
Guestuser get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
@DeleteMapping("/Guestuser/{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,33 @@
|
|||||||
|
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 Coupon 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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -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 Guestuser extends Extension {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String fullname;
|
||||||
|
|
||||||
|
private Boolean active;
|
||||||
|
|
||||||
|
private String macaddress;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private String mob_no;
|
||||||
|
|
||||||
|
private String dateofbirth;
|
||||||
|
|
||||||
|
private String driving_license_no;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
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.Coupon;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CouponRepository extends JpaRepository<Coupon, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from coupon where created_by=?1", nativeQuery = true)
|
||||||
|
List<Coupon> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from coupon where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Coupon> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
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.Guestuser;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface GuestuserRepository extends JpaRepository<Guestuser, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from guestuser where created_by=?1", nativeQuery = true)
|
||||||
|
List<Guestuser> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from guestuser where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Guestuser> findAll( Long creayedBy,Pageable page);
|
||||||
|
}
|
||||||
@ -21,15 +21,13 @@ private Car_categoryRepository Repository;
|
|||||||
List<Car_category> list= Repository.findAll();
|
List<Car_category> list= Repository.findAll();
|
||||||
ArrayList<Car_category_ListFilter1> l = new ArrayList<>();
|
ArrayList<Car_category_ListFilter1> l = new ArrayList<>();
|
||||||
for (Car_category data : list) {
|
for (Car_category data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Car_category_ListFilter1 dummy = new Car_category_ListFilter1();
|
Car_category_ListFilter1 dummy = new Car_category_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
dummy.setDescription(data.getDescription());
|
dummy.setDescription(data.getDescription());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
|
|
||||||
@ -39,15 +37,13 @@ return l;}
|
|||||||
List<Car_category> list= Repository.findAll();
|
List<Car_category> list= Repository.findAll();
|
||||||
ArrayList<Car_category_ListFilter1> l = new ArrayList<>();
|
ArrayList<Car_category_ListFilter1> l = new ArrayList<>();
|
||||||
for (Car_category data : list) {
|
for (Car_category data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Car_category_ListFilter1 dummy = new Car_category_ListFilter1();
|
Car_category_ListFilter1 dummy = new Car_category_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
dummy.setDescription(data.getDescription());
|
dummy.setDescription(data.getDescription());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.realnet.taxi_rental.Services;
|
||||||
|
import com.realnet.taxi_rental.Repository.CouponRepository;
|
||||||
|
import com.realnet.taxi_rental.Entity.Coupon
|
||||||
|
;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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CouponService {
|
||||||
|
@Autowired
|
||||||
|
private CouponRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Coupon Savedata(Coupon data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Coupon save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Coupon> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Coupon> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Coupon> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Coupon getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Coupon update(Coupon data,Integer id) {
|
||||||
|
Coupon old = Repository.findById(id).get();
|
||||||
|
old.setName(data.getName());
|
||||||
|
|
||||||
|
old.setDescription(data.getDescription());
|
||||||
|
|
||||||
|
old.setActive (data.getActive());
|
||||||
|
|
||||||
|
final Coupon test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -21,9 +21,7 @@ private Custom_settingRepository Repository;
|
|||||||
List<Custom_setting> list= Repository.findAll();
|
List<Custom_setting> list= Repository.findAll();
|
||||||
ArrayList<Custom_setting_ListFilter1> l = new ArrayList<>();
|
ArrayList<Custom_setting_ListFilter1> l = new ArrayList<>();
|
||||||
for (Custom_setting data : list) {
|
for (Custom_setting data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
@ -35,7 +33,7 @@ Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
|||||||
dummy.setPst_rate(data.getPst_rate());
|
dummy.setPst_rate(data.getPst_rate());
|
||||||
dummy.setAge_threshold(data.getAge_threshold());
|
dummy.setAge_threshold(data.getAge_threshold());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
|
|
||||||
@ -45,9 +43,7 @@ return l;}
|
|||||||
List<Custom_setting> list= Repository.findAll();
|
List<Custom_setting> list= Repository.findAll();
|
||||||
ArrayList<Custom_setting_ListFilter1> l = new ArrayList<>();
|
ArrayList<Custom_setting_ListFilter1> l = new ArrayList<>();
|
||||||
for (Custom_setting data : list) {
|
for (Custom_setting data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
@ -59,7 +55,7 @@ Custom_setting_ListFilter1 dummy = new Custom_setting_ListFilter1();
|
|||||||
dummy.setPst_rate(data.getPst_rate());
|
dummy.setPst_rate(data.getPst_rate());
|
||||||
dummy.setAge_threshold(data.getAge_threshold());
|
dummy.setAge_threshold(data.getAge_threshold());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
}
|
}
|
||||||
@ -21,9 +21,9 @@ private FeatureRepository Repository;
|
|||||||
List<Feature> list= Repository.findAll();
|
List<Feature> list= Repository.findAll();
|
||||||
ArrayList<Feature_ListFilter1> l = new ArrayList<>();
|
ArrayList<Feature_ListFilter1> l = new ArrayList<>();
|
||||||
for (Feature data : list) {
|
for (Feature data : list) {
|
||||||
boolean isactive = data.getActive();
|
Boolean isActive = data.getActive();
|
||||||
|
|
||||||
if (isactive) {{
|
if (Boolean.TRUE.equals(isActive)) {{
|
||||||
Feature_ListFilter1 dummy = new Feature_ListFilter1();
|
Feature_ListFilter1 dummy = new Feature_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
@ -39,9 +39,9 @@ return l;}
|
|||||||
List<Feature> list= Repository.findAll();
|
List<Feature> list= Repository.findAll();
|
||||||
ArrayList<Feature_ListFilter1> l = new ArrayList<>();
|
ArrayList<Feature_ListFilter1> l = new ArrayList<>();
|
||||||
for (Feature data : list) {
|
for (Feature data : list) {
|
||||||
boolean isactive = data.getActive();
|
Boolean isActive = data.getActive();
|
||||||
|
|
||||||
if (isactive) {{
|
if (Boolean.TRUE.equals(isActive)) {{
|
||||||
Feature_ListFilter1 dummy = new Feature_ListFilter1();
|
Feature_ListFilter1 dummy = new Feature_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
|
|||||||
@ -0,0 +1,133 @@
|
|||||||
|
package com.realnet.taxi_rental.Services;
|
||||||
|
import com.realnet.taxi_rental.Repository.GuestuserRepository;
|
||||||
|
import com.realnet.taxi_rental.Entity.Guestuser
|
||||||
|
;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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GuestuserService {
|
||||||
|
@Autowired
|
||||||
|
private GuestuserRepository Repository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Guestuser Savedata(Guestuser data) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
Guestuser save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Guestuser> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll( getUser().getUserId(),page);
|
||||||
|
}
|
||||||
|
public List<Guestuser> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Guestuser> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all ; }
|
||||||
|
|
||||||
|
|
||||||
|
public Guestuser getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Guestuser update(Guestuser data,Integer id) {
|
||||||
|
Guestuser old = Repository.findById(id).get();
|
||||||
|
old.setFullname(data.getFullname());
|
||||||
|
|
||||||
|
old.setActive (data.getActive());
|
||||||
|
|
||||||
|
old.setMacaddress(data.getMacaddress());
|
||||||
|
|
||||||
|
old.setEmail(data.getEmail());
|
||||||
|
|
||||||
|
old.setMob_no(data.getMob_no());
|
||||||
|
|
||||||
|
old.setDateofbirth(data.getDateofbirth());
|
||||||
|
|
||||||
|
old.setDriving_license_no(data.getDriving_license_no());
|
||||||
|
|
||||||
|
final Guestuser test = Repository.save(old);
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
return test;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}}
|
||||||
@ -21,14 +21,12 @@ private OfficeRepository Repository;
|
|||||||
List<Office> list= Repository.findAll();
|
List<Office> list= Repository.findAll();
|
||||||
ArrayList<Office_ListFilter1> l = new ArrayList<>();
|
ArrayList<Office_ListFilter1> l = new ArrayList<>();
|
||||||
for (Office data : list) {
|
for (Office data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Office_ListFilter1 dummy = new Office_ListFilter1();
|
Office_ListFilter1 dummy = new Office_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
|
|
||||||
@ -38,14 +36,12 @@ return l;}
|
|||||||
List<Office> list= Repository.findAll();
|
List<Office> list= Repository.findAll();
|
||||||
ArrayList<Office_ListFilter1> l = new ArrayList<>();
|
ArrayList<Office_ListFilter1> l = new ArrayList<>();
|
||||||
for (Office data : list) {
|
for (Office data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Office_ListFilter1 dummy = new Office_ListFilter1();
|
Office_ListFilter1 dummy = new Office_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
}
|
}
|
||||||
@ -21,9 +21,7 @@ private ProductsRepository Repository;
|
|||||||
List<Products> list= Repository.findAll();
|
List<Products> list= Repository.findAll();
|
||||||
ArrayList<Products_ListFilter1> l = new ArrayList<>();
|
ArrayList<Products_ListFilter1> l = new ArrayList<>();
|
||||||
for (Products data : list) {
|
for (Products data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Products_ListFilter1 dummy = new Products_ListFilter1();
|
Products_ListFilter1 dummy = new Products_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
@ -31,7 +29,7 @@ Products_ListFilter1 dummy = new Products_ListFilter1();
|
|||||||
dummy.setFeatures(data.getFeatures());
|
dummy.setFeatures(data.getFeatures());
|
||||||
dummy.setDescription(data.getDescription());
|
dummy.setDescription(data.getDescription());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
|
|
||||||
@ -41,9 +39,7 @@ return l;}
|
|||||||
List<Products> list= Repository.findAll();
|
List<Products> list= Repository.findAll();
|
||||||
ArrayList<Products_ListFilter1> l = new ArrayList<>();
|
ArrayList<Products_ListFilter1> l = new ArrayList<>();
|
||||||
for (Products data : list) {
|
for (Products data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Products_ListFilter1 dummy = new Products_ListFilter1();
|
Products_ListFilter1 dummy = new Products_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
@ -51,7 +47,7 @@ Products_ListFilter1 dummy = new Products_ListFilter1();
|
|||||||
dummy.setFeatures(data.getFeatures());
|
dummy.setFeatures(data.getFeatures());
|
||||||
dummy.setDescription(data.getDescription());
|
dummy.setDescription(data.getDescription());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
}
|
}
|
||||||
@ -21,9 +21,7 @@ private Vehicle_add_onRepository Repository;
|
|||||||
List<Vehicle_add_on> list= Repository.findAll();
|
List<Vehicle_add_on> list= Repository.findAll();
|
||||||
ArrayList<Vehicle_add_on_ListFilter1> l = new ArrayList<>();
|
ArrayList<Vehicle_add_on_ListFilter1> l = new ArrayList<>();
|
||||||
for (Vehicle_add_on data : list) {
|
for (Vehicle_add_on data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
@ -31,7 +29,7 @@ Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
|||||||
dummy.setPrice_per_day(data.getPrice_per_day());
|
dummy.setPrice_per_day(data.getPrice_per_day());
|
||||||
dummy.setPrice_per_trip(data.getPrice_per_trip());
|
dummy.setPrice_per_trip(data.getPrice_per_trip());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
|
|
||||||
@ -41,9 +39,7 @@ return l;}
|
|||||||
List<Vehicle_add_on> list= Repository.findAll();
|
List<Vehicle_add_on> list= Repository.findAll();
|
||||||
ArrayList<Vehicle_add_on_ListFilter1> l = new ArrayList<>();
|
ArrayList<Vehicle_add_on_ListFilter1> l = new ArrayList<>();
|
||||||
for (Vehicle_add_on data : list) {
|
for (Vehicle_add_on data : list) {
|
||||||
boolean isactive = data.getActive();
|
{
|
||||||
|
|
||||||
if (isactive) {{
|
|
||||||
Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
||||||
dummy.setId(data.getId());
|
dummy.setId(data.getId());
|
||||||
dummy.setName(data.getName());
|
dummy.setName(data.getName());
|
||||||
@ -51,7 +47,7 @@ Vehicle_add_on_ListFilter1 dummy = new Vehicle_add_on_ListFilter1();
|
|||||||
dummy.setPrice_per_day(data.getPrice_per_day());
|
dummy.setPrice_per_day(data.getPrice_per_day());
|
||||||
dummy.setPrice_per_trip(data.getPrice_per_trip());
|
dummy.setPrice_per_trip(data.getPrice_per_trip());
|
||||||
l.add(dummy);
|
l.add(dummy);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
return l;}
|
return l;}
|
||||||
}
|
}
|
||||||
@ -1,14 +1,6 @@
|
|||||||
CREATE TABLE fdb.Feature(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
CREATE TABLE fdb.Feature(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
CREATE TABLE fdb.Office(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
CREATE TABLE fdb.Coupon(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
CREATE TABLE fdb.Car_category(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id));
|
CREATE TABLE fdb.Guestuser(id BIGINT NOT NULL AUTO_INCREMENT, dateofbirth Date, active VARCHAR(400), macaddress VARCHAR(400), driving_license_no VARCHAR(400), fullname VARCHAR(400), email VARCHAR(400), mob_no VARCHAR(400), PRIMARY KEY (id));
|
||||||
|
|
||||||
CREATE TABLE fdb.Vehicle_add_on(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), icon VARCHAR(400), price_per_day int, price_per_trip int, name VARCHAR(400), PRIMARY KEY (id));
|
|
||||||
|
|
||||||
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,84 @@
|
|||||||
|
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 CouponApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Coupon/Coupon');
|
||||||
|
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/Coupon/Coupon/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/Coupon/Coupon', 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/Coupon/Coupon/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Coupon/Coupon/$entityId');
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to delete entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
// 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 '../Coupon_viewModel/Coupon_view_model_screen.dart';
|
||||||
|
import 'Coupon_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 CouponCreateEntityScreen extends StatefulWidget {
|
||||||
|
const CouponCreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CouponCreateEntityScreenState createState() => _CouponCreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CouponCreateEntityScreenState extends State<CouponCreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<CouponViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: CouponFields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Coupon',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<CouponViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.createEntity(formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
// 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 '../Coupon_viewModel/Coupon_view_model_screen.dart';
|
||||||
|
import 'Coupon_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class CouponDetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const CouponDetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CouponDetailsScreen> createState() => _CouponDetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CouponDetailsScreenState extends State<CouponDetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CouponViewModelScreen(),
|
||||||
|
child: CouponUpdateEntityScreen(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 Coupon?'),
|
||||||
|
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<CouponViewModelScreen>(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<CouponViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Coupon',
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||||
|
|
||||||
|
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||||
|
|
||||||
|
],
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,150 @@
|
|||||||
|
// 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 'Coupon_create_entity_screen.dart';
|
||||||
|
import 'Coupon_update_entity_screen.dart';
|
||||||
|
import '../Coupon_viewModel/Coupon_view_model_screen.dart';
|
||||||
|
import 'Coupon_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 Coupon_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Coupon_entity_list_screenState createState() => _Coupon_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Coupon_entity_list_screenState extends State<Coupon_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<CouponViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CouponViewModelScreen(),
|
||||||
|
child: const CouponCreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<CouponViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CouponViewModelScreen(),
|
||||||
|
child: CouponUpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<CouponViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CouponViewModelScreen(),
|
||||||
|
child: CouponDetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Coupon?'),
|
||||||
|
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<CouponViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<CouponViewModelScreen>(
|
||||||
|
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.searchcoupon(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Coupon',
|
||||||
|
onAddNew: _navigateToCreateScreen,
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'name', 'label': 'Name', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'description', 'label': 'Description', 'type': 'textarea'},
|
||||||
|
|
||||||
|
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
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 '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Coupon_viewModel/Coupon_view_model_screen.dart';/// Field definitions for Coupon entity
|
||||||
|
/// This defines the structure and validation for Coupon forms
|
||||||
|
class CouponFields {
|
||||||
|
/// Get field definitions for Coupon entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<CouponViewModelScreen>(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',
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Coupon_viewModel/Coupon_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Coupon_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 CouponUpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
CouponUpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CouponUpdateEntityScreenState createState() => _CouponUpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CouponUpdateEntityScreenState extends State<CouponUpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<CouponViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = CouponFields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Coupon',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<CouponViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
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 CouponRepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Coupon/Coupon';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,305 @@
|
|||||||
|
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 '../Coupon_Repo/Coupon_repo_screen.dart';
|
||||||
|
|
||||||
|
class CouponViewModelScreen extends ChangeNotifier{
|
||||||
|
final CouponRepoScreen repo = CouponRepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _couponList = [];
|
||||||
|
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 couponList => _couponList;
|
||||||
|
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 coupon list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_couponList = response.data ?? [];
|
||||||
|
_filteredList = List.from(_couponList);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch coupon list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch coupon list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get coupon list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_couponList.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) {
|
||||||
|
_couponList = newItems;
|
||||||
|
} else {
|
||||||
|
_couponList.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_couponList);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Coupon list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch coupon list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create Coupon
|
||||||
|
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: 'coupon created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Coupon');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Coupon',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create coupon: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Coupon: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update coupon
|
||||||
|
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: 'Coupon updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _couponList.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_couponList[index] = response.data!;
|
||||||
|
_filteredList = List.from(_couponList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Coupon');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Coupon',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update coupon: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Coupon: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete coupon
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Coupon deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_couponList.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_couponList);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Coupon');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Coupon',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete coupon: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Coupon: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search coupon
|
||||||
|
void searchcoupon(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_couponList);
|
||||||
|
} else {
|
||||||
|
_filteredList = _couponList.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)
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
void clearSearch() {
|
||||||
|
_searchQuery = '';
|
||||||
|
_filteredList = List.from(_couponList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -87,6 +87,7 @@ class _Feature_entity_list_screenState extends State<Feature_entity_list_screen>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showDeleteDialog(Map<String, dynamic> entity) {
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@ -105,7 +106,7 @@ class _Feature_entity_list_screenState extends State<Feature_entity_list_screen>
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
final vm =
|
final vm =
|
||||||
Provider.of<FeatureViewModelScreen>(context, listen: false);
|
Provider.of<FeatureViewModelScreen>(parentContext, listen: false);
|
||||||
await vm.deleteEntity(entity['id']);
|
await vm.deleteEntity(entity['id']);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -35,7 +35,13 @@ import '../../../../BuilderField/shared/fields/data_grid_field.dart';
|
|||||||
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
import '../../../../BuilderField/shared/fields/dropdown_field.dart';
|
||||||
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart';
|
||||||
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart';
|
||||||
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';import '../Feature_viewModel/Feature_view_model_screen.dart';/// Field definitions for Feature entity
|
import '../../../../BuilderField/shared/fields/static_multiselect_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Feature_viewModel/Feature_view_model_screen.dart';/// Field definitions for Feature entity
|
||||||
/// This defines the structure and validation for Feature forms
|
/// This defines the structure and validation for Feature forms
|
||||||
class FeatureFields {
|
class FeatureFields {
|
||||||
/// Get field definitions for Feature entity
|
/// Get field definitions for Feature entity
|
||||||
|
|||||||
@ -14,8 +14,25 @@ class FeatureRepoScreen {
|
|||||||
try {
|
try {
|
||||||
final response =
|
final response =
|
||||||
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
return ApiResponse.success(response as List<Map<String, dynamic>>);
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
print(' error got $e');
|
||||||
return ApiResponse.error('Failed to get all entities: $e');
|
return ApiResponse.error('Failed to get all entities: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,100 @@
|
|||||||
|
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 GuestuserApiService {
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _helper.getGetApiResponse('$baseUrl/Guestuser/Guestuser');
|
||||||
|
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/Guestuser/Guestuser/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/Guestuser/Guestuser', 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/Guestuser/Guestuser/$entityId',
|
||||||
|
entity); print(entity);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to update entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteEntity( int entityId) async {
|
||||||
|
try {
|
||||||
|
await _helper.getDeleteApiResponse('$baseUrl/Guestuser/Guestuser/$entityId');
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to delete entity: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
// 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 '../Guestuser_viewModel/Guestuser_view_model_screen.dart';
|
||||||
|
import 'Guestuser_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 GuestuserCreateEntityScreen extends StatefulWidget {
|
||||||
|
const GuestuserCreateEntityScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_GuestuserCreateEntityScreenState createState() => _GuestuserCreateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GuestuserCreateEntityScreenState extends State<GuestuserCreateEntityScreen> {
|
||||||
|
|
||||||
|
final Map<String, dynamic> formData = {};
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<GuestuserViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityCreateScreen(
|
||||||
|
fields: GuestuserFields.getFields(context),
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Guestuser',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<GuestuserViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.createEntity(formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
// 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 '../Guestuser_viewModel/Guestuser_view_model_screen.dart';
|
||||||
|
import 'Guestuser_update_entity_screen.dart';
|
||||||
|
|
||||||
|
class GuestuserDetailsScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
const GuestuserDetailsScreen({
|
||||||
|
super.key,
|
||||||
|
required this.entity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<GuestuserDetailsScreen> createState() => _GuestuserDetailsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GuestuserDetailsScreenState extends State<GuestuserDetailsScreen> {
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => GuestuserViewModelScreen(),
|
||||||
|
child: GuestuserUpdateEntityScreen(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 Guestuser?'),
|
||||||
|
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<GuestuserViewModelScreen>(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<GuestuserViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
return EntityDetails(
|
||||||
|
entity: widget.entity,
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
title: 'Guestuser',
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'fullname', 'label': 'fullName', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||||
|
|
||||||
|
{'key': 'macaddress', 'label': 'macAddress', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'email', 'label': 'email', 'type': 'email'},
|
||||||
|
|
||||||
|
{'key': 'mob_no', 'label': 'Mob No', 'type': 'phone'},
|
||||||
|
|
||||||
|
{'key': 'dateofbirth', 'label': 'dateofbirth', 'type': 'date'},
|
||||||
|
|
||||||
|
{'key': 'driving_license_no', 'label': 'driving license no', 'type': 'text'},
|
||||||
|
|
||||||
|
],
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
// 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 'Guestuser_create_entity_screen.dart';
|
||||||
|
import 'Guestuser_update_entity_screen.dart';
|
||||||
|
import '../Guestuser_viewModel/Guestuser_view_model_screen.dart';
|
||||||
|
import 'Guestuser_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 Guestuser_entity_list_screen extends StatefulWidget {
|
||||||
|
static const String routeName = '/entity-list';
|
||||||
|
|
||||||
|
@override
|
||||||
|
_Guestuser_entity_list_screenState createState() => _Guestuser_entity_list_screenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Guestuser_entity_list_screenState extends State<Guestuser_entity_list_screen> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadData() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
final vm = Provider.of<GuestuserViewModelScreen>(context, listen: false);
|
||||||
|
vm.getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToCreateScreen() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => GuestuserViewModelScreen(),
|
||||||
|
child: const GuestuserCreateEntityScreen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<GuestuserViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUpdateScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => GuestuserViewModelScreen(),
|
||||||
|
child: GuestuserUpdateEntityScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
final vm = Provider.of<GuestuserViewModelScreen>(context, listen: false);
|
||||||
|
vm.refreshData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDetailsScreen(Map<String, dynamic> entity) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => GuestuserViewModelScreen(),
|
||||||
|
child: GuestuserDetailsScreen(entity: entity),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog(Map<String, dynamic> entity) {
|
||||||
|
final parentContext = context;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text('Are you sure you want to delete this Guestuser?'),
|
||||||
|
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<GuestuserViewModelScreen>(parentContext, listen: false);
|
||||||
|
await vm.deleteEntity(entity['id']);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<GuestuserViewModelScreen>(
|
||||||
|
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.searchguestuser(query),
|
||||||
|
onEdit: (entity) => _navigateToUpdateScreen(entity),
|
||||||
|
onDelete: (entity) => _showDeleteDialog(entity),
|
||||||
|
onTap: (entity) => _navigateToDetailsScreen(entity),
|
||||||
|
onRefresh: () => viewModel.refreshData(),
|
||||||
|
onLoadMore: () => viewModel.getAllWithPagination(),
|
||||||
|
title: 'Guestuser',
|
||||||
|
onAddNew: _navigateToCreateScreen,
|
||||||
|
displayFields: [
|
||||||
|
{'key': 'fullname', 'label': 'fullName', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'active', 'label': 'Active', 'type': 'toggle_switch'},
|
||||||
|
|
||||||
|
{'key': 'macaddress', 'label': 'macAddress', 'type': 'text'},
|
||||||
|
|
||||||
|
{'key': 'email', 'label': 'email', 'type': 'email'},
|
||||||
|
|
||||||
|
{'key': 'mob_no', 'label': 'Mob No', 'type': 'phone'},
|
||||||
|
|
||||||
|
{'key': 'dateofbirth', 'label': 'dateofbirth', 'type': 'date'},
|
||||||
|
|
||||||
|
{'key': 'driving_license_no', 'label': 'driving license no', 'type': 'text'},
|
||||||
|
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
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 '../../../../BuilderField/shared/fields/currency_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/field_group_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/qr_code_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/barcode_field.dart';
|
||||||
|
import '../../../../BuilderField/shared/fields/dependent_dropdown_field.dart';
|
||||||
|
import '../Guestuser_viewModel/Guestuser_view_model_screen.dart';/// Field definitions for Guestuser entity
|
||||||
|
/// This defines the structure and validation for Guestuser forms
|
||||||
|
class GuestuserFields {
|
||||||
|
/// Get field definitions for Guestuser entity
|
||||||
|
static List<BaseField> getFields(BuildContext context) {
|
||||||
|
final viewModel =
|
||||||
|
Provider.of<GuestuserViewModelScreen>(context, listen: false);
|
||||||
|
return [
|
||||||
|
// Basic Information
|
||||||
|
CustomTextField(
|
||||||
|
fieldKey: 'fullname',
|
||||||
|
label: 'fullName',
|
||||||
|
hint: 'Enter fullName',
|
||||||
|
isRequired: true,
|
||||||
|
maxLength: 50,
|
||||||
|
),
|
||||||
|
|
||||||
|
SwitchField(
|
||||||
|
fieldKey: 'active',
|
||||||
|
label: 'Active',
|
||||||
|
),
|
||||||
|
|
||||||
|
CustomTextField(
|
||||||
|
fieldKey: 'macaddress',
|
||||||
|
label: 'macAddress',
|
||||||
|
hint: 'Enter macAddress',
|
||||||
|
isRequired: true,
|
||||||
|
maxLength: 50,
|
||||||
|
),
|
||||||
|
|
||||||
|
EmailField(
|
||||||
|
fieldKey: 'email',
|
||||||
|
label: 'email',
|
||||||
|
hint: 'Enter email',
|
||||||
|
isRequired: false,
|
||||||
|
),
|
||||||
|
|
||||||
|
PhoneField(
|
||||||
|
fieldKey: 'mob_no',
|
||||||
|
label: 'Mob No',
|
||||||
|
hint: 'Enter Mob No',
|
||||||
|
isRequired: false,
|
||||||
|
countryCode: '+91',
|
||||||
|
),
|
||||||
|
|
||||||
|
DateField(
|
||||||
|
fieldKey: 'dateofbirth',
|
||||||
|
label: 'dateofbirth',
|
||||||
|
hint: 'Select dateofbirth',
|
||||||
|
isRequired: false,
|
||||||
|
),
|
||||||
|
|
||||||
|
CustomTextField(
|
||||||
|
fieldKey: 'driving_license_no',
|
||||||
|
label: 'driving license no',
|
||||||
|
hint: 'Enter driving license no',
|
||||||
|
isRequired: true,
|
||||||
|
maxLength: 50,
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../Guestuser_viewModel/Guestuser_view_model_screen.dart';
|
||||||
|
import 'package:base_project/BuilderField/shared/ui/entity_screens.dart';
|
||||||
|
import 'Guestuser_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 GuestuserUpdateEntityScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic> entity;
|
||||||
|
|
||||||
|
|
||||||
|
GuestuserUpdateEntityScreen({required this.entity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_GuestuserUpdateEntityScreenState createState() => _GuestuserUpdateEntityScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GuestuserUpdateEntityScreenState extends State<GuestuserUpdateEntityScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<GuestuserViewModelScreen>(
|
||||||
|
builder: (context, viewModel, child) {
|
||||||
|
// Start with all fields, then remove upload fields (generic filter by keys)
|
||||||
|
final Set<String> hiddenKeys = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
final fields = GuestuserFields.getFields(context)
|
||||||
|
.where((f) => !hiddenKeys.contains(f.fieldKey))
|
||||||
|
.toList(); return EntityUpdateScreen(
|
||||||
|
fields: fields,
|
||||||
|
initialData: widget.entity,
|
||||||
|
onSubmit: (data) => _handleSubmit(data),
|
||||||
|
title: 'Guestuser',
|
||||||
|
isLoading: viewModel.isLoading,
|
||||||
|
errorMessage:
|
||||||
|
viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleSubmit(Map<String, dynamic> formData) async {
|
||||||
|
final provider =
|
||||||
|
Provider.of<GuestuserViewModelScreen>(context, listen: false);
|
||||||
|
final success = await provider.updateEntity(widget.entity['id'], formData);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
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 GuestuserRepoScreen {
|
||||||
|
|
||||||
|
final String baseUrl = ApiConstants.baseUrl;
|
||||||
|
final BaseNetworkService _helper = NetworkApiService();
|
||||||
|
final String _endpointPath = '/Guestuser/Guestuser';
|
||||||
|
|
||||||
|
Future<ApiResponse<List<Map<String, dynamic>>>> getEntities() async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _helper.getGetApiResponse('$baseUrl$_endpointPath');
|
||||||
|
print('Response received: $response');
|
||||||
|
List<Map<String, dynamic>> entities = const [];
|
||||||
|
if (response is List) {
|
||||||
|
entities = response
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
} else if (response is Map<String, dynamic>) {
|
||||||
|
final dynamic content = response['content'];
|
||||||
|
if (content is List) {
|
||||||
|
entities = content
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ApiResponse.success(entities);
|
||||||
|
} catch (e) {
|
||||||
|
print(' error got $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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,369 @@
|
|||||||
|
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 '../Guestuser_Repo/Guestuser_repo_screen.dart';
|
||||||
|
|
||||||
|
class GuestuserViewModelScreen extends ChangeNotifier{
|
||||||
|
final GuestuserRepoScreen repo = GuestuserRepoScreen();
|
||||||
|
|
||||||
|
|
||||||
|
// State variables
|
||||||
|
List<Map<String, dynamic>> _guestuserList = [];
|
||||||
|
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 guestuserList => _guestuserList;
|
||||||
|
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 guestuser list
|
||||||
|
Future<void> getEntities() async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.getEntities();
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
_guestuserList = response.data ?? [];
|
||||||
|
_filteredList = List.from(_guestuserList);
|
||||||
|
_currentPage = 0;
|
||||||
|
_hasMoreData = true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch guestuser list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch guestuser list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get guestuser list with pagination
|
||||||
|
Future<void> getAllWithPagination({bool refresh = false}) async {
|
||||||
|
if (refresh) {
|
||||||
|
_currentPage = 0;
|
||||||
|
_guestuserList.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) {
|
||||||
|
_guestuserList = newItems;
|
||||||
|
} else {
|
||||||
|
_guestuserList.addAll(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filteredList = List.from(_guestuserList);
|
||||||
|
_currentPage++;
|
||||||
|
|
||||||
|
// Check if we have more data
|
||||||
|
_hasMoreData = newItems.length == _pageSize;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to fetch Guestuser list');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to fetch guestuser list: $e');
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create Guestuser
|
||||||
|
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: 'guestuser created successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Refresh the list
|
||||||
|
await getEntities();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to create Guestuser');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to create Guestuser',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to create guestuser: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to create Guestuser: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update guestuser
|
||||||
|
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: 'Guestuser updated successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the item in the list
|
||||||
|
final index = _guestuserList.indexWhere((item) => item['id'] == id);
|
||||||
|
if (index != -1) {
|
||||||
|
_guestuserList[index] = response.data!;
|
||||||
|
_filteredList = List.from(_guestuserList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to update Guestuser');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to update Guestuser',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to update guestuser: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to update Guestuser: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete guestuser
|
||||||
|
Future<bool> deleteEntity(int id) async {
|
||||||
|
_setLoading(true);
|
||||||
|
_setError('');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await repo.deleteEntity(id);
|
||||||
|
|
||||||
|
if (response.status == Status.SUCCESS) {
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Guestuser deleted successfully',
|
||||||
|
toastType: ToastType.success,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove the item from the list
|
||||||
|
_guestuserList.removeWhere((item) => item['id'] == id);
|
||||||
|
_filteredList = List.from(_guestuserList);
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_setError(response.message ?? 'Failed to delete Guestuser');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: response.message ?? 'Failed to delete Guestuser',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_setError('Failed to delete guestuser: $e');
|
||||||
|
ToastMessageUtil.showToast(
|
||||||
|
message: 'Failed to delete Guestuser: $e',
|
||||||
|
toastType: ToastType.error,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
_setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search guestuser
|
||||||
|
void searchguestuser(String query) {
|
||||||
|
_searchQuery = query;
|
||||||
|
|
||||||
|
if (query.isEmpty) {
|
||||||
|
_filteredList = List.from(_guestuserList);
|
||||||
|
} else {
|
||||||
|
_filteredList = _guestuserList.where((item) {
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
(item['fullname']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
(item['active']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['macaddress']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['email']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['mob_no']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['dateofbirth']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) ||
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(item['driving_license_no']?.toString().toLowerCase().contains(query.toLowerCase()) ??false)
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear search
|
||||||
|
void clearSearch() {
|
||||||
|
_searchQuery = '';
|
||||||
|
_filteredList = List.from(_guestuserList);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh data
|
||||||
|
Future<void> refreshData() async {
|
||||||
|
await getAllWithPagination(refresh: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,3 +1,10 @@
|
|||||||
|
import '../../Entity/taxi_rental/Guestuser/GuestuserView/Guestuser_entity_list_screen.dart';
|
||||||
|
import '../../Entity/taxi_rental/Guestuser/Guestuser_viewModel/Guestuser_view_model_screen.dart';
|
||||||
|
|
||||||
|
import '../../Entity/taxi_rental/Coupon/CouponView/Coupon_entity_list_screen.dart';
|
||||||
|
import '../../Entity/taxi_rental/Coupon/Coupon_viewModel/Coupon_view_model_screen.dart';
|
||||||
|
|
||||||
|
|
||||||
import '../../Entity/taxi_rental/Products/ProductsView/Products_entity_list_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/Products/Products_viewModel/Products_view_model_screen.dart';
|
||||||
|
|
||||||
@ -116,21 +123,57 @@ Navigator.pushNamed(context, RouteNames.changePasswordView);
|
|||||||
// NEW MENU
|
// NEW MENU
|
||||||
DrawerItem(
|
DrawerItem(
|
||||||
icon: Icons.data_object,
|
icon: Icons.data_object,
|
||||||
title: 'Products Management',
|
title: 'Guestuser Management',
|
||||||
subtitle: 'Manage Products entities',
|
subtitle: 'Manage Guestuser entities',
|
||||||
onTap: (context) {
|
onTap: (context) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => ChangeNotifierProvider(
|
builder: (context) => ChangeNotifierProvider(
|
||||||
create: (context) => ProductsViewModelScreen(),
|
create: (context) => GuestuserViewModelScreen(),
|
||||||
child: Products_entity_list_screen(),
|
child: Guestuser_entity_list_screen(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
DrawerItem(
|
||||||
|
icon: Icons.data_object,
|
||||||
|
title: 'Coupon Management',
|
||||||
|
subtitle: 'Manage Coupon entities',
|
||||||
|
onTap: (context) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => CouponViewModelScreen(),
|
||||||
|
child: Coupon_entity_list_screen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DrawerItem(
|
||||||
|
icon: Icons.data_object,
|
||||||
|
title: 'Products Management',
|
||||||
|
subtitle: 'Manage Products entities',
|
||||||
|
onTap: (context) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ChangeNotifierProvider(
|
||||||
|
create: (context) => ProductsViewModelScreen(),
|
||||||
|
child: Products_entity_list_screen(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
DrawerItem(
|
DrawerItem(
|
||||||
icon: Icons.data_object,
|
icon: Icons.data_object,
|
||||||
title: 'Rides Management',
|
title: 'Rides Management',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user