Skip to content

Commit

Permalink
feat : fixes entities
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli authored Oct 28, 2023
1 parent a126788 commit 3434875
Show file tree
Hide file tree
Showing 9 changed files with 429 additions and 455 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.example.archunit;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan({"com.example.archunit"})
public class ExampleArchunitApplication {

public static void main(String[] args) {
SpringApplication.run(ExampleArchunitApplication.class, args);
}
}
package com.example.archunit;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ExampleArchUnitApplication {

public static void main(String[] args) {
SpringApplication.run(ExampleArchUnitApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
package com.example.archunit.controller;

import com.example.archunit.service.ClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/client")
public class ClientController {

ClientService clientService;

@Autowired
public ClientController(ClientService clientService) {
this.clientService = clientService;
}

@DeleteMapping(value = "/{id}")
public @ResponseBody ResponseEntity<Boolean> delete(@PathVariable("id") Long id) {
return new ResponseEntity<>(clientService.delete(id), HttpStatus.OK);
}
}
package com.example.archunit.controller;

import com.example.archunit.service.ClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/client")
public class ClientController {

private final ClientService clientService;

@Autowired
public ClientController(ClientService clientService) {
this.clientService = clientService;
}

@DeleteMapping(value = "/{id}")
public @ResponseBody ResponseEntity<Boolean> delete(@PathVariable("id") Long id) {
return new ResponseEntity<>(clientService.delete(id), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
package com.example.archunit.model;

import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Version;
import java.io.Serializable;
import java.util.Objects;

@MappedSuperclass
public abstract class Base implements Serializable {

private static final long serialVersionUID = -2053886894431223968L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Version
@Column(nullable = false)
private Integer version;

@Column(nullable = false, columnDefinition = "boolean default true")
private Boolean active = Boolean.TRUE;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Integer getVersion() {
return version;
}

public void setVersion(Integer version) {
this.version = version;
}

public Boolean getActive() {
return active;
}

public void setActive(Boolean active) {
this.active = active;
}

@Override
public int hashCode() {
return Objects.hash(id, active, version);
}

@Override
public boolean equals(Object obj) {
return Objects.equals(this, obj);
}
}
package com.example.archunit.model;

import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Version;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

@MappedSuperclass
public abstract class Base implements Serializable {

@Serial protected static final long serialVersionUID = -2053886894431223968L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;

@Version
@Column(nullable = false)
private Integer version;

@Column(nullable = false, columnDefinition = "boolean default true")
private Boolean active = Boolean.TRUE;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Integer getVersion() {
return version;
}

public void setVersion(Integer version) {
this.version = version;
}

public Boolean getActive() {
return active;
}

public void setActive(Boolean active) {
this.active = active;
}

@Override
public int hashCode() {
return Objects.hash(id, active, version);
}

@Override
public boolean equals(Object obj) {
return Objects.equals(this, obj);
}
}
Loading

0 comments on commit 3434875

Please sign in to comment.