Added dataslate, weapon, and unikeyword classes with APIs to access them
This commit is contained in:
parent
a96d1057bb
commit
fb5584615c
237
src/main/java/com/warhammer/domain/Dataslate.java
Normal file
237
src/main/java/com/warhammer/domain/Dataslate.java
Normal file
@ -0,0 +1,237 @@
|
||||
package com.warhammer.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A dataslate.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "dataslate")
|
||||
public class Dataslate implements Serializable {
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMovement() {
|
||||
return movement;
|
||||
}
|
||||
|
||||
public void setMovement(String movement) {
|
||||
this.movement = movement;
|
||||
}
|
||||
|
||||
public String getWeaponSkill() {
|
||||
return weaponSkill;
|
||||
}
|
||||
|
||||
public void setWeaponSkill(String weaponSkill) {
|
||||
this.weaponSkill = weaponSkill;
|
||||
}
|
||||
|
||||
public String getBallisticSkill() {
|
||||
return ballisticSkill;
|
||||
}
|
||||
|
||||
public void setBallisticSkill(String ballisticSkill) {
|
||||
this.ballisticSkill = ballisticSkill;
|
||||
}
|
||||
|
||||
public Long getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(Long strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getToughness() {
|
||||
return toughness;
|
||||
}
|
||||
|
||||
public void setToughness(String toughness) {
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
public String getWounds() {
|
||||
return wounds;
|
||||
}
|
||||
|
||||
public void setWounds(String wounds) {
|
||||
this.wounds = wounds;
|
||||
}
|
||||
|
||||
public String getAttacks() {
|
||||
return attacks;
|
||||
}
|
||||
|
||||
public void setAttacks(String attacks) {
|
||||
this.attacks = attacks;
|
||||
}
|
||||
|
||||
public Integer getLeadership() {
|
||||
return leadership;
|
||||
}
|
||||
|
||||
public void setLeadership(Integer leadership) {
|
||||
this.leadership = leadership;
|
||||
}
|
||||
|
||||
public Integer getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(Integer save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public Integer getInvulnerable() {
|
||||
return invulnerable;
|
||||
}
|
||||
|
||||
public void setInvulnerable(Integer invulnerable) {
|
||||
this.invulnerable = invulnerable;
|
||||
}
|
||||
|
||||
public Integer getFeelNoPain() {
|
||||
return feelNoPain;
|
||||
}
|
||||
|
||||
public void setFeelNoPain(Integer feelNoPain) {
|
||||
this.feelNoPain = feelNoPain;
|
||||
}
|
||||
|
||||
public String getWargearOptions() {
|
||||
return wargearOptions;
|
||||
}
|
||||
|
||||
public void setWargearOptions(String wargearOptions) {
|
||||
this.wargearOptions = wargearOptions;
|
||||
}
|
||||
|
||||
public String getPsyker() {
|
||||
return psyker;
|
||||
}
|
||||
|
||||
public void setPsyker(String psyker) {
|
||||
this.psyker = psyker;
|
||||
}
|
||||
|
||||
public Set<Weapon> getWeapons() {
|
||||
return weapons;
|
||||
}
|
||||
|
||||
public void setWeapons(Set<Weapon> weapons) {
|
||||
this.weapons = weapons;
|
||||
}
|
||||
|
||||
public Set<UnitKeyword> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(Set<UnitKeyword> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public UnitArmy getUnitArmy() {
|
||||
return unitArmy;
|
||||
}
|
||||
|
||||
public void setUnitArmy(UnitArmy unitArmy) {
|
||||
this.unitArmy = unitArmy;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getOwnerLogin() {
|
||||
return ownerLogin;
|
||||
}
|
||||
|
||||
public void setOwnerLogin(String ownerLogin) {
|
||||
this.ownerLogin = ownerLogin;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@Column(name = "movement")
|
||||
private String movement;
|
||||
|
||||
@Column(name = "weapon_skill")
|
||||
private String weaponSkill;
|
||||
|
||||
@Column(name = "ballistic_skill")
|
||||
private String ballisticSkill;
|
||||
|
||||
@Column(name = "strength")
|
||||
private Long strength;
|
||||
|
||||
@Column(name = "toughness")
|
||||
private String toughness;
|
||||
|
||||
@Column(name = "wounds")
|
||||
private String wounds;
|
||||
|
||||
@Column(name = "attacks")
|
||||
private String attacks;
|
||||
|
||||
@Column(name = "leadership")
|
||||
private Integer leadership;
|
||||
|
||||
@Column(name = "save")
|
||||
private Integer save;
|
||||
|
||||
@Column(name = "invulnerable")
|
||||
private Integer invulnerable;
|
||||
|
||||
@Column(name = "feel_no_pain")
|
||||
private Integer feelNoPain;
|
||||
|
||||
@Lob
|
||||
@Column(name = "wargear_options")
|
||||
private String wargearOptions;
|
||||
|
||||
@Lob
|
||||
@Column(name = "psyker")
|
||||
private String psyker;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "dataslate_weapon",
|
||||
joinColumns = { @JoinColumn(name = "dataslate_id") },
|
||||
inverseJoinColumns = { @JoinColumn(name = "weapon_id") }
|
||||
)
|
||||
private Set<Weapon> weapons = new HashSet<>();
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "dataslate_keyword",
|
||||
joinColumns = { @JoinColumn(name = "dataslate_id") },
|
||||
inverseJoinColumns = { @JoinColumn(name = "keyword_id") }
|
||||
)
|
||||
private Set<UnitKeyword> keywords = new HashSet<>();
|
||||
|
||||
@ManyToOne
|
||||
private UnitArmy unitArmy;
|
||||
|
||||
@ManyToOne
|
||||
private User owner;
|
||||
|
||||
private String ownerLogin;
|
||||
}
|
@ -354,6 +354,10 @@ public class UnitArmy implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Army getArmy() {
|
||||
return this.army;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
59
src/main/java/com/warhammer/domain/UnitKeyword.java
Normal file
59
src/main/java/com/warhammer/domain/UnitKeyword.java
Normal file
@ -0,0 +1,59 @@
|
||||
package com.warhammer.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "unit_keyword")
|
||||
public class UnitKeyword implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "keyword")
|
||||
private String keyword;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "isFaction")
|
||||
private boolean isFaction;
|
||||
|
||||
@ManyToOne
|
||||
private User owner;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public boolean isFaction() {
|
||||
return isFaction;
|
||||
}
|
||||
|
||||
public void setFaction(boolean faction) {
|
||||
isFaction = faction;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
119
src/main/java/com/warhammer/domain/Weapon.java
Normal file
119
src/main/java/com/warhammer/domain/Weapon.java
Normal file
@ -0,0 +1,119 @@
|
||||
package com.warhammer.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "weapon")
|
||||
public class Weapon implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "weapon")
|
||||
private String weapon;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "range")
|
||||
private String range;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "strength")
|
||||
private String strength;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "armor_penetration")
|
||||
private String armorPenetration;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "damage")
|
||||
private String damage;
|
||||
|
||||
@Lob
|
||||
@Column(name = "abilities")
|
||||
private String abilities;
|
||||
|
||||
@ManyToOne
|
||||
private User owner;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public void setWeapon(String weapon) {
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
public String getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public void setRange(String range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(String strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getArmorPenetration() {
|
||||
return armorPenetration;
|
||||
}
|
||||
|
||||
public void setArmorPenetration(String armorPenetration) {
|
||||
this.armorPenetration = armorPenetration;
|
||||
}
|
||||
|
||||
public String getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(String damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public String getAbilities() {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
public void setAbilities(String abilities) {
|
||||
this.abilities = abilities;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.warhammer.repository;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Spring Data repository for Dataslate entity.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Repository
|
||||
public interface DataslateRepository extends JpaRepository<Dataslate, Long> {
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.warhammer.repository;
|
||||
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Spring Data repository for UnitKeyword entity.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Repository
|
||||
public interface UnitKeywordRepository extends JpaRepository<UnitKeyword, Long> {
|
||||
}
|
13
src/main/java/com/warhammer/repository/WeaponRepository.java
Normal file
13
src/main/java/com/warhammer/repository/WeaponRepository.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.warhammer.repository;
|
||||
|
||||
import com.warhammer.domain.Weapon;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Spring Data repository for Weapon entity.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Repository
|
||||
public interface WeaponRepository extends JpaRepository<Weapon, Long> {
|
||||
}
|
54
src/main/java/com/warhammer/service/DataslateService.java
Normal file
54
src/main/java/com/warhammer/service/DataslateService.java
Normal file
@ -0,0 +1,54 @@
|
||||
package com.warhammer.service;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface DataslateService {
|
||||
|
||||
/**
|
||||
* Save a dataslate
|
||||
*
|
||||
* @param dataslateDTO the entity to save.
|
||||
* @return the persisted entity
|
||||
*/
|
||||
DataslateDTO save(DataslateDTO dataslateDTO);
|
||||
|
||||
/**
|
||||
* Get all the Dataslates
|
||||
*
|
||||
* @return the list of the entities
|
||||
*/
|
||||
List<DataslateDTO> findAll();
|
||||
|
||||
/**
|
||||
* Get all the Dataslates for a user
|
||||
*
|
||||
* @param ownerLogin the owner to search for the dataslates of
|
||||
* @return List of Dataslates owned by Owner
|
||||
*/
|
||||
List<Dataslate> findAllByOwner(Optional <String> ownerLogin);
|
||||
|
||||
/**
|
||||
* Get all the Dataslates for an army
|
||||
*
|
||||
* @param id the id of the army
|
||||
* @return List of Dataslates by army
|
||||
*/
|
||||
List<DataslateDTO> findAllByArmy(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Optional<DataslateDTO> findOne(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void delete(Long id);
|
||||
}
|
47
src/main/java/com/warhammer/service/UnitKeywordService.java
Normal file
47
src/main/java/com/warhammer/service/UnitKeywordService.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.warhammer.service;
|
||||
|
||||
import com.warhammer.service.dto.UnitKeywordDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UnitKeywordService {
|
||||
|
||||
/**
|
||||
* Save a UnitKeyword
|
||||
*
|
||||
* @param unitKeywordDTO the entity to save.
|
||||
* @return the persisted entity
|
||||
*/
|
||||
UnitKeywordDTO save(UnitKeywordDTO unitKeywordDTO);
|
||||
|
||||
/**
|
||||
* Get all keywords
|
||||
*
|
||||
* @return the list of the keywords
|
||||
*/
|
||||
List<UnitKeywordDTO> findAll();
|
||||
|
||||
/**
|
||||
* Get all the keywords for a user
|
||||
*
|
||||
* @param ownerLogin the owner to search for the keywords of
|
||||
* @return List of keywords owned by Owner
|
||||
*/
|
||||
List<UnitKeywordDTO> findAllByOwner(Optional <String> ownerLogin);
|
||||
|
||||
/**
|
||||
* Get a single keyword
|
||||
*
|
||||
* @param id of the keyword
|
||||
* @return the entity
|
||||
*/
|
||||
Optional<UnitKeywordDTO> findOne(Long id);
|
||||
|
||||
/**
|
||||
* Delete a single keyword
|
||||
*
|
||||
* @param id of the entity to delete
|
||||
*/
|
||||
void delete(Long id);
|
||||
}
|
47
src/main/java/com/warhammer/service/WeaponService.java
Normal file
47
src/main/java/com/warhammer/service/WeaponService.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.warhammer.service;
|
||||
|
||||
import com.warhammer.service.dto.WeaponDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface WeaponService {
|
||||
|
||||
/**
|
||||
* Save a weapon
|
||||
*
|
||||
* @param weaponDTO
|
||||
* @return the persisted entity
|
||||
*/
|
||||
WeaponDTO save(WeaponDTO weaponDTO);
|
||||
|
||||
/**
|
||||
* Get all weapons
|
||||
*
|
||||
* @return the list of the entities
|
||||
*/
|
||||
List<WeaponDTO> findAll();
|
||||
|
||||
/**
|
||||
* Get all Weapons for a user
|
||||
*
|
||||
* @param ownerLogin the owner to search for the weapons of
|
||||
* @return List of weapons owned by Owner
|
||||
*/
|
||||
List<WeaponDTO> findAllByOwner(Optional <String> ownerLogin);
|
||||
|
||||
/**
|
||||
* Find a single weapon
|
||||
*
|
||||
* @param id the id of the entity
|
||||
* @return the entity
|
||||
*/
|
||||
Optional<WeaponDTO> findOne(Long id);
|
||||
|
||||
/**
|
||||
* Deletes a weapon
|
||||
*
|
||||
* @param id of the weapon
|
||||
*/
|
||||
void delete(Long id);
|
||||
}
|
233
src/main/java/com/warhammer/service/dto/DataslateDTO.java
Normal file
233
src/main/java/com/warhammer/service/dto/DataslateDTO.java
Normal file
@ -0,0 +1,233 @@
|
||||
package com.warhammer.service.dto;
|
||||
|
||||
import com.warhammer.domain.UnitArmy;
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import com.warhammer.domain.User;
|
||||
import com.warhammer.domain.Weapon;
|
||||
|
||||
import javax.persistence.Lob;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* A DTO for the {@link com.warhammer.domain.Dataslate} entity.
|
||||
*/
|
||||
public class DataslateDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String movement;
|
||||
|
||||
private String weapon_skill;
|
||||
|
||||
private String ballistic_skill;
|
||||
|
||||
private String strength;
|
||||
|
||||
private String toughness;
|
||||
|
||||
private String wounds;
|
||||
|
||||
private String attacks;
|
||||
|
||||
private Integer leadership;
|
||||
|
||||
private Integer save;
|
||||
|
||||
private Integer invulnerable;
|
||||
|
||||
private Integer feelNoPain;
|
||||
|
||||
@Lob
|
||||
private String wargearOptions;
|
||||
|
||||
@Lob
|
||||
private String psyker;
|
||||
|
||||
private HashSet<Weapon> weapons;
|
||||
|
||||
private HashSet<UnitKeyword> keywords;
|
||||
|
||||
private UnitArmy unitArmy;
|
||||
|
||||
private User owner;
|
||||
|
||||
public String ownerLogin;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMovement() {
|
||||
return movement;
|
||||
}
|
||||
|
||||
public void setMovement(String movement) {
|
||||
this.movement = movement;
|
||||
}
|
||||
|
||||
public String getWeapon_skill() {
|
||||
return weapon_skill;
|
||||
}
|
||||
|
||||
public void setWeapon_skill(String weapon_skill) {
|
||||
this.weapon_skill = weapon_skill;
|
||||
}
|
||||
|
||||
public String getBallistic_skill() {
|
||||
return ballistic_skill;
|
||||
}
|
||||
|
||||
public void setBallistic_skill(String ballistic_skill) {
|
||||
this.ballistic_skill = ballistic_skill;
|
||||
}
|
||||
|
||||
public String getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(String strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getToughness() {
|
||||
return toughness;
|
||||
}
|
||||
|
||||
public void setToughness(String toughness) {
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
public String getWounds() {
|
||||
return wounds;
|
||||
}
|
||||
|
||||
public void setWounds(String wounds) {
|
||||
this.wounds = wounds;
|
||||
}
|
||||
|
||||
public String getAttacks() {
|
||||
return attacks;
|
||||
}
|
||||
|
||||
public void setAttacks(String attacks) {
|
||||
this.attacks = attacks;
|
||||
}
|
||||
|
||||
public Integer getLeadership() {
|
||||
return leadership;
|
||||
}
|
||||
|
||||
public void setLeadership(Integer leadership) {
|
||||
this.leadership = leadership;
|
||||
}
|
||||
|
||||
public Integer getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(Integer save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public Integer getInvulnerable() {
|
||||
return invulnerable;
|
||||
}
|
||||
|
||||
public void setInvulnerable(Integer invulnerable) {
|
||||
this.invulnerable = invulnerable;
|
||||
}
|
||||
|
||||
public Integer getFeelNoPain() {
|
||||
return feelNoPain;
|
||||
}
|
||||
|
||||
public void setFeelNoPain(Integer feelNoPain) {
|
||||
this.feelNoPain = feelNoPain;
|
||||
}
|
||||
|
||||
public String getWargearOptions() {
|
||||
return wargearOptions;
|
||||
}
|
||||
|
||||
public void setWargearOptions(String wargearOptions) {
|
||||
this.wargearOptions = wargearOptions;
|
||||
}
|
||||
|
||||
public String getPsyker() {
|
||||
return psyker;
|
||||
}
|
||||
|
||||
public void setPsyker(String psyker) {
|
||||
this.psyker = psyker;
|
||||
}
|
||||
|
||||
public HashSet<Weapon> getWeapons() {
|
||||
return weapons;
|
||||
}
|
||||
|
||||
public void setWeapons(HashSet<Weapon> weapons) {
|
||||
this.weapons = weapons;
|
||||
}
|
||||
|
||||
public HashSet<UnitKeyword> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(HashSet<UnitKeyword> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public UnitArmy getUnitArmy() {
|
||||
return unitArmy;
|
||||
}
|
||||
|
||||
public void setUnitArmy(UnitArmy unitArmy) {
|
||||
this.unitArmy = unitArmy;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getOwnerLogin() {
|
||||
return ownerLogin;
|
||||
}
|
||||
|
||||
public void setOwnerLogin(String ownerLogin) {
|
||||
this.ownerLogin = ownerLogin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataslateDTO{" +
|
||||
"id=" + getId() +
|
||||
", movement='" + getMovement() + "'" +
|
||||
", weaponSkill='" + getWeapon_skill() + "'" +
|
||||
", ballisticSkill='" + getBallistic_skill() + "'" +
|
||||
", strength='" + getStrength() + "'" +
|
||||
", toughness='" + getToughness() + "'" +
|
||||
", wounds='" + getWounds() + "'" +
|
||||
", attacks='" + getAttacks() + "'" +
|
||||
", leadership='" + getLeadership() + "'" +
|
||||
", save=" + getSave() +
|
||||
", invulnerable= " + getInvulnerable() +
|
||||
", feelNoPain=" + getFeelNoPain() +
|
||||
", wargearOptions='" + getWargearOptions() + "'" +
|
||||
", psyker='" + getPsyker() + "'" +
|
||||
", weapons='" + getWeapons() + "'" +
|
||||
", keywords='" + getKeywords() + "'" +
|
||||
", unit=" + getUnitArmy() +
|
||||
", owner=" + getOwner() +
|
||||
"}";
|
||||
}
|
||||
|
||||
}
|
56
src/main/java/com/warhammer/service/dto/UnitKeywordDTO.java
Normal file
56
src/main/java/com/warhammer/service/dto/UnitKeywordDTO.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.warhammer.service.dto;
|
||||
|
||||
import com.warhammer.domain.User;
|
||||
|
||||
public class UnitKeywordDTO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String keyword;
|
||||
|
||||
private boolean isFaction;
|
||||
|
||||
private User owner;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public boolean isFaction() {
|
||||
return isFaction;
|
||||
}
|
||||
|
||||
public void setFaction(boolean faction) {
|
||||
isFaction = faction;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UnitKeywordDTO{" +
|
||||
"id=" + id +
|
||||
", keyword='" + keyword + '\'' +
|
||||
", isFaction=" + isFaction +
|
||||
", owner=" + owner +
|
||||
'}';
|
||||
}
|
||||
}
|
113
src/main/java/com/warhammer/service/dto/WeaponDTO.java
Normal file
113
src/main/java/com/warhammer/service/dto/WeaponDTO.java
Normal file
@ -0,0 +1,113 @@
|
||||
package com.warhammer.service.dto;
|
||||
|
||||
import com.warhammer.domain.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WeaponDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String weapon;
|
||||
|
||||
private String range;
|
||||
|
||||
private String type;
|
||||
|
||||
private String strength;
|
||||
|
||||
private String armorPenetration;
|
||||
|
||||
private String damage;
|
||||
|
||||
private String abilities;
|
||||
|
||||
private User owner;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public void setWeapon(String weapon) {
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
public String getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public void setRange(String range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getStrength() {
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(String strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public String getArmorPenetration() {
|
||||
return armorPenetration;
|
||||
}
|
||||
|
||||
public void setArmorPenetration(String armorPenetration) {
|
||||
this.armorPenetration = armorPenetration;
|
||||
}
|
||||
|
||||
public String getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(String damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public String getAbilities() {
|
||||
return abilities;
|
||||
}
|
||||
|
||||
public void setAbilities(String abilities) {
|
||||
this.abilities = abilities;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeaponDTO{" +
|
||||
"id=" + id +
|
||||
", weapon='" + weapon + '\'' +
|
||||
", range='" + range + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", strength='" + strength + '\'' +
|
||||
", armorPenetration='" + armorPenetration + '\'' +
|
||||
", damage='" + damage + '\'' +
|
||||
", abilities='" + abilities + '\'' +
|
||||
", owner=" + owner +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.warhammer.service.impl;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.repository.DataslateRepository;
|
||||
import com.warhammer.service.DataslateService;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
import com.warhammer.service.mapper.DataslateMapper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class DataslateServiceImpl implements DataslateService {
|
||||
private final Logger log = LoggerFactory.getLogger(DataslateServiceImpl.class);
|
||||
|
||||
private final DataslateRepository dataslateRepository;
|
||||
|
||||
private final DataslateMapper dataslateMapper;
|
||||
|
||||
public DataslateServiceImpl(DataslateRepository dataslateRepository, DataslateMapper dataslateMapper) {
|
||||
this.dataslateRepository = dataslateRepository;
|
||||
this.dataslateMapper = dataslateMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataslateDTO save(DataslateDTO dataslateDTO) {
|
||||
log.debug("Request to save Dataslate : {}", dataslateDTO);
|
||||
Dataslate dataslate = dataslateMapper.toEntity(dataslateDTO);
|
||||
dataslate = dataslateRepository.save(dataslate);
|
||||
return dataslateMapper.toDto(dataslate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<DataslateDTO> findAll() {
|
||||
log.debug("Request to get all Dataslates");
|
||||
return dataslateRepository.findAll().stream()
|
||||
.map(dataslateMapper::toDto)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataslateDTO> findAllByOwner(Optional ownerLoginOptional) {
|
||||
log.debug("Request to get all Dataslates by Owner : " + ownerLoginOptional.orElse(null));
|
||||
return dataslateRepository.findAll().stream()
|
||||
.map(dataslateMapper::toDto)
|
||||
.filter(dataslateDTO -> dataslateDTO.getOwnerLogin().equals(ownerLoginOptional.orElse(null)))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataslateDTO> findAllByArmy(Long id) {
|
||||
log.debug("Request to get all Dataslates by Army : " + id);
|
||||
return dataslateRepository.findAll().stream()
|
||||
.map(dataslateMapper::toDto)
|
||||
.filter(dataslateDTO -> dataslateDTO.getUnitArmy().getArmy().getId().equals(id))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<DataslateDTO> findOne(Long id) {
|
||||
log.debug("Request to get Dataslate : {}", id);
|
||||
return dataslateRepository.findById(id)
|
||||
.map(dataslateMapper::toDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
log.debug("Request to delete Dataslate : {}", id);
|
||||
dataslateRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.warhammer.service.impl;
|
||||
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import com.warhammer.repository.UnitKeywordRepository;
|
||||
import com.warhammer.service.UnitKeywordService;
|
||||
import com.warhammer.service.dto.UnitKeywordDTO;
|
||||
import com.warhammer.service.mapper.UnitKeywordMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class UnitKeywordServiceImpl implements UnitKeywordService {
|
||||
private final Logger log = LoggerFactory.getLogger(UnitKeywordServiceImpl.class);
|
||||
|
||||
private final UnitKeywordRepository unitKeywordRepository;
|
||||
|
||||
private final UnitKeywordMapper unitKeywordMapper;
|
||||
|
||||
public UnitKeywordServiceImpl(UnitKeywordRepository unitKeywordRepository, UnitKeywordMapper unitKeywordMapper) {
|
||||
this.unitKeywordRepository = unitKeywordRepository;
|
||||
this.unitKeywordMapper = unitKeywordMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitKeywordDTO save(UnitKeywordDTO unitKeywordDTO) {
|
||||
log.debug("Request to save UnitKeyword : {}", unitKeywordDTO);
|
||||
UnitKeyword unitKeyword = unitKeywordMapper.toEntity(unitKeywordDTO);
|
||||
unitKeyword = unitKeywordRepository.save(unitKeyword);
|
||||
return unitKeywordMapper.toDto(unitKeyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UnitKeywordDTO> findAll() {
|
||||
log.debug("Request to get all UnitKeywords");
|
||||
return unitKeywordRepository.findAll().stream()
|
||||
.map(unitKeywordMapper::toDto)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UnitKeywordDTO> findAllByOwner(Optional ownerLoginOptional) {
|
||||
log.debug("Request to get all UnitKeywords by Owner : " + ownerLoginOptional.orElse(null));
|
||||
return unitKeywordRepository.findAll().stream()
|
||||
.map(unitKeywordMapper::toDto)
|
||||
.filter(unitKeywordDto -> unitKeywordDto.getOwner().equals(ownerLoginOptional.orElse(null)))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UnitKeywordDTO> findOne(Long id) {
|
||||
log.debug("Request to get UnitKeyword : {}", id);
|
||||
return unitKeywordRepository.findById(id)
|
||||
.map(unitKeywordMapper::toDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
log.debug("Request ot delete UnitKeyword : {}", id);
|
||||
unitKeywordRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.warhammer.service.impl;
|
||||
|
||||
import com.warhammer.domain.Weapon;
|
||||
import com.warhammer.repository.WeaponRepository;
|
||||
import com.warhammer.service.WeaponService;
|
||||
import com.warhammer.service.dto.WeaponDTO;
|
||||
import com.warhammer.service.mapper.WeaponMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class WeaponServiceImpl implements WeaponService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(WeaponServiceImpl.class);
|
||||
|
||||
private final WeaponRepository weaponRepository;
|
||||
|
||||
private final WeaponMapper weaponMapper;
|
||||
|
||||
public WeaponServiceImpl(WeaponRepository weaponRepository, WeaponMapper weaponMapper) {
|
||||
this.weaponRepository = weaponRepository;
|
||||
this.weaponMapper = weaponMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeaponDTO save(WeaponDTO weaponDTO) {
|
||||
log.debug("Request to save Weapon : {}", weaponDTO);
|
||||
Weapon weapon = weaponMapper.toEntity(weaponDTO);
|
||||
weapon = weaponRepository.save(weapon);
|
||||
return weaponMapper.toDto(weapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<WeaponDTO> findAll() {
|
||||
log.debug("Request to get all Weapons");
|
||||
return weaponRepository.findAll().stream()
|
||||
.map(weaponMapper::toDto)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<WeaponDTO> findAllByOwner(Optional<String> ownerLoginOptional) {
|
||||
log.debug("Request to get all Weapons by Owner : " + ownerLoginOptional.orElse(null));
|
||||
return weaponRepository.findAll().stream()
|
||||
.map(weaponMapper::toDto)
|
||||
.filter(weaponDTO -> weaponDTO.getOwner().equals(ownerLoginOptional.orElse(null)))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<WeaponDTO> findOne(Long id) {
|
||||
log.debug("Request to get Dataslate : {}", id);
|
||||
return weaponRepository.findById(id)
|
||||
.map(weaponMapper::toDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
log.debug("Request to delete Weapon : {}", id);
|
||||
weaponRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.warhammer.service.mapper;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
import org.mapstruct.*;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {UserMapper.class})
|
||||
public interface DataslateMapper extends EntityMapper<DataslateDTO, Dataslate> {
|
||||
@Mapping(source = "owner.id", target = "owner")
|
||||
@Mapping(source = "owner.login", target = "ownerLogin")
|
||||
DataslateDTO toDto(Dataslate dataslate);
|
||||
|
||||
@Mapping(source = "owner", target = "owner")
|
||||
Dataslate toEntity(DataslateDTO dataslateDTO);
|
||||
|
||||
default Dataslate fromId(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
Dataslate dataslate = new Dataslate();
|
||||
dataslate.setId(id);
|
||||
return dataslate;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.warhammer.service.mapper;
|
||||
|
||||
import com.warhammer.domain.UnitKeyword;
|
||||
import com.warhammer.service.dto.UnitKeywordDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {UserMapper.class})
|
||||
public interface UnitKeywordMapper extends EntityMapper<UnitKeywordDTO, UnitKeyword> {
|
||||
UnitKeywordDTO toDto(UnitKeyword unitKeyword);
|
||||
|
||||
UnitKeyword toEntity(UnitKeywordDTO unitKeywordDTO);
|
||||
}
|
15
src/main/java/com/warhammer/service/mapper/WeaponMapper.java
Normal file
15
src/main/java/com/warhammer/service/mapper/WeaponMapper.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.warhammer.service.mapper;
|
||||
|
||||
import com.warhammer.domain.Weapon;
|
||||
import com.warhammer.service.dto.WeaponDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {UserMapper.class})
|
||||
public interface WeaponMapper extends EntityMapper<WeaponDTO, Weapon> {
|
||||
// @Mapping(source = "owner.login", target = "owner")
|
||||
@Mapping(source = "weapon", target = "weapon")
|
||||
WeaponDTO toDto(Weapon weapon);
|
||||
|
||||
Weapon toEntity(WeaponDTO weaponDTO);
|
||||
}
|
111
src/main/java/com/warhammer/web/rest/DataslateResource.java
Normal file
111
src/main/java/com/warhammer/web/rest/DataslateResource.java
Normal file
@ -0,0 +1,111 @@
|
||||
package com.warhammer.web.rest;
|
||||
|
||||
import com.warhammer.domain.Dataslate;
|
||||
import com.warhammer.security.SecurityUtils;
|
||||
import com.warhammer.service.DataslateService;
|
||||
import com.warhammer.service.dto.DataslateDTO;
|
||||
import com.warhammer.web.rest.errors.BadRequestAlertException;
|
||||
import io.github.jhipster.web.util.HeaderUtil;
|
||||
import io.github.jhipster.web.util.ResponseUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("~/api")
|
||||
public class DataslateResource {
|
||||
private final Logger log = LoggerFactory.getLogger(DataslateResource.class);
|
||||
|
||||
private static final String ENTITY_NAME = "dataslate";
|
||||
|
||||
@Value("crusadetrackerApp")
|
||||
private String applicationName;
|
||||
|
||||
private final DataslateService dataslateService;
|
||||
|
||||
public DataslateResource(DataslateService dataslateService) {
|
||||
this.dataslateService = dataslateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code POST /dataslates} : Creates a dataslate.
|
||||
*
|
||||
* @param dataslateDTO the dataslate to create
|
||||
* @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new dataslate, or with status {@code 400 (Bad Request)} if the dataslate already has an ID.
|
||||
* @throws URISyntaxException if the Location URI syntax is incorrect.
|
||||
*/
|
||||
@PostMapping("/dataslates")
|
||||
public ResponseEntity<DataslateDTO> createDataslate(@Valid @RequestBody DataslateDTO dataslateDTO) throws URISyntaxException {
|
||||
log.debug("REST request to save Dataslate : {}", dataslateDTO);
|
||||
if (dataslateDTO.getId() != null) {
|
||||
throw new BadRequestAlertException("A new dataslate cannot already have an ID", ENTITY_NAME, "idexists");
|
||||
}
|
||||
DataslateDTO result = dataslateService.save(dataslateDTO);
|
||||
return ResponseEntity.created(new URI("/api/dataslates/" + result.getId()))
|
||||
.headers(HeaderUtil.createEntityCreationAlert(applicationName, false, ENTITY_NAME, result.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code PUT /dataslates} : Updates an existing dataslate.
|
||||
*
|
||||
* @param dataslateDTO the dataslate to update
|
||||
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated dataslate,
|
||||
* or with status {@code 400 (Bad Request)} if the dataslate is not valid,
|
||||
* or with status {@code 500 (Internal Server Error)} if the dataslate couldn't be updated.
|
||||
* @throws URISyntaxException if the Location URI syntax is incorrect.
|
||||
*/
|
||||
@PutMapping("/dataslates")
|
||||
public ResponseEntity<DataslateDTO> updateDataSlate(@Valid @RequestBody DataslateDTO dataslateDTO) throws URISyntaxException {
|
||||
log.debug("REST request to update Dataslate : {}", dataslateDTO);
|
||||
if (dataslateDTO.getId() == null) {
|
||||
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
|
||||
}
|
||||
DataslateDTO result = dataslateService.save(dataslateDTO);
|
||||
return ResponseEntity.ok()
|
||||
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, false, ENTITY_NAME,
|
||||
dataslateDTO.getId().toString()))
|
||||
.body(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code GET /dataslates} : get all the dataslates
|
||||
*
|
||||
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of dataslates in body.
|
||||
*/
|
||||
@GetMapping("/dataslates")
|
||||
public List<Dataslate> getAllDataslates() {
|
||||
log.debug("REST request to get all dataslates");
|
||||
Optional<String> userLogin = SecurityUtils.getCurrentUserLogin();
|
||||
return dataslateService.findAllByOwner(userLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code GET /dataslates/get-army/:id} : get all
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/dataslates/get-army/{id}")
|
||||
public ResponseEntity<List<DataslateDTO>> getUnitArmy(@PathVariable Long id) {
|
||||
log.debug("REST request to get Dataslates for army : {}", id);
|
||||
List<DataslateDTO> dataslateDTO = dataslateService.findAllByArmy(id);
|
||||
Optional<List<DataslateDTO>> optionalDataslateDTOS = Optional.of(dataslateDTO);
|
||||
return ResponseUtil.wrapOrNotFound(optionalDataslateDTOS);
|
||||
}
|
||||
|
||||
@DeleteMapping("/dataslates/{id}")
|
||||
public ResponseEntity<Void> deleteDataslate(@PathVariable Long id) {
|
||||
log.debug("REST request to delete Dataslate : {}", id);
|
||||
dataslateService.delete(id);
|
||||
return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(
|
||||
applicationName, false, ENTITY_NAME, id.toString())).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.warhammer.web.rest;
|
||||
|
||||
public class UnitKeywordResource {
|
||||
}
|
4
src/main/java/com/warhammer/web/rest/WeaponResource.java
Normal file
4
src/main/java/com/warhammer/web/rest/WeaponResource.java
Normal file
@ -0,0 +1,4 @@
|
||||
package com.warhammer.web.rest;
|
||||
|
||||
public class WeaponResource {
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
|
||||
|
||||
<property name="autoIncrement" value="true"/>
|
||||
|
||||
<!--
|
||||
Update the entity UnitArmy.
|
||||
to remove entity UnitBase
|
||||
-->
|
||||
<!-- todo -->
|
||||
<changeSet id="20220421081900_add_dataslates.xml-1" author="mitch" runOnChange="true">
|
||||
<createTable tableName="weapon">
|
||||
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="weapon" type="varchar(255)"/>
|
||||
<column name="range" type="varchar(255)"/>
|
||||
<column name="type" type="varchar(255)"/>
|
||||
<column name="strength" type="varchar(255)"/>
|
||||
<column name="armor_penetration" type="varchar(255)"/>
|
||||
<column name="damage" type="varchar(255)"/>
|
||||
<column name="abilities" type="varchar(255)"/>
|
||||
</createTable>
|
||||
<createTable tableName="unit_keyword">
|
||||
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
|
||||
<constraints primaryKey="true" nullable="false" />
|
||||
</column>
|
||||
<column name="keyword" type="varchar(255)"/>
|
||||
<column name="isFaction" type="boolean"/>
|
||||
</createTable>
|
||||
<createTable tableName="dataslate">
|
||||
<column name="id" type="bigint" autoIncrement="${autoIncrement}">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="movement" type="varchar(255)"/>
|
||||
<column name="weapon_skill" type="varchar(255)"/>
|
||||
<column name="ballistic_skill" type="varchar(255)"/>
|
||||
<column name="strength" type="varchar(255)"/>
|
||||
<column name="wounds" type="varchar(255)"/>
|
||||
<column name="attacks" type="varchar(255)"/>
|
||||
<column name="leadership" type="int"/>
|
||||
<column name="save" type="int"/>
|
||||
<column name="invulnerable" type="int"/>
|
||||
<column name="feel_no_pain" type="int"/>
|
||||
<column name="wargear_options" type="${clobType}"/>
|
||||
<column name="psyker" type="${clobType}"/>
|
||||
</createTable>
|
||||
<createTable tableName="dataslate_weapon">
|
||||
<column name="dataslate_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_weapon_composite"
|
||||
foreignKeyName="fk_dataslate_id"
|
||||
references="dataslate(id)"
|
||||
/>
|
||||
</column>
|
||||
<column name="weapon_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_wweapon_composite"
|
||||
foreignKeyName="fk_dataslate_weapon_id"
|
||||
references="weapon(id)"
|
||||
/>
|
||||
</column>
|
||||
</createTable>
|
||||
<createTable tableName="dataslate_keyword">
|
||||
<column name="dataslate_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_keyword_composite"
|
||||
foreignKeyName="fk_dataslate_keyword_dataslate_id"
|
||||
references="dataslate(id)"
|
||||
/>
|
||||
</column>
|
||||
<column name="keyword_id" type="bigint">
|
||||
<constraints nullable="false"
|
||||
primaryKey="true"
|
||||
primaryKeyName="pk_dataslate_keyword_composite"
|
||||
foreignKeyName="fk_dataslate_keyword_keyword_id"
|
||||
references="unit_keyword(id)"
|
||||
/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
<changeSet id="20220421081900_add_dataslates.xml-2" author="mitch" runOnChange="true">
|
||||
<addColumn tableName="unit_army">
|
||||
<column name="unit_dataslate_id" type="bigint">
|
||||
<constraints nullable="true" foreignKeyName="fk_unit_dataslate_unit_army_id" references="dataslate(id)"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -26,6 +26,7 @@
|
||||
<include file="config/liquibase/changelog/20220304184800_remove_agenda_unit_army.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/changelog/20220313104800_remove_unused_kill_tally.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/changelog/20220315083700_add_tie_tally.xml" relativeToChangelogFile="false"/>
|
||||
<include file="config/liquibase/changelog/20220421081900_add_dataslates.xml" relativeToChangelogFile="false"/>
|
||||
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
|
||||
<!-- jhipster-needle-liquibase-add-incremental-changelog - JHipster will add incremental liquibase changelogs here -->
|
||||
</databaseChangeLog>
|
||||
|
Loading…
Reference in New Issue
Block a user