mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
Co-authored-by: lxwcodemonkey
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.tencent.supersonic.headless.server.rest;
|
package com.tencent.supersonic.headless.server.rest;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.headless.api.pojo.request.MetaBatchReq;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@@ -37,13 +38,22 @@ public class TermController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public List<TermResp> getTerms(@RequestParam("domainId") Long domainId) {
|
public List<TermResp> getTerms(@RequestParam("domainId") Long domainId,
|
||||||
return termService.getTerms(domainId);
|
@RequestParam(name = "queryKey", required = false) String queryKey) {
|
||||||
|
return termService.getTerms(domainId, queryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public boolean delete(@PathVariable("id") Long id) {
|
public boolean delete(@PathVariable("id") Long id) {
|
||||||
termService.delete(id);
|
termService.delete(id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteBatch")
|
||||||
|
public boolean deleteBatch(@RequestBody MetaBatchReq metaBatchReq) {
|
||||||
|
termService.deleteBatch(metaBatchReq);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.tencent.supersonic.headless.server.service;
|
package com.tencent.supersonic.headless.server.service;
|
||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
|
import com.tencent.supersonic.headless.api.pojo.request.MetaBatchReq;
|
||||||
import com.tencent.supersonic.headless.api.pojo.request.TermReq;
|
import com.tencent.supersonic.headless.api.pojo.request.TermReq;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.TermResp;
|
import com.tencent.supersonic.headless.api.pojo.response.TermResp;
|
||||||
|
|
||||||
@@ -14,7 +15,9 @@ public interface TermService {
|
|||||||
|
|
||||||
void delete(Long id);
|
void delete(Long id);
|
||||||
|
|
||||||
List<TermResp> getTerms(Long domainId);
|
void deleteBatch(MetaBatchReq metaBatchReq);
|
||||||
|
|
||||||
|
List<TermResp> getTerms(Long domainId, String queryKey);
|
||||||
|
|
||||||
Map<Long, List<TermResp>> getTermSets(Set<Long> domainIds);
|
Map<Long, List<TermResp>> getTermSets(Set<Long> domainIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
import com.tencent.supersonic.common.util.BeanMapper;
|
import com.tencent.supersonic.common.util.BeanMapper;
|
||||||
import com.tencent.supersonic.common.util.JsonUtil;
|
import com.tencent.supersonic.common.util.JsonUtil;
|
||||||
|
import com.tencent.supersonic.headless.api.pojo.request.MetaBatchReq;
|
||||||
import com.tencent.supersonic.headless.api.pojo.request.TermReq;
|
import com.tencent.supersonic.headless.api.pojo.request.TermReq;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.TermResp;
|
import com.tencent.supersonic.headless.api.pojo.response.TermResp;
|
||||||
import com.tencent.supersonic.headless.server.persistence.dataobject.TermDO;
|
import com.tencent.supersonic.headless.server.persistence.dataobject.TermDO;
|
||||||
import com.tencent.supersonic.headless.server.persistence.mapper.TermMapper;
|
import com.tencent.supersonic.headless.server.persistence.mapper.TermMapper;
|
||||||
import com.tencent.supersonic.headless.server.service.TermService;
|
import com.tencent.supersonic.headless.server.service.TermService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
@@ -42,9 +44,26 @@ public class TermServiceImpl extends ServiceImpl<TermMapper, TermDO> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TermResp> getTerms(Long domainId) {
|
public void deleteBatch(MetaBatchReq metaBatchReq) {
|
||||||
|
if (CollectionUtils.isEmpty(metaBatchReq.getIds())) {
|
||||||
|
throw new RuntimeException("术语ID不可为空");
|
||||||
|
}
|
||||||
|
removeBatchByIds(metaBatchReq.getIds());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TermResp> getTerms(Long domainId, String queryKey) {
|
||||||
QueryWrapper<TermDO> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<TermDO> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(TermDO::getDomainId, domainId);
|
queryWrapper.lambda().eq(TermDO::getDomainId, domainId);
|
||||||
|
if (StringUtils.isNotBlank(queryKey)) {
|
||||||
|
queryWrapper.lambda().and(i ->
|
||||||
|
i.like(TermDO::getName, queryKey)
|
||||||
|
.or()
|
||||||
|
.like(TermDO::getDescription, queryKey)
|
||||||
|
.or()
|
||||||
|
.like(TermDO::getAlias, queryKey)
|
||||||
|
);
|
||||||
|
}
|
||||||
List<TermDO> termDOS = list(queryWrapper);
|
List<TermDO> termDOS = list(queryWrapper);
|
||||||
return termDOS.stream().map(this::convert).collect(Collectors.toList());
|
return termDOS.stream().map(this::convert).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user