new voucher system + jdoc

This commit is contained in:
2021-10-06 15:25:13 +02:00
parent 456332f24e
commit 442bdb4996
234 changed files with 4793 additions and 2737 deletions
@@ -23,8 +23,7 @@ import de.bstly.we.model.Quota;
import de.bstly.we.model.UserData;
/**
* @author _bastler@bstly.de
*
* The Class MinetestAccountManager.
*/
@Component
public class MinetestAccountManager implements UserDataProvider {
@@ -36,18 +35,20 @@ public class MinetestAccountManager implements UserDataProvider {
private QMinetestAccount qMinetestAccount = QMinetestAccount.minetestAccount;
/**
*
* @param name
* @return
* Gets the.
*
* @param name the name
* @return the minetest account
*/
public MinetestAccount get(String name) {
return minetestAccountRepository.findById(name).orElse(null);
}
/**
*
* @param userId
* @return
* Gets the all by owner.
*
* @param userId the user id
* @return the all by owner
*/
public List<MinetestAccount> getAllByOwner(Long userId) {
return Lists
@@ -55,12 +56,13 @@ public class MinetestAccountManager implements UserDataProvider {
}
/**
*
* @param page
* @param size
* @param sortBy
* @param descending
* @return
* Gets the.
*
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @return the page
*/
public Page<MinetestAccount> get(int page, int size, String sortBy, boolean descending) {
return minetestAccountRepository.findAll(PageRequest.of(page, size,
@@ -68,11 +70,12 @@ public class MinetestAccountManager implements UserDataProvider {
}
/**
*
* @param owner
* @param name
* @param quota
* @return
* Creates the.
*
* @param owner the owner
* @param name the name
* @param quota the quota
* @return the minetest account
*/
public MinetestAccount create(Long owner, String name, boolean quota) {
MinetestAccount minetestAccount = new MinetestAccount();
@@ -97,18 +100,20 @@ public class MinetestAccountManager implements UserDataProvider {
}
/**
*
* @param minetestAccount
* @return
* Save.
*
* @param minetestAccount the minetest account
* @return the minetest account
*/
public MinetestAccount save(MinetestAccount minetestAccount) {
return minetestAccountRepository.save(minetestAccount);
}
/**
*
* @param minetestAccount
* @param quota
* Delete.
*
* @param minetestAccount the minetest account
* @param quota the quota
*/
public void delete(MinetestAccount minetestAccount, boolean quota) {
if (quota) {
@@ -127,9 +132,10 @@ public class MinetestAccountManager implements UserDataProvider {
}
/**
*
* @param owner
* @param quota
* Delete all.
*
* @param owner the owner
* @param quota the quota
*/
public void deleteAll(Long owner, boolean quota) {
List<MinetestAccount> minetestAccounts = Lists
@@ -140,6 +146,7 @@ public class MinetestAccountManager implements UserDataProvider {
}
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
*/
@@ -148,6 +155,7 @@ public class MinetestAccountManager implements UserDataProvider {
return "minetest-accounts";
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#getUserData(java.lang.Long)
*/
@@ -160,6 +168,7 @@ public class MinetestAccountManager implements UserDataProvider {
return result;
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#purgeUserData(java.lang.Long)
*/
@@ -4,8 +4,7 @@
package de.bstly.we.minetest.businesslogic;
/**
* @author _bastler@bstly.de
*
* The Interface MinetestPermissions.
*/
public interface MinetestPermissions {
@@ -4,8 +4,7 @@
package de.bstly.we.minetest.businesslogic;
/**
* @author _bastler@bstly.de
*
* The Interface MinetestQuotas.
*/
public interface MinetestQuotas {
@@ -30,8 +30,7 @@ import de.bstly.we.minetest.model.MinetestAccount;
import de.bstly.we.model.Quota;
/**
* @author _bastler@bstly.de
*
* The Class MinetestAccountController.
*/
@RestController
@RequestMapping("/minetest/accounts")
@@ -47,8 +46,9 @@ public class MinetestAccountController extends BaseController {
private MinetestAccountValidator minetestAccountModelValidator;
/**
*
* @return
* Gets the minetest accounts.
*
* @return the minetest accounts
*/
@PreAuthorize("isAuthenticated()")
@GetMapping
@@ -62,9 +62,10 @@ public class MinetestAccountController extends BaseController {
}
/**
*
* @param minetestAccountModel
* @return
* Creates the minetest account.
*
* @param minetestAccount the minetest account
* @return the minetest account
*/
@PreAuthorize("isAuthenticated()")
@PostMapping
@@ -92,8 +93,9 @@ public class MinetestAccountController extends BaseController {
}
/**
*
* @param id
* Delete minetest account.
*
* @param name the name
*/
@PreAuthorize("isAuthenticated()")
@DeleteMapping("/{name}")
@@ -27,8 +27,7 @@ import de.bstly.we.minetest.controller.validation.MinetestAccountValidator;
import de.bstly.we.minetest.model.MinetestAccount;
/**
* @author _bastler@bstly.de
*
* The Class MinetestAccountManagementController.
*/
@RestController
@RequestMapping("/minetest/accounts/manage")
@@ -40,8 +39,11 @@ public class MinetestAccountManagementController extends BaseController {
private MinetestAccountValidator minetestAccountModelValidator;
/**
*
* @return
* Gets the minetest accounts.
*
* @param pageParameter the page parameter
* @param sizeParameter the size parameter
* @return the minetest accounts
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping
@@ -53,9 +55,10 @@ public class MinetestAccountManagementController extends BaseController {
}
/**
*
* @param minetestAccount
* @return
* Creates the or update minetest account.
*
* @param minetestAccount the minetest account
* @return the minetest account
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping
@@ -73,8 +76,10 @@ public class MinetestAccountManagementController extends BaseController {
}
/**
*
* @param id
* Delete minetest account.
*
* @param name the name
* @param quota the quota
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/{name}")
@@ -91,8 +96,10 @@ public class MinetestAccountManagementController extends BaseController {
}
/**
*
* @param owner
* Delete all.
*
* @param owner the owner
* @param quota the quota
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/all/{owner}")
@@ -15,8 +15,7 @@ import de.bstly.we.minetest.businesslogic.MinetestAccountManager;
import de.bstly.we.minetest.model.MinetestAccount;
/**
* @author _bastler@bstly.de
*
* The Class MinetestAccountValidator.
*/
@Component
public class MinetestAccountValidator implements Validator {
@@ -27,19 +26,18 @@ public class MinetestAccountValidator implements Validator {
private SystemPropertyManager systemPropertyManager;
protected static final String NAME_REGEX = "^([-_a-zA-Z0-9]+)$";
/*
* @see org.springframework.validation.Validator#supports(java.lang.Class)
*/
@Override
public boolean supports(Class<?> clazz) {
return clazz.isAssignableFrom(MinetestAccount.class);
}
/*
* @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
* @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Override
public void validate(Object target, Errors errors) {
validateMinetestName(target, errors);
if (!errors.hasErrors()) {
@@ -48,9 +46,10 @@ public class MinetestAccountValidator implements Validator {
}
/**
*
* @param target
* @param errors
* Validate minetest name.
*
* @param target the target
* @param errors the errors
*/
public void validateMinetestName(Object target, Errors errors) {
MinetestAccount minetestAccount = (MinetestAccount) target;
@@ -72,9 +71,10 @@ public class MinetestAccountValidator implements Validator {
}
/**
*
* @param target
* @param errors
* Validate reserved names.
*
* @param target the target
* @param errors the errors
*/
public void validateReservedNames(Object target, Errors errors) {
MinetestAccount minetestAccount = (MinetestAccount) target;
@@ -12,8 +12,7 @@ import javax.persistence.Table;
import de.bstly.we.model.UserData;
/**
* @author _bastler@bstly.de
*
* The Class MinetestAccount.
*/
@Entity
@Table(name = "minetest_accounts")
@@ -29,6 +28,8 @@ public class MinetestAccount implements UserData {
private String skin;
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
@@ -36,13 +37,17 @@ public class MinetestAccount implements UserData {
}
/**
* @param name the name to set
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the owner.
*
* @return the owner
*/
public Long getOwner() {
@@ -50,13 +55,17 @@ public class MinetestAccount implements UserData {
}
/**
* @param owner the owner to set
* Sets the owner.
*
* @param owner the new owner
*/
public void setOwner(Long owner) {
this.owner = owner;
}
/**
* Gets the skin.
*
* @return the skin
*/
public String getSkin() {
@@ -64,7 +73,9 @@ public class MinetestAccount implements UserData {
}
/**
* @param skin the skin to set
* Sets the skin.
*
* @param skin the new skin
*/
public void setSkin(String skin) {
this.skin = skin;
@@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.minetest.model.MinetestAccount;
/**
*
* @author _bastler@bstly.de
*
* The Interface MinetestAccountRepository.
*/
@Repository
public interface MinetestAccountRepository