| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.linghu.mapper.KeywordMapper; |
| | | import com.linghu.mapper.ReferenceMapper; |
| | | import com.linghu.model.common.ResponseResult; |
| | | import com.linghu.model.entity.Keyword; |
| | | import com.linghu.model.entity.Type; |
| | | import com.linghu.service.TypeService; |
| | | import com.linghu.mapper.TypeMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author xy |
| | |
| | | implements TypeService { |
| | | @Resource |
| | | private TypeMapper typeMapper; |
| | | @Autowired |
| | | private KeywordMapper keywordMapper; |
| | | @Override |
| | | public Type getTypeByName(String typeName) { |
| | | // 查询 |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ResponseResult<Type> addType(Type type) { |
| | | boolean success = this.save(type); |
| | | if (success) { |
| | | return ResponseResult.success(type); |
| | | } |
| | | return ResponseResult.error("添加类型失败"); |
| | | } |
| | | |
| | | @Override |
| | | public ResponseResult<Void> batchDeleteTypes(List<Integer> typeIds) { |
| | | List<Type> types = typeIds.stream().map(id -> { |
| | | Type type = new Type(); |
| | | type.setType_id(id); |
| | | return type; |
| | | }).collect(Collectors.toList()); |
| | | boolean success = this.updateBatchById(types); |
| | | if (success) { |
| | | return ResponseResult.success(); |
| | | } |
| | | return ResponseResult.error("批量删除类型失败"); |
| | | } |
| | | |
| | | @Override |
| | | public ResponseResult<List<Type>> pageList(Integer keywordId, Integer questionId, Integer isNow) { |
| | | List<Integer> typeIds=new ArrayList<>(); |
| | | Keyword keyword=new Keyword(); |
| | | //先查找当前关键词下,所有的回答 的 所有的平台名称 |
| | | if (keywordId != null) { |
| | | keyword = keywordMapper.selectById(keywordId); |
| | | } |
| | | |
| | | |
| | | typeIds= keywordMapper.getTypeIds(keywordId, questionId, isNow,keyword); |
| | | LambdaQueryWrapper<Type> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (!typeIds.isEmpty()) { |
| | | queryWrapper.in(Type::getType_id, typeIds); |
| | | }else { |
| | | if (keywordId != null) { |
| | | return ResponseResult.success(new ArrayList<>()); |
| | | |
| | | }else { |
| | | List<Type> list = this.list(queryWrapper); |
| | | return ResponseResult.success(list); |
| | | } |
| | | |
| | | } |
| | | List<Type> list = this.list(queryWrapper); |
| | | return ResponseResult.success(list); |
| | | } |
| | | |
| | | } |