new voucher system + jdoc
This commit is contained in:
@@ -20,8 +20,7 @@ import de.bstly.we.i18n.model.I18n;
|
||||
import de.bstly.we.i18n.repository.I18nRepository;
|
||||
|
||||
/**
|
||||
* @author _bastler@bstly.de
|
||||
*
|
||||
* The Class I18nManager.
|
||||
*/
|
||||
@Component
|
||||
public class I18nManager {
|
||||
@@ -31,18 +30,20 @@ public class I18nManager {
|
||||
private Gson gson = new Gson();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @return
|
||||
* Gets the.
|
||||
*
|
||||
* @param locale the locale
|
||||
* @return the i 18 n
|
||||
*/
|
||||
public I18n get(String locale) {
|
||||
return i18nRepository.findById(locale).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @return
|
||||
* Gets the label.
|
||||
*
|
||||
* @param locale the locale
|
||||
* @return the label
|
||||
*/
|
||||
public JsonObject getLabel(String locale) {
|
||||
I18n i18n = get(locale);
|
||||
@@ -57,17 +58,19 @@ public class I18nManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* Gets the locales.
|
||||
*
|
||||
* @return the locales
|
||||
*/
|
||||
public List<String> getLocales() {
|
||||
return i18nRepository.findAll().stream().map(I18n::getLocale).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dest
|
||||
* @param src
|
||||
* Extend json object.
|
||||
*
|
||||
* @param dest the dest
|
||||
* @param src the src
|
||||
*/
|
||||
protected void extendJsonObject(JsonObject dest, JsonObject src) {
|
||||
for (Entry<String, JsonElement> srcEntry : src.entrySet()) {
|
||||
@@ -87,10 +90,11 @@ public class I18nManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @param newLabel
|
||||
* @return
|
||||
* Adds the label.
|
||||
*
|
||||
* @param locale the locale
|
||||
* @param newLabel the new label
|
||||
* @return the i 18 n
|
||||
*/
|
||||
public I18n addLabel(String locale, JsonObject newLabel) {
|
||||
JsonObject label = getLabel(locale);
|
||||
@@ -109,10 +113,11 @@ public class I18nManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @param label
|
||||
* @return
|
||||
* Sets the label.
|
||||
*
|
||||
* @param locale the locale
|
||||
* @param label the label
|
||||
* @return the i 18 n
|
||||
*/
|
||||
public I18n setLabel(String locale, JsonObject label) {
|
||||
I18n i18n = new I18n();
|
||||
@@ -123,8 +128,9 @@ public class I18nManager {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* Delete label.
|
||||
*
|
||||
* @param locale the locale
|
||||
*/
|
||||
public void deleteLabel(String locale) {
|
||||
if (i18nRepository.existsById(locale)) {
|
||||
|
||||
@@ -28,8 +28,7 @@ import de.bstly.we.controller.BaseController;
|
||||
import de.bstly.we.i18n.businesslogic.I18nManager;
|
||||
|
||||
/**
|
||||
* @author _bastler@bstly.de
|
||||
*
|
||||
* The Class I18nController.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/i18n")
|
||||
@@ -40,8 +39,9 @@ public class I18nController extends BaseController {
|
||||
private Gson gson = new Gson();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* Gets the locales.
|
||||
*
|
||||
* @return the locales
|
||||
*/
|
||||
@GetMapping
|
||||
public List<String> getLocales() {
|
||||
@@ -49,11 +49,13 @@ public class I18nController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @param response
|
||||
* @throws JsonIOException
|
||||
* @throws IOException
|
||||
* Gets the label.
|
||||
*
|
||||
* @param locale the locale
|
||||
* @param response the response
|
||||
* @return the label
|
||||
* @throws JsonIOException the json IO exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
@GetMapping("/{locale}")
|
||||
public void getLabel(@PathVariable("locale") String locale, HttpServletResponse response)
|
||||
@@ -66,9 +68,10 @@ public class I18nController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @param label
|
||||
* Sets the label.
|
||||
*
|
||||
* @param locale the locale
|
||||
* @param label the label
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@PostMapping("/{locale}")
|
||||
@@ -81,9 +84,10 @@ public class I18nController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* @param label
|
||||
* Adds the label.
|
||||
*
|
||||
* @param locale the locale
|
||||
* @param label the label
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@PutMapping("/{locale}")
|
||||
@@ -96,8 +100,9 @@ public class I18nController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locale
|
||||
* Delete locale.
|
||||
*
|
||||
* @param locale the locale
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@DeleteMapping("/{locale}")
|
||||
|
||||
@@ -11,9 +11,7 @@ import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author _bastler@bstly.de
|
||||
*
|
||||
* The Class I18n.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "i18n", uniqueConstraints = @UniqueConstraint(columnNames = { "locale" }))
|
||||
@@ -34,6 +32,8 @@ public class I18n {
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Gets the locale.
|
||||
*
|
||||
* @return the locale
|
||||
*/
|
||||
public String getLocale() {
|
||||
@@ -41,13 +41,17 @@ public class I18n {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locale the locale to set
|
||||
* Sets the locale.
|
||||
*
|
||||
* @param locale the new locale
|
||||
*/
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
@@ -55,7 +59,9 @@ public class I18n {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param label the label to set
|
||||
* Sets the label.
|
||||
*
|
||||
* @param label the new label
|
||||
*/
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
|
||||
@@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
|
||||
import de.bstly.we.i18n.model.I18n;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author _bastler@bstly.de
|
||||
*
|
||||
* The Interface I18nRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface I18nRepository
|
||||
|
||||
Reference in New Issue
Block a user