feat:增加标签功能

This commit is contained in:
lvxudong 2023-11-09 17:21:45 +08:00
parent d83ce56244
commit 3e69a02f7d
7 changed files with 57 additions and 20 deletions

View File

@ -127,7 +127,7 @@ security:
# 多租户配置
tenant:
# 是否开启
enable: true
enable: false
# 排除表
excludes:
- sys_menu
@ -138,6 +138,8 @@ tenant:
- sys_user_post
- sys_user_role
- sys_client
- f_labels
- f_questions
# MyBatisPlus配置
# https://baomidou.com/config/

View File

@ -90,6 +90,14 @@ public class LabelsController extends BaseController {
return toAjax(labelsService.updateByBo(bo));
}
@SaCheckPermission("question:label:edit")
@Log(title = "题目标签", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping("changeStatus")
public R<Void> changeStatus(@RequestBody LabelsBo bo) {
return toAjax(labelsService.updateStatusByBo(bo));
}
/**
* 删除题目标签
*

View File

@ -1,11 +1,10 @@
package org.dromara.question.domain;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.util.Date;
/**
* 题目标签对象 f_labels
@ -14,17 +13,13 @@ import java.io.Serial;
* @date 2023-11-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("f_labels")
public class Labels extends BaseEntity {
public class Labels {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
@ -37,5 +32,15 @@ public class Labels extends BaseEntity {
*/
private Integer status;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}

View File

@ -1,5 +1,7 @@
package org.dromara.question.domain.bo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import org.dromara.question.domain.Labels;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
@ -9,6 +11,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.Date;
/**
* 题目标签业务对象 f_labels
*
@ -16,9 +20,8 @@ import jakarta.validation.constraints.*;
* @date 2023-11-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = Labels.class, reverseConvertGenerate = false)
public class LabelsBo extends BaseEntity {
public class LabelsBo {
/**
*
@ -38,5 +41,17 @@ public class LabelsBo extends BaseEntity {
@NotNull(message = "标签状态 1启用 0禁用不能为空", groups = { AddGroup.class, EditGroup.class })
private Integer status;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}

View File

@ -43,7 +43,7 @@ public class LabelsVo implements Serializable {
/**
* 标签状态 1启用 0禁用
*/
@ExcelProperty(value = "标签状态 1启用 0禁用")
@ExcelProperty(value = "标签状态")
private Integer status;

View File

@ -1,10 +1,9 @@
package org.dromara.question.service;
import org.dromara.question.domain.Labels;
import org.dromara.question.domain.vo.LabelsVo;
import org.dromara.question.domain.bo.LabelsBo;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.question.domain.bo.LabelsBo;
import org.dromara.question.domain.vo.LabelsVo;
import java.util.Collection;
import java.util.List;
@ -41,6 +40,7 @@ public interface ILabelsService {
* 修改题目标签
*/
Boolean updateByBo(LabelsBo bo);
Boolean updateStatusByBo(LabelsBo bo);
/**
* 校验并批量删除题目标签信息

View File

@ -1,5 +1,6 @@
package org.dromara.question.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -59,7 +60,6 @@ public class LabelsServiceImpl implements ILabelsService {
}
private LambdaQueryWrapper<Labels> buildQueryWrapper(LabelsBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<Labels> lqw = Wrappers.lambdaQuery();
lqw.eq(StringUtils.isNotBlank(bo.getLabel()), Labels::getLabel, bo.getLabel());
lqw.eq(bo.getStatus() != null, Labels::getStatus, bo.getStatus());
@ -90,6 +90,13 @@ public class LabelsServiceImpl implements ILabelsService {
return baseMapper.updateById(update) > 0;
}
@Override
public Boolean updateStatusByBo(LabelsBo bo) {
Labels update = MapstructUtils.convert(bo, Labels.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/