Commit 90a39a5d authored by curryft's avatar curryft

批量删除

parent 02db6bea
......@@ -173,6 +173,7 @@ public class BLessonServiceImpl implements BLessonService {
}
BLesson bLesson = new BLesson();
bLesson.setBusinessId(id);
bLesson.setDeleted();
UserUtil.setCurrentMergeOperation(bLesson);
int line = bLessonRepository.logicalDelete(bLesson);
//int line = bLessonRepository.deleteByPrimaryKey(id);
......
......@@ -40,7 +40,7 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="添加", notes="添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping
@PreAuthorize("hasRole('ROLE_1001')")
@PreAuthorize("hasRole('ROLE_1002')")
public Result add(@Valid TQuestion tQuestion, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR.getCode(),
......@@ -55,9 +55,9 @@ public class TQuestionController extends PaginationController<TQuestion> {
}
@ApiOperation(value="删除题目", notes="根据ID删除一个题")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "businessId", required = false, dataType = "varchar")})
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")})
@PostMapping("/remove")
@PreAuthorize("hasRole('ROLE_1001')")
@PreAuthorize("hasRole('ROLE_1002')")
public Result delete(@PathVariable String id) {
TQuestion tQuestion = new TQuestion();
tQuestion.setBusinessId(id);
......@@ -69,10 +69,22 @@ public class TQuestionController extends PaginationController<TQuestion> {
id);
}
@ApiOperation(value="批量删除", notes="根据ID批量删除")
@ApiImplicitParams({@ApiImplicitParam(name = "id数组", value = "businessId数组", required = true, dataType = "varchar")})
@PostMapping("/removeByIds")
@PreAuthorize("hasRole('ROLE_1002')")
public Result deletes(@PathVariable String idInfoList ) {
PersistModel data = new PersistModel(tQuestionServiceImpl.removeByIds(idInfoList));
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
idInfoList);
}
@ApiOperation(value="修改", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PutMapping("/{id:\\d+}")
@PreAuthorize("hasRole('ROLE_1001')")
@PreAuthorize("hasRole('ROLE_1002')")
public Result update(@Valid TQuestion tQuestion, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR.getCode(),
......@@ -88,7 +100,7 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="唯一查找", notes="根据ID查找一条记录")
@GetMapping("/one")
@PreAuthorize("hasRole('ROLE_1001')")
@PreAuthorize("hasRole('ROLE_1002')")
public Result detail(@PathVariable String id) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -100,6 +112,7 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiImplicitParams({@ApiImplicitParam(name = "qtype" , value = "题目类型" , required = false , dataType = "varchar"),
@ApiImplicitParam(name = "qtitle" , value = "关键字" , required = false , dataType = "varchar")})
@GetMapping(value = "/queryTQuestionByPagination")
@PreAuthorize("hasRole('ROLE_1002')")
public GridModel listByPagination(TQuestion tQuestion) {
tQuestion.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
tQuestionServiceImpl.findAllByPagination(getPaginationUtility(), tQuestion);
......@@ -109,6 +122,7 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="根据条件查询", notes="根据URL中的参数查询全部")
@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")
@GetMapping(value = "/queryTQestions")
@PreAuthorize("hasRole('ROLE_1002')")
public Result queryTQestion(TQuestion tQuestion) {
tQuestion.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
return Result.builder(new PersistModel(1),
......
package org.rcisoft.business.tquestion.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.tquestion.entity.TQuestionOptions;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.tquestion.entity.TQuestion;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.core.model.PersistModel;
import org.springframework.stereotype.Repository;
......@@ -39,11 +38,14 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
@Select("<script>select * "
+"from t_question tq"
+"left join t_question_options tqo on tqo.business_id = tq.business_id"
+"left join t_question_options tqo on tqo.qid = tq.business_id"
+"where 1=1"
+"<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+"<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+"<if test=\"business_id != null and business_id != ''\">and business_id = #{business_id}</if>")
+"<if test=\"business_id != null and business_id != ''\">and business_id = #{business_id}</if><script>")
List<TQuestion> queryTQuestions(TQuestion tQuestion);
@Update("<script> update t_question set del_flag = 1 and flag = 0 where FIND_IN_SET(business_id,idInfoList)<script>")
int deleteByIds(String idInfoList);
}
......@@ -50,4 +50,5 @@ public interface TQuestionService {
List<TQuestion> queryTQuestions(TQuestion tQuestion);
int removeByIds(String idInfoList);
}
......@@ -111,4 +111,9 @@ public class TQuestionServiceImpl implements TQuestionService {
return tQuestionRepository.queryTQuestions(tQuestion);
}
@Override
public int removeByIds(String idInfoList) {
return tQuestionRepository.deleteByIds(idInfoList);
}
}
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