题目状态
This commit is contained in:
parent
01e9b12eaf
commit
16bac95dee
@ -80,7 +80,7 @@ public class AiolQuestionController extends JeecgController<AiolQuestion, IAiolQ
|
|||||||
IPage<AiolQuestion> pageList = aiolQuestionService.page(page, queryWrapper);
|
IPage<AiolQuestion> pageList = aiolQuestionService.page(page, queryWrapper);
|
||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加
|
* 添加
|
||||||
*
|
*
|
||||||
@ -93,16 +93,38 @@ public class AiolQuestionController extends JeecgController<AiolQuestion, IAiolQ
|
|||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result<String> add(@RequestBody AiolQuestion aiolQuestion,@RequestParam String repoId) {
|
public Result<String> add(@RequestBody AiolQuestion aiolQuestion,@RequestParam String repoId) {
|
||||||
|
aiolQuestion.setStatus(1);
|
||||||
aiolQuestionService.save(aiolQuestion);
|
aiolQuestionService.save(aiolQuestion);
|
||||||
//题库题目添加
|
//题库题目添加
|
||||||
if(repoId!=null&& !repoId.isEmpty()){
|
if(repoId!=null&& !repoId.isEmpty()){
|
||||||
AiolQuestionRepo aiolQuestionRepo = new AiolQuestionRepo();
|
AiolQuestionRepo aiolQuestionRepo = new AiolQuestionRepo();
|
||||||
aiolQuestionRepo.setRepoId(repoId);
|
aiolQuestionRepo.setRepoId(repoId);
|
||||||
aiolQuestionRepo.setQuestionId(aiolQuestion.getId());
|
aiolQuestionRepo.setQuestionId(aiolQuestion.getId());
|
||||||
|
|
||||||
aiolQuestionRepoController.add(aiolQuestionRepo);
|
aiolQuestionRepoController.add(aiolQuestionRepo);
|
||||||
}
|
}
|
||||||
return Result.OK(aiolQuestion.getId());
|
return Result.OK(aiolQuestion.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AutoLog(value = "题目-是否入库")
|
||||||
|
@Operation(summary="题目-是否入库")
|
||||||
|
@PostMapping(value = "/whetherPutStorage")
|
||||||
|
public Result<String> whetherPutStorage(@RequestBody List<String> ids){
|
||||||
|
try {
|
||||||
|
// 参数校验
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
return Result.error("参数不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调用服务层更新状态
|
||||||
|
aiolQuestionService.updateStatusByIds(ids);
|
||||||
|
|
||||||
|
return Result.OK("操作成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("更新题目状态失败", e);
|
||||||
|
return Result.error("操作失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
@ -118,7 +140,7 @@ public class AiolQuestionController extends JeecgController<AiolQuestion, IAiolQ
|
|||||||
aiolQuestionService.updateById(aiolQuestion);
|
aiolQuestionService.updateById(aiolQuestion);
|
||||||
return Result.OK("编辑成功!");
|
return Result.OK("编辑成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除
|
* 通过id删除
|
||||||
*
|
*
|
||||||
@ -133,7 +155,7 @@ public class AiolQuestionController extends JeecgController<AiolQuestion, IAiolQ
|
|||||||
aiolQuestionService.removeById(id);
|
aiolQuestionService.removeById(id);
|
||||||
return Result.OK("删除成功!");
|
return Result.OK("删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
*
|
*
|
||||||
@ -148,7 +170,7 @@ public class AiolQuestionController extends JeecgController<AiolQuestion, IAiolQ
|
|||||||
this.aiolQuestionService.removeByIds(Arrays.asList(ids.split(",")));
|
this.aiolQuestionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
return Result.OK("批量删除成功!");
|
return Result.OK("批量删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id查询
|
* 通过id查询
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,8 @@ package org.jeecg.modules.aiol.service;
|
|||||||
import org.jeecg.modules.aiol.entity.AiolQuestion;
|
import org.jeecg.modules.aiol.entity.AiolQuestion;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 题目
|
* @Description: 题目
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
@ -11,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface IAiolQuestionService extends IService<AiolQuestion> {
|
public interface IAiolQuestionService extends IService<AiolQuestion> {
|
||||||
|
|
||||||
|
void updateStatusByIds(List<String> ids);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.jeecg.modules.aiol.service.impl;
|
package org.jeecg.modules.aiol.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import org.jeecg.modules.aiol.entity.AiolQuestion;
|
import org.jeecg.modules.aiol.entity.AiolQuestion;
|
||||||
import org.jeecg.modules.aiol.mapper.AiolQuestionMapper;
|
import org.jeecg.modules.aiol.mapper.AiolQuestionMapper;
|
||||||
import org.jeecg.modules.aiol.service.IAiolQuestionService;
|
import org.jeecg.modules.aiol.service.IAiolQuestionService;
|
||||||
@ -7,6 +9,8 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 题目
|
* @Description: 题目
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
@ -16,4 +20,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
@Service
|
@Service
|
||||||
public class AiolQuestionServiceImpl extends ServiceImpl<AiolQuestionMapper, AiolQuestion> implements IAiolQuestionService {
|
public class AiolQuestionServiceImpl extends ServiceImpl<AiolQuestionMapper, AiolQuestion> implements IAiolQuestionService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateStatusByIds(List<String> ids) {
|
||||||
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
|
throw new IllegalArgumentException("题目ID列表不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量更新
|
||||||
|
LambdaUpdateWrapper<AiolQuestion> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.in(AiolQuestion::getId, ids)
|
||||||
|
.setSql("status = CASE WHEN status IS NULL OR status = 1 THEN 0 ELSE 1 END");
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user