Commit 96c97fa6 by danmo

分类接口添加校验,列表排序

1 parent fa109883
......@@ -14,6 +14,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
......@@ -59,7 +60,7 @@ public class WeCategoryController extends BaseController {
@Log(title = "添加类目", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("添加类目")
public AjaxResult add(@RequestBody WeCategory category) {
public AjaxResult add(@Validated @RequestBody WeCategory category) {
weCategoryService.insertWeCategory(category);
return AjaxResult.success();
}
......@@ -71,7 +72,7 @@ public class WeCategoryController extends BaseController {
@Log(title = "更新目录", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation("更新目录")
public AjaxResult edit(@RequestBody WeCategory category) {
public AjaxResult edit(@Validated @RequestBody WeCategory category) {
weCategoryService.updateWeCategory(category);
return AjaxResult.success();
}
......
......@@ -11,6 +11,8 @@ import lombok.experimental.SuperBuilder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
@Data
@TableName("we_category")
@SuperBuilder
......@@ -31,6 +33,7 @@ public class WeCategory extends BaseEntity {
@ApiModelProperty("分类名称")
@NotEmpty(message = "分类名称不能为空")
private String name;
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.core.domain.Tree;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.SnowFlakeUtil;
......@@ -62,7 +63,7 @@ public class WeCategoryServiceImpl extends ServiceImpl<WeCategoryMapper,WeCatego
public List<? extends Tree<?>> findWeCategoryByMediaType(String mediaType) {
List<WeCategory> weCategories = this.list(new LambdaQueryWrapper<WeCategory>()
.eq(WeCategory::getMediaType,mediaType)
.eq(WeCategory::getDelFlag,Constants.NORMAL_CODE));
.eq(WeCategory::getDelFlag,Constants.NORMAL_CODE).orderByDesc(BaseEntity::getCreateTime));
List<WeCategoryVo> weCategoryVos = new ArrayList<>();
weCategories.forEach(c -> {
WeCategoryVo weCategoryVo = new WeCategoryVo();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!