[improvement](chat) fix checkstyle error in CollectService (#439)

This commit is contained in:
lexluo09
2023-11-28 00:39:22 +08:00
committed by GitHub
parent 02b9dc6947
commit 7c7ccadcfd
5 changed files with 25 additions and 31 deletions

View File

@@ -5,27 +5,21 @@ import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.semantic.model.domain.CollectService;
import com.tencent.supersonic.semantic.model.domain.dataobject.CollectDO;
import com.tencent.supersonic.semantic.model.infrastructure.mapper.CollectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class CollectServiceImpl implements CollectService {
public static final String type = "metric";
@Resource
private CollectMapper collectMapper;
String type = "metric";
@Override
public Boolean createCollectionIndicators(User user, Long id) {
CollectDO collectDO = new CollectDO();
@@ -39,18 +33,18 @@ public class CollectServiceImpl implements CollectService {
@Override
public Boolean deleteCollectionIndicators(User user, Long id) {
QueryWrapper<CollectDO> collectDOQueryWrapper = new QueryWrapper<>();
collectDOQueryWrapper.lambda().eq(CollectDO::getUsername,user.getName());
collectDOQueryWrapper.lambda().eq(CollectDO::getCollectId,id);
collectDOQueryWrapper.lambda().eq(CollectDO::getType,type);
collectDOQueryWrapper.lambda().eq(CollectDO::getUsername, user.getName());
collectDOQueryWrapper.lambda().eq(CollectDO::getCollectId, id);
collectDOQueryWrapper.lambda().eq(CollectDO::getType, type);
collectMapper.delete(collectDOQueryWrapper);
return true;
}
@Override
public List<CollectDO> getCollectList(String username) {
public List<CollectDO> getCollectList(String username) {
QueryWrapper<CollectDO> queryWrapper = new QueryWrapper<>();
if (!StringUtils.isEmpty(username)){
queryWrapper.lambda().eq(CollectDO::getUsername,username);
if (!StringUtils.isEmpty(username)) {
queryWrapper.lambda().eq(CollectDO::getUsername, username);
}
return collectMapper.selectList(queryWrapper);
}

View File

@@ -65,11 +65,11 @@ public class MetricServiceImpl implements MetricService {
private ApplicationEventPublisher eventPublisher;
public MetricServiceImpl(MetricRepository metricRepository,
ModelService modelService,
DomainService domainService,
ChatGptHelper chatGptHelper,
CollectService collectService,
ApplicationEventPublisher eventPublisher) {
ModelService modelService,
DomainService domainService,
ChatGptHelper chatGptHelper,
CollectService collectService,
ApplicationEventPublisher eventPublisher) {
this.domainService = domainService;
this.metricRepository = metricRepository;
this.modelService = modelService;
@@ -185,7 +185,7 @@ public class MetricServiceImpl implements MetricService {
BeanUtils.copyProperties(metricDOPageInfo, pageInfo);
List<CollectDO> collectList = collectService.getCollectList(user.getName());
List<Long> collect = collectList.stream().map(CollectDO::getCollectId).collect(Collectors.toList());
List<MetricResp> metricResps = convertList(metricDOPageInfo.getList(),collect);
List<MetricResp> metricResps = convertList(metricDOPageInfo.getList(), collect);
fillAdminRes(metricResps, user);
pageInfo.setList(metricResps);
return pageInfo;

View File

@@ -14,7 +14,7 @@ public interface CollectService {
Boolean createCollectionIndicators(User user, Long id);
Boolean deleteCollectionIndicators(User user,Long id);
Boolean deleteCollectionIndicators(User user, Long id);
List<CollectDO> getCollectList(String username);

View File

@@ -66,9 +66,9 @@ public class MetricConverter {
metricResp.setModelName(modelResp.getName());
metricResp.setDomainId(modelResp.getDomainId());
}
if (collect != null && collect.contains(metricDO.getId())){
if (collect != null && collect.contains(metricDO.getId())) {
metricResp.setIsCollect(true);
}else {
} else {
metricResp.setIsCollect(false);
}
metricResp.setTag(metricDO.getTags());

View File

@@ -30,8 +30,8 @@ public class CollectController {
@PostMapping("/createCollectionIndicators")
public boolean createCollectionIndicators(@RequestBody CollectDO collectDO,
HttpServletRequest request,
HttpServletResponse response) {
HttpServletRequest request,
HttpServletResponse response) {
User user = UserHolder.findUser(request, response);
return collectService.createCollectionIndicators(user, collectDO.getId());
}
@@ -39,10 +39,10 @@ public class CollectController {
@DeleteMapping("/deleteCollectionIndicators/{id}")
public boolean deleteCollectionIndicators(@PathVariable Long id,
HttpServletRequest request,
HttpServletResponse response) {
HttpServletRequest request,
HttpServletResponse response) {
User user = UserHolder.findUser(request, response);
return collectService.deleteCollectionIndicators(user,id);
return collectService.deleteCollectionIndicators(user, id);
}
}