Clowiz - The Cloud Wizard Home Tutorial User Guide Page Help Login
FeatureGen

Preview of (Clowiz Page)

Clowiz Page Form


  • Mature Spring RestController
    			package com.app.controller; 
    
    import java.util.*;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.http.*;
    import org.springframework.web.bind.annotation.*;
    
    import com.app.models.ClowizPage;
    import com.app.repositories.ClowizPageRepository;
    
    @RestController
    @RequestMapping("/clowiz_page")
    public class ClowizPageController {
    
    	@Autowired
    	ClowizPageRepository clowizPageRepo;
    
    	@RequestMapping(method = RequestMethod.OPTIONS)
    	ResponseEntity<?> options() {
    	  // @formatter:off
    	  return ResponseEntity.ok().allow(
    		       HttpMethod.GET,
    		       HttpMethod.POST,
    		       HttpMethod.HEAD,
    		       HttpMethod.OPTIONS,
    		       HttpMethod.PUT,
    		       HttpMethod.DELETE).
    		       build(); 
    	  // @formatter:on
    	}
    
    	@GetMapping
    	public ResponseEntity<List<ClowizPage>> getAll() {
    		return ResponseEntity.ok(this.clowizPageRepo.findAll());
    	}
    
    	@PostMapping
    	public ResponseEntity<ClowizPage> insert(@RequestBody ClowizPage clowizPage) {
    		ClowizPage save = this.clowizPageRepo.save(clowizPage);
    		return ResponseEntity.ok(save);
    	}
    
    	@GetMapping(value = "/{id}")
    	public ResponseEntity<ClowizPage> find(@PathVariable("id") int id) {
    		Optional<ClowizPage> object = this.clowizPageRepo.findById(id);
    		if (object.isPresent()) {
    			return ResponseEntity.ok(object.get());
    		}
    		return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
    	}
    
    	@DeleteMapping(value="/{id}")
    	public ResponseEntity<ClowizPage> delete(@PathVariable int id){
    		Optional<ClowizPage> object = this.clowizPageRepo.findById(id);
    		if(object.isPresent()) {
    			this.clowizPageRepo.deleteById(id);
    			return ResponseEntity.noContent().build();
    		}
    		return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
    	}
    
    	@PutMapping(value="/{id}")
    	public ResponseEntity<ClowizPage> save(@PathVariable int id, @RequestBody ClowizPage clowizPage){
    		Optional<ClowizPage> object = this.clowizPageRepo.findById(id);
    		if(object.isPresent()) {
    			clowizPage.setId(id);
    			this.clowizPageRepo.save(clowizPage);
    			return ResponseEntity.noContent().build();
    		}
    		return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
    	}
    }
    
    		
  • JPA Entity
    			package com.app.models;
    
    import javax.persistence.*;
    @Entity
    @Table(name="clowiz_page")
    public class ClowizPage{
    
      @Id
      @Column(name="id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      Integer id;
    
    
      public void setId(Integer id){
        this.id=id;
      }
    
      public Integer getId(){
       return this.id;
      }
      @Override
      public String toString(){
        StringBuffer buf=new StringBuffer();
        buf.append(this.id).append(" ");
        return buf.toString();
      }
    
      @Override
      public boolean equals(Object obj) {
        if (obj == null) {
    	  return false;
        }
        return this.getId() == ((ClowizPage) obj).getId();
      }
    
    }
    
    		
  • SpringData Service
    			package com.app.repositories;
    
    import java.util.List;
    import org.springframework.data.jpa.repository.JpaRepository;
    import org.springframework.stereotype.Service;
    import com.app.models.ClowizPage;
    
    @Service
    public interface ClowizPageService extends JpaRepository<ClowizPage, Integer> {
    }