Commit b82bb4a7 authored by 万成波's avatar 万成波

优化代码

parent efb37816
......@@ -28,7 +28,7 @@ public class MybatisPlusConfig {
// 乐观锁插件
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
// 阻断插件
interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
// interceptor.addInnerInterceptor(blockAttackInnerInterceptor());
return interceptor;
}
......
......@@ -80,6 +80,19 @@ public class BbsGradeController extends BaseController {
}
/**
* 修改用户初始等级值
*/
@ApiOperation("修改用户等级")
@PreAuthorize("@ss.hasPermi('bbs:grade:edit')")
@Log(title = "用户等级", businessType = BusinessType.UPDATE)
@PutMapping("/initial")
public AjaxResult editInitial(@RequestBody BbsGrade grade) {
this.bbsGradeService.editGradeInitial(grade);
return AjaxResult.success();
}
/**
* 删除用户等级
*/
......
......@@ -58,4 +58,9 @@ public class BbsGrade extends BaseEntity {
@ApiModelProperty("排序值(升序)")
private Integer sort;
/** 是否初始等级:0 否、1 是 */
@Excel(name = "是否初始等级")
@ApiModelProperty("是否初始等级")
private Integer isInitial;
}
package com.tangguo.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 是否初始等级
*
* @author 谈笑
* @createTime 2025-09-02 09:33:33 星期二
*/
@Getter
@AllArgsConstructor
public enum IsInitialGrade {
YES(1, "初始等级"), NO(0, "非初始等级");
private final int value;
private final String desc;
}
......@@ -38,6 +38,14 @@ public interface IBbsGradeService extends IService<BbsGrade> {
void editGrade(BbsGrade grade);
/**
* 修改等级初始值
*
* @param grade 等级
*/
void editGradeInitial(BbsGrade grade);
/**
* 删除等级
*
......
......@@ -7,9 +7,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.common.utils.StringUtils;
import com.tangguo.domain.BbsGrade;
import com.tangguo.enums.IsInitialGrade;
import com.tangguo.mapper.BbsGradeMapper;
import com.tangguo.service.IBbsGradeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......@@ -37,10 +39,9 @@ public class BbsGradeServiceImpl extends ServiceImpl<BbsGradeMapper, BbsGrade> i
@Override
public List<BbsGrade> selectBbsGradeList(BbsGrade grade) {
LambdaQueryWrapper<BbsGrade> lqw = Wrappers.lambdaQuery();
lqw.orderByDesc(BbsGrade::getCreateTime);
lqw.like(StringUtils.isNotBlank(grade.getName()), BbsGrade::getName, grade.getName());
lqw.eq(StringUtils.isNotBlank(grade.getCode()), BbsGrade::getCode, grade.getCode());
lqw.eq(grade.getSort() != null, BbsGrade::getSort, grade.getSort());
lqw.orderByAsc(BbsGrade::getCreateTime);
return bbsGradeMapper.selectList(lqw);
}
......@@ -129,6 +130,32 @@ public class BbsGradeServiceImpl extends ServiceImpl<BbsGradeMapper, BbsGrade> i
}
/**
* 修改等级初始值
*
* @param grade 等级
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void editGradeInitial(BbsGrade grade) {
BbsGrade dbGrade = this.getById(grade.getId());
if (Objects.isNull(dbGrade)) {
throw new ServiceException("修改失败,未查询到当前等级数据。");
}
Integer isInitial = grade.getIsInitial();
if (!dbGrade.getIsInitial().equals(isInitial)) {
if (IsInitialGrade.YES.getValue() == isInitial) {
this.update(Wrappers.lambdaUpdate(BbsGrade.class)
.set(BbsGrade::getIsInitial, IsInitialGrade.NO.getValue()));
}
this.update(Wrappers.lambdaUpdate(BbsGrade.class)
.set(BbsGrade::getIsInitial, isInitial)
.eq(BbsGrade::getId, dbGrade.getId()));
}
}
/**
* 删除等级
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment