|
@@ -2,13 +2,19 @@ package cn.rankin.userservice.service;
|
|
|
|
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
|
+import cn.rankin.common.utils.enums.BaseStatusEnum;
|
|
|
import cn.rankin.data.api.user.dto.CollectionDTO;
|
|
|
import cn.rankin.data.api.user.entity.Collection;
|
|
|
+import cn.rankin.userservice.code.UserServiceAPICode;
|
|
|
import cn.rankin.userservice.repository.CollectionRepository;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.rankin.userservice.utils.DTOConverter.convert;
|
|
|
+
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class CollectionService {
|
|
@@ -17,10 +23,27 @@ public class CollectionService {
|
|
|
private CollectionRepository collectionRepository;
|
|
|
|
|
|
public APIResult<Boolean> put(CollectionDTO collectionDTO) {
|
|
|
+ Collection collection = collectionRepository.findByPidAndUserId(collectionDTO.getPid(), collectionDTO.getUserId());
|
|
|
+ if (collection != null) {
|
|
|
+ if (collection.getStatus().equals(BaseStatusEnum.NORMAL)) {
|
|
|
+ return APIResult.error(UserServiceAPICode.ALREADY_EXISTS);
|
|
|
+ }else {
|
|
|
+ collection.setStatus(BaseStatusEnum.NORMAL);
|
|
|
+ collectionRepository.save(collection);
|
|
|
+ return APIResult.ok(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Collection newCollection = convert(collectionDTO);
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public APIResult<Page<Collection>> getPage(String userId, Integer start, Integer size) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public APIResult<Page<Collection>> getCollections(String userId, Integer start, Integer size) {
|
|
|
+ public APIResult<List<Collection>> gets(String userId, Integer size) {
|
|
|
return null;
|
|
|
}
|
|
|
|