说明:1、添加后端英语单词模块校验分组
This commit is contained in:
parent
3239eddba4
commit
0fdf9e9537
|
|
@ -360,7 +360,6 @@ export default {
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm() {
|
submitForm() {
|
||||||
this.$refs["form"].validate(valid => {
|
this.$refs["form"].validate(valid => {
|
||||||
console.log(valid)
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (this.form.id != null) {
|
if (this.form.id != null) {
|
||||||
updateWord(this.form).then(response => {
|
updateWord(this.form).then(response => {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.xjs.validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiejs
|
||||||
|
* @desc 添加校验分组
|
||||||
|
* @create 2021-12-30
|
||||||
|
*/
|
||||||
|
public interface AddGroup {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.xjs.validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiejs
|
||||||
|
* @desc 修改校验分组
|
||||||
|
* @create 2021-12-30
|
||||||
|
*/
|
||||||
|
public interface UpdateGroup {
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,8 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.xjs.validation.AddGroup;
|
||||||
|
import com.xjs.validation.UpdateGroup;
|
||||||
import com.xjs.word.domain.EnglishWord;
|
import com.xjs.word.domain.EnglishWord;
|
||||||
import com.xjs.word.service.IEnglishWordService;
|
import com.xjs.word.service.IEnglishWordService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -69,7 +71,7 @@ public class EnglishWordController extends BaseController {
|
||||||
@RequiresPermissions("english:word:add")
|
@RequiresPermissions("english:word:add")
|
||||||
@Log(title = "英语单词", businessType = BusinessType.INSERT)
|
@Log(title = "英语单词", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody EnglishWord englishWord) {
|
public AjaxResult add(@Validated({AddGroup.class}) @RequestBody EnglishWord englishWord) {
|
||||||
return toAjax(englishWordService.insertEnglishWord(englishWord));
|
return toAjax(englishWordService.insertEnglishWord(englishWord));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +81,7 @@ public class EnglishWordController extends BaseController {
|
||||||
@RequiresPermissions("english:word:edit")
|
@RequiresPermissions("english:word:edit")
|
||||||
@Log(title = "英语单词", businessType = BusinessType.UPDATE)
|
@Log(title = "英语单词", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody EnglishWord englishWord) {
|
public AjaxResult edit(@Validated({UpdateGroup.class}) @RequestBody EnglishWord englishWord) {
|
||||||
return toAjax(englishWordService.updateEnglishWord(englishWord));
|
return toAjax(englishWordService.updateEnglishWord(englishWord));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,12 @@ package com.xjs.word.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
|
import com.xjs.validation.AddGroup;
|
||||||
|
import com.xjs.validation.UpdateGroup;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,12 +30,14 @@ public class EnglishWord {
|
||||||
* 英语单词
|
* 英语单词
|
||||||
*/
|
*/
|
||||||
@Excel(name = "英语单词")
|
@Excel(name = "英语单词")
|
||||||
|
@NotBlank(message = "英语单词不能为空",groups = {UpdateGroup.class})
|
||||||
private String englishWord;
|
private String englishWord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对应的中文
|
* 对应的中文
|
||||||
*/
|
*/
|
||||||
@Excel(name = "中文")
|
@Excel(name = "中文")
|
||||||
|
@NotBlank(message = "中文不能为空",groups = {UpdateGroup.class})
|
||||||
private String chineseWord;
|
private String chineseWord;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,7 +45,7 @@ public class EnglishWord {
|
||||||
* 前端传递的内容(可能是中、英文)
|
* 前端传递的内容(可能是中、英文)
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@NotBlank(message = "内容不能为空")
|
@NotBlank(message = "内容不能为空",groups = {AddGroup.class})
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,12 +58,14 @@ public class EnglishWord {
|
||||||
* 是否收藏 1收藏 2不收藏
|
* 是否收藏 1收藏 2不收藏
|
||||||
*/
|
*/
|
||||||
@Excel(name = "是否收藏",readConverterExp = "1=收藏,2=不收藏")
|
@Excel(name = "是否收藏",readConverterExp = "1=收藏,2=不收藏")
|
||||||
|
@NotNull(message = "收藏字段不能为空",groups = {AddGroup.class, UpdateGroup.class})
|
||||||
private Integer isCollect;
|
private Integer isCollect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 置顶 1置顶 2不置顶
|
* 置顶 1置顶 2不置顶
|
||||||
*/
|
*/
|
||||||
@Excel(name = "置顶",readConverterExp = "1=置顶,2=不置顶")
|
@Excel(name = "置顶",readConverterExp = "1=置顶,2=不置顶")
|
||||||
|
@NotNull(message = "置顶字段不能为空",groups = {AddGroup.class, UpdateGroup.class})
|
||||||
private Integer top;
|
private Integer top;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue