fixing ref files

This commit is contained in:
Azmat-7860
2026-10-19 16:35:26 +05:30
parent 8a6c273983
commit d418526c0d
3 changed files with 17 additions and 21 deletions
+2
View File
@@ -1 +1,3 @@
.DS_Store .DS_Store
/pack-spring-v1.0.json
/io8.ref
@@ -17,15 +17,16 @@ import org.springframework.web.bind.annotation.RestController;
import com.realnet.io8ref.Xyz.Entity.Xyz; import com.realnet.io8ref.Xyz.Entity.Xyz;
import com.realnet.io8ref.Xyz.Services.XyzService; import com.realnet.io8ref.Xyz.Services.XyzService;
@RequestMapping(value = "/xyz") @RequestMapping(value = { "/Xyz", "/xyz" })
@RestController @RestController
@CrossOrigin(origins = "*", maxAge = 3600)
public class XyzController { public class XyzController {
@Autowired @Autowired
private XyzService Service; private XyzService Service;
// add data // add data
@PostMapping("/Xyz") @PostMapping({ "/Xyz", "/xyz" })
public Xyz Savedata(@RequestBody Xyz data) { public Xyz Savedata(@RequestBody Xyz data) {
Xyz save = Service.Savedata(data); Xyz save = Service.Savedata(data);
@@ -33,7 +34,7 @@ public class XyzController {
} }
// get all // get all
@GetMapping("/Xyz") @GetMapping({ "/Xyz", "/xyz" })
public List<Xyz> getdetails() { public List<Xyz> getdetails() {
List<Xyz> get = Service.getdetails(); List<Xyz> get = Service.getdetails();
@@ -41,7 +42,7 @@ public class XyzController {
} }
// getby id // getby id
@GetMapping("/Xyz/{id}") @GetMapping({ "/Xyz/{id}", "/xyz/{id}" })
public Xyz getdetailsbyId(@PathVariable Long id) { public Xyz getdetailsbyId(@PathVariable Long id) {
Xyz get = Service.getdetailsbyId(id); Xyz get = Service.getdetailsbyId(id);
@@ -49,7 +50,7 @@ public class XyzController {
} }
// update by id // update by id
@PutMapping("/Xyz/{id}") @PutMapping({ "/Xyz/{id}", "/xyz/{id}" })
public Xyz update(@RequestBody Xyz data, @PathVariable Long id) { public Xyz update(@RequestBody Xyz data, @PathVariable Long id) {
Xyz update = Service.update(data, id); Xyz update = Service.update(data, id);
@@ -57,7 +58,7 @@ public class XyzController {
} }
// delete by id // delete by id
@DeleteMapping("/Xyz/{id}") @DeleteMapping({ "/Xyz/{id}", "/xyz/{id}" })
public ResponseEntity<?> delete_by_id(@PathVariable Long id) { public ResponseEntity<?> delete_by_id(@PathVariable Long id) {
Service.delete_by_id(id); Service.delete_by_id(id);
@@ -4,6 +4,7 @@ import com.realnet.io8ref.Xyz.Repository.XyzRepository;
import com.realnet.io8ref.Xyz.Entity.Xyz; import com.realnet.io8ref.Xyz.Entity.Xyz;
import java.util.List; import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -21,7 +22,7 @@ public class XyzService {
} }
public Xyz getdetailsbyId(Long id) { public Xyz getdetailsbyId(Long id) {
return Repository.findById(id).get(); return Repository.findById(id).orElse(null);
} }
public void delete_by_id(Long id) { public void delete_by_id(Long id) {
@@ -29,19 +30,11 @@ public class XyzService {
} }
public Xyz update(Xyz data, Long id) { public Xyz update(Xyz data, Long id) {
Xyz old = Repository.findById(id).get(); Xyz old = Repository.findById(id).orElse(null);
old.setName(data.getName()); if (old != null) {
old.setDescription(data.getDescription()); BeanUtils.copyProperties(data, old, "id");
old.setEmail(data.getEmail()); return Repository.save(old);
old.setPrice(data.getPrice()); }
old.setQuantity(data.getQuantity()); return null;
old.setDob(data.getDob());
old.setCreatedAt(data.getCreatedAt());
old.setActive(data.getActive());
old.setStatus(data.getStatus());
old.setTags(data.getTags());
old.setPhoto(data.getPhoto());
old.setCategoryId(data.getCategoryId());
return Repository.save(old);
} }
} }