mirror of https://gitee.com/stylefeng/roses
【i18n】整理校验以及查询条件
parent
be021cacea
commit
c19dc23145
|
@ -4,6 +4,9 @@ import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多语言请求信息
|
* 多语言请求信息
|
||||||
*
|
*
|
||||||
|
@ -19,26 +22,31 @@ public class TranslationRequest extends BaseRequest {
|
||||||
/**
|
/**
|
||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "tranId不能为空", groups = {edit.class, detail.class, delete.class})
|
||||||
private Long tranId;
|
private Long tranId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码
|
* 编码
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "tranCode不能为空", groups = {add.class, edit.class})
|
||||||
private String tranCode;
|
private String tranCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多语言条例名称
|
* 多语言条例名称
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "tranName不能为空", groups = {add.class, edit.class})
|
||||||
private String tranName;
|
private String tranName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1:中文 2:英语
|
* 1:中文 2:英语
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "language不能为空", groups = {add.class, edit.class})
|
||||||
private Integer language;
|
private Integer language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻译的值
|
* 翻译的值
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "tranValue不能为空", groups = {add.class, edit.class})
|
||||||
private String tranValue;
|
private String tranValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,13 @@ import cn.stylefeng.roses.kernel.i18n.api.pojo.request.TranslationRequest;
|
||||||
import cn.stylefeng.roses.kernel.i18n.modular.entity.Translation;
|
import cn.stylefeng.roses.kernel.i18n.modular.entity.Translation;
|
||||||
import cn.stylefeng.roses.kernel.i18n.modular.service.TranslationService;
|
import cn.stylefeng.roses.kernel.i18n.modular.service.TranslationService;
|
||||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||||
|
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||||
import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -32,7 +36,7 @@ public class TranslationController {
|
||||||
* @date 2021/1/24 19:17
|
* @date 2021/1/24 19:17
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "新增多语言配置", path = "/i18n/add")
|
@PostResource(name = "新增多语言配置", path = "/i18n/add")
|
||||||
public ResponseData addItem(TranslationRequest translationRequest) {
|
public ResponseData addItem(@RequestBody @Validated(TranslationRequest.add.class) TranslationRequest translationRequest) {
|
||||||
this.translationService.add(translationRequest);
|
this.translationService.add(translationRequest);
|
||||||
return new SuccessResponseData();
|
return new SuccessResponseData();
|
||||||
}
|
}
|
||||||
|
@ -44,7 +48,7 @@ public class TranslationController {
|
||||||
* @date 2021/1/24 19:17
|
* @date 2021/1/24 19:17
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "新增多语言配置", path = "/i18n/edit")
|
@PostResource(name = "新增多语言配置", path = "/i18n/edit")
|
||||||
public ResponseData editItem(TranslationRequest translationRequest) {
|
public ResponseData editItem(@RequestBody @Validated(BaseRequest.edit.class) TranslationRequest translationRequest) {
|
||||||
this.translationService.update(translationRequest);
|
this.translationService.update(translationRequest);
|
||||||
return new SuccessResponseData();
|
return new SuccessResponseData();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +60,7 @@ public class TranslationController {
|
||||||
* @date 2021/1/24 19:20
|
* @date 2021/1/24 19:20
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "新增多语言配置", path = "/i18n/delete")
|
@PostResource(name = "新增多语言配置", path = "/i18n/delete")
|
||||||
public ResponseData delete(TranslationRequest translationRequest) {
|
public ResponseData delete(@RequestBody @Validated(BaseRequest.delete.class) TranslationRequest translationRequest) {
|
||||||
this.translationService.delete(translationRequest);
|
this.translationService.delete(translationRequest);
|
||||||
return new SuccessResponseData();
|
return new SuccessResponseData();
|
||||||
}
|
}
|
||||||
|
@ -67,8 +71,8 @@ public class TranslationController {
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @date 2021/1/24 19:20
|
* @date 2021/1/24 19:20
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "新增多语言配置", path = "/i18n/detail")
|
@GetResource(name = "新增多语言配置", path = "/i18n/detail")
|
||||||
public ResponseData detail(TranslationRequest translationRequest) {
|
public ResponseData detail(@Validated(BaseRequest.detail.class) TranslationRequest translationRequest) {
|
||||||
Translation detail = this.translationService.findDetail(translationRequest);
|
Translation detail = this.translationService.findDetail(translationRequest);
|
||||||
return new SuccessResponseData(detail);
|
return new SuccessResponseData(detail);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +83,7 @@ public class TranslationController {
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @date 2021/1/24 19:20
|
* @date 2021/1/24 19:20
|
||||||
*/
|
*/
|
||||||
@PostResource(name = "新增多语言配置", path = "/i18n/page")
|
@GetResource(name = "新增多语言配置", path = "/i18n/page")
|
||||||
public ResponseData list(TranslationRequest translationRequest) {
|
public ResponseData list(TranslationRequest translationRequest) {
|
||||||
PageResult<Translation> page = this.translationService.findPage(translationRequest);
|
PageResult<Translation> page = this.translationService.findPage(translationRequest);
|
||||||
return new SuccessResponseData(page);
|
return new SuccessResponseData(page);
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class TranslationServiceImpl extends ServiceImpl<TranslationMapper, Trans
|
||||||
|
|
||||||
// 如果翻译名称不为空,则带上翻译名称
|
// 如果翻译名称不为空,则带上翻译名称
|
||||||
if (ObjectUtil.isNotEmpty(param.getTranName())) {
|
if (ObjectUtil.isNotEmpty(param.getTranName())) {
|
||||||
queryWrapper.eq(Translation::getTranName, param.getTranName());
|
queryWrapper.like(Translation::getTranName, param.getTranName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue