-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a126788
commit 3434875
Showing
9 changed files
with
429 additions
and
455 deletions.
There are no files selected for viewing
26 changes: 12 additions & 14 deletions
26
.../archunit/ExampleArchunitApplication.java → .../archunit/ExampleArchUnitApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
56 changes: 28 additions & 28 deletions
56
boot-api-archunit-sample/src/main/java/com/example/archunit/controller/ClientController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
123 changes: 62 additions & 61 deletions
123
boot-api-archunit-sample/src/main/java/com/example/archunit/model/Base.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.