build_app
This commit is contained in:
parent
33633f1547
commit
50b3c4110b
@ -69,6 +69,9 @@ public class BuilderService {
|
||||
executeDump(true);
|
||||
|
||||
// ADD OTHER SERVICE
|
||||
addCustomMenu( "Emp_details", "Transcations");
|
||||
|
||||
|
||||
|
||||
System.out.println("dashboard and menu inserted...");
|
||||
|
||||
|
||||
@ -0,0 +1,299 @@
|
||||
package com.realnet.vpspack.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.vpspack.Entity.Emp_details;
|
||||
import com.realnet.vpspack.Services.Emp_detailsService ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Emp_details")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Emp_detailsController {
|
||||
@Autowired
|
||||
private Emp_detailsService Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Emp_details")
|
||||
public Emp_details Savedata(@RequestBody Emp_details data) {
|
||||
Emp_details save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Emp_details/{id}")
|
||||
public Emp_details update(@RequestBody Emp_details data,@PathVariable Integer id ) {
|
||||
Emp_details update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Emp_details/getall/page")
|
||||
public Page<Emp_details> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Emp_details> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Emp_details")
|
||||
public List<Emp_details> getdetails() {
|
||||
List<Emp_details> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Emp_details")
|
||||
public List<Emp_details> getallwioutsec() {
|
||||
List<Emp_details> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Emp_details/{id}")
|
||||
public Emp_details getdetailsbyId(@PathVariable Integer id ) {
|
||||
Emp_details get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Emp_details/{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,150 @@
|
||||
package com.realnet.vpspack.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Emp_details extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String first_name;
|
||||
|
||||
private int numbera;
|
||||
|
||||
private String phone_number;
|
||||
|
||||
|
||||
@Column(length = 2000)
|
||||
private String paragraph_field;
|
||||
|
||||
private String password_field;
|
||||
@Transient
|
||||
private String confirmpassword_field;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String textarea_field;
|
||||
|
||||
private String date_field;
|
||||
|
||||
private String datetime_field;
|
||||
|
||||
private String email_field;
|
||||
|
||||
private boolean toggle_switch;
|
||||
|
||||
private String url_field;
|
||||
|
||||
private int decimal_field;
|
||||
|
||||
private int percentage_field;
|
||||
|
||||
private String recaptcha;
|
||||
|
||||
private String documentsequence;
|
||||
|
||||
private String selectsta;
|
||||
|
||||
private String radios;
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean q;
|
||||
|
||||
|
||||
|
||||
private boolean b;
|
||||
|
||||
|
||||
|
||||
private String fileupload_fieldname;
|
||||
private String fileupload_fieldpath ;
|
||||
|
||||
private String imageupload_fieldname;
|
||||
private String imageupload_fieldpath ;
|
||||
|
||||
private String audio_fieldname;
|
||||
private String audio_fieldpath ;
|
||||
|
||||
private String video_fieldname;
|
||||
private String video_fieldpath ;
|
||||
|
||||
private String survey_form;
|
||||
|
||||
private String currency;
|
||||
|
||||
private String qrcode_field;
|
||||
|
||||
private String barcode_field;
|
||||
|
||||
private int numberb;
|
||||
|
||||
private String calculatedadd;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.realnet.vpspack.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.vpspack.Entity.Emp_details;
|
||||
|
||||
@Repository
|
||||
public interface Emp_detailsRepository extends JpaRepository<Emp_details, Integer> {
|
||||
|
||||
@Query(value = "select * from emp_details where created_by=?1", nativeQuery = true)
|
||||
List<Emp_details> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from emp_details where created_by=?1", nativeQuery = true)
|
||||
Page<Emp_details> findAll(Pageable page, Long creayedBy);
|
||||
}
|
||||
@ -0,0 +1,354 @@
|
||||
package com.realnet.vpspack.Services;
|
||||
import com.realnet.vpspack.Repository.Emp_detailsRepository;
|
||||
import com.realnet.vpspack.Entity.Emp_details
|
||||
;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 Emp_detailsService {
|
||||
@Autowired
|
||||
private Emp_detailsRepository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private SequenceService documentsequencesequenceService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Emp_details Savedata(Emp_details data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setDocumentsequence (documentsequencesequenceService.GenerateSequence("aa"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Emp_details save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Emp_details> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll(page, getUser().getUserId());
|
||||
}
|
||||
public List<Emp_details> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Emp_details> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Emp_details getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Emp_details update(Emp_details data,Integer id) {
|
||||
Emp_details old = Repository.findById(id).get();
|
||||
old.setFirst_name(data.getFirst_name());
|
||||
|
||||
old.setNumbera(data.getNumbera());
|
||||
|
||||
old.setPhone_number(data.getPhone_number());
|
||||
|
||||
old.setParagraph_field(data.getParagraph_field());
|
||||
|
||||
old.setPassword_field(data.getPassword_field());
|
||||
|
||||
old.setTextarea_field(data.getTextarea_field());
|
||||
|
||||
old.setDate_field(data.getDate_field());
|
||||
|
||||
old.setDatetime_field(data.getDatetime_field());
|
||||
|
||||
old.setEmail_field(data.getEmail_field());
|
||||
|
||||
old.setToggle_switch (data.isToggle_switch());
|
||||
|
||||
old.setUrl_field(data.getUrl_field());
|
||||
|
||||
old.setDecimal_field(data.getDecimal_field());
|
||||
|
||||
old.setPercentage_field(data.getPercentage_field());
|
||||
|
||||
old.setRecaptcha(data.getRecaptcha());
|
||||
|
||||
old.setDocumentsequence(data.getDocumentsequence());
|
||||
|
||||
old.setSelectsta(data.getSelectsta());
|
||||
|
||||
old.setRadios(data.getRadios());
|
||||
|
||||
|
||||
|
||||
old.setQ(data.isQ());
|
||||
|
||||
|
||||
|
||||
old.setB(data.isB());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
old.setSurvey_form(data.getSurvey_form());
|
||||
|
||||
old.setCurrency(data.getCurrency());
|
||||
|
||||
old.setQrcode_field(data.getQrcode_field());
|
||||
|
||||
old.setBarcode_field(data.getBarcode_field());
|
||||
|
||||
old.setNumberb(data.getNumberb());
|
||||
|
||||
old.setCalculatedadd(data.getCalculatedadd());
|
||||
|
||||
final Emp_details test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
2
testingflutter104-db-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
2
testingflutter104-db-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
@ -0,0 +1,2 @@
|
||||
CREATE TABLE db.Emp_details(id BIGINT NOT NULL AUTO_INCREMENT, video_field VARCHAR(400), b bit(1), qrcode_field VARCHAR(400), datetime_field VARCHAR(400), phone_number VARCHAR(400), radios VARCHAR(400), fileupload_field VARCHAR(400), q bit(1), textarea_field VARCHAR(400), currency VARCHAR(400), recaptcha VARCHAR(400), date_field Date, selectsta VARCHAR(400), barcode_field VARCHAR(400), numberb int, first_name VARCHAR(400), numbera int, toggle_switch VARCHAR(400), percentage_field int, email_field VARCHAR(400), calculatedadd VARCHAR(400), url_field VARCHAR(400), survey_form VARCHAR(400), paragraph_field VARCHAR(400), imageupload_field VARCHAR(400), audio_field VARCHAR(400), password_field VARCHAR(400), decimal_field int, documentsequence VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
@ -0,0 +1,184 @@
|
||||
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 emp_detailsApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Emp_details/Emp_details');
|
||||
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/Emp_details/Emp_details/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/Emp_details/Emp_details', 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/Emp_details/Emp_details/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Emp_details/Emp_details/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,154 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../../../data/network/base_network_service.dart';
|
||||
import '../../../../data/network/network_api_service.dart';
|
||||
import '../../../../resources/api_constants.dart';
|
||||
|
||||
class Emp_detailsRepoScreen {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
Future<dynamic> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Emp_details/Emp_details');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getAllWithPagination(int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl/Emp_details/Emp_details/getall/page?page=$page&size=$size');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> createEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response = await _helper.getPostApiResponse(
|
||||
'$baseUrl/Emp_details/Emp_details', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateEntity(int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse(
|
||||
'$baseUrl/Emp_details/Emp_details/$entityId', entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper
|
||||
.getDeleteApiResponse('$baseUrl/Emp_details/Emp_details/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<dynamic> fileupload_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> imageupload_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload Imageupload Field: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> audio_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> video_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,366 @@
|
||||
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 'package:flutter/material.dart';
|
||||
import '../Emp_details_Repo/Emp_details_repo_screen.dart';
|
||||
|
||||
class Emp_detailsViewModelScreen extends ChangeNotifier{
|
||||
final Emp_detailsRepoScreen repo = Emp_detailsRepoScreen();
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
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 repo.getAllWithPagination(page, size); // ✅ Use await
|
||||
|
||||
print('with pagination res - $response');
|
||||
|
||||
// ✅ Ensure response is a Map<String, dynamic>
|
||||
if (response is! Map<String, dynamic>) {
|
||||
throw Exception('Unexpected response format: $response');
|
||||
}
|
||||
|
||||
// ✅ Extract 'content' and ensure it's a list
|
||||
final entities = (response['content'] as List)
|
||||
.cast<Map<String, dynamic>>() // ✅ Ensure list of maps
|
||||
.toList();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
print(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");
|
||||
// Wait for API response
|
||||
final responseData =
|
||||
await repo.createEntity(entity) as Map<String, dynamic>;
|
||||
print('after value - $responseData');
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Added Successfully", toastType: ToastType.success);
|
||||
|
||||
return responseData; // Return the data AFTER it is received
|
||||
} catch (error) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Got Error", toastType: ToastType.error);
|
||||
|
||||
throw Exception(
|
||||
'Failed to Create Entity: $error'); // Properly rethrow the error
|
||||
}
|
||||
}
|
||||
Future<void> updateEntity(int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
repo.updateEntity(entityId, entity).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Updated Successfully", toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Got Error", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity(int entityId) async {
|
||||
try {
|
||||
repo.deleteEntity(entityId).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Deleted Successfully", toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Got Error", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Modify the uploadfileupload_fieldimage function
|
||||
Future<void> uploadfileupload_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List imageTimageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = imageTimageBytes!;
|
||||
final mimeType = fileupload_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
await repo.fileupload_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String fileupload_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last;
|
||||
switch (ext) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadimageupload_fieldimage function
|
||||
Future<void> uploadimageupload_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = imageupload_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
await repo.imageupload_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String imageupload_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last;
|
||||
switch (ext) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadaudio_fieldimage function
|
||||
Future<void> uploadaudio_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = audio_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
await repo.audio_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String audio_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last.toLowerCase();
|
||||
switch (ext) {
|
||||
case 'mp3':
|
||||
return 'audio/mpeg';
|
||||
case 'wav':
|
||||
return 'audio/wav';
|
||||
case 'm4a':
|
||||
return 'audio/mp4';
|
||||
case 'flac':
|
||||
return 'audio/flac';
|
||||
// Add more cases for other audio formats as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadvideo_fieldimage function
|
||||
Future<void> uploadvideo_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = video_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
|
||||
await repo.video_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String video_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last.toLowerCase();
|
||||
switch (ext) {
|
||||
case 'mp4':
|
||||
return 'video/mp4';
|
||||
case 'mov':
|
||||
return 'video/quicktime';
|
||||
case 'avi':
|
||||
return 'video/x-msvideo';
|
||||
case 'wmv':
|
||||
return 'video/x-ms-wmv';
|
||||
case 'flv':
|
||||
return 'video/x-flv';
|
||||
case 'mkv':
|
||||
return 'video/x-matroska';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,3 +1,6 @@
|
||||
import '../../Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_entity_list_screen.dart';
|
||||
import '../../Entity/vpspack/Emp_details/Emp_details_viewModel/Emp_details_view_model_screen.dart';
|
||||
|
||||
import 'package:base_project/utils/image_constant.dart';
|
||||
import 'package:base_project/commans/widgets/custome_drawe_item.dart';
|
||||
import 'package:base_project/resources/app_colors.dart';
|
||||
@ -9,79 +12,96 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyCustomDrawer extends StatelessWidget {
|
||||
const MyCustomDrawer({super.key});
|
||||
const MyCustomDrawer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final email = UserManager().email;
|
||||
final userName = UserManager().userName;
|
||||
final provider = Provider.of<ProfileViewModel>(context, listen: false);
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
UserAccountsDrawerHeader(
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColors.primary,
|
||||
),
|
||||
currentAccountPicture: CircleAvatar(
|
||||
radius: 60,
|
||||
backgroundColor: AppColors.primary.withOpacity(0.3),
|
||||
backgroundImage: provider.profileImageBytes != null
|
||||
? MemoryImage(provider.profileImageBytes!)
|
||||
: null,
|
||||
child: provider.profileImageBytes != null
|
||||
? null // Use backgroundImage for the actual image, so child should be null
|
||||
: SvgPicture.asset(
|
||||
ImageConstant.userProfileImg, // Placeholder SVG asset
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final email = UserManager().email;
|
||||
final userName = UserManager().userName;
|
||||
final provider = Provider.of<ProfileViewModel>(context, listen: false);
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
UserAccountsDrawerHeader(
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColors.primary,
|
||||
),
|
||||
currentAccountPicture: CircleAvatar(
|
||||
radius: 60,
|
||||
backgroundColor: AppColors.primary.withOpacity(0.3),
|
||||
backgroundImage: provider.profileImageBytes != null
|
||||
? MemoryImage(provider.profileImageBytes!)
|
||||
: null,
|
||||
child: provider.profileImageBytes != null
|
||||
? null // Use backgroundImage for the actual image, so child should be null
|
||||
: SvgPicture.asset(
|
||||
ImageConstant.userProfileImg, // Placeholder SVG asset
|
||||
|
||||
// AppImages.userProfileImg, // Placeholder SVG asset
|
||||
width: 60, // Adjust to fit the CircleAvatar
|
||||
height: 60,
|
||||
),
|
||||
),
|
||||
accountName: Text("Hello, $userName"),
|
||||
accountEmail: Text(email.toString()),
|
||||
),
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.person,
|
||||
title: 'Profile',
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, RouteNames.profileView);
|
||||
},
|
||||
),
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.system_security_update,
|
||||
title: 'System Parameters',
|
||||
onTap: () {
|
||||
width: 60, // Adjust to fit the CircleAvatar
|
||||
height: 60,
|
||||
),
|
||||
),
|
||||
accountName: Text("Hello, $userName"),
|
||||
accountEmail: Text(email.toString()),
|
||||
),
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.person,
|
||||
title: 'Profile',
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, RouteNames.profileView);
|
||||
},
|
||||
),
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.system_security_update,
|
||||
title: 'System Parameters',
|
||||
onTap: () {
|
||||
// Add navigation or other logic here
|
||||
Navigator.pushNamed(context, RouteNames.systemParamsView);
|
||||
},
|
||||
),
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.password,
|
||||
title: 'change password',
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, RouteNames.changePasswordView);
|
||||
},
|
||||
),
|
||||
Navigator.pushNamed(context, RouteNames.systemParamsView);
|
||||
},
|
||||
),
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.password,
|
||||
title: 'change password',
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, RouteNames.changePasswordView);
|
||||
},
|
||||
),
|
||||
|
||||
// NEW MENU
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.logout,
|
||||
color: Colors.red,
|
||||
title: 'Logout',
|
||||
onTap: () async {
|
||||
await UserManager().clearUser();
|
||||
Navigator.pushReplacementNamed(context, RouteNames.splashView);
|
||||
},
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.chat_bubble,
|
||||
title: 'Emp_details',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Emp_detailsViewModelScreen(),
|
||||
child: emp_details_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.logout,
|
||||
color: Colors.red,
|
||||
title: 'Logout',
|
||||
onTap: () async {
|
||||
await UserManager().clearUser();
|
||||
Navigator.pushReplacementNamed(context, RouteNames.splashView);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user