|
@@ -0,0 +1,49 @@
|
|
|
|
+package com.ruoyi.generator.service;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityCollectionUser;
|
|
|
|
+import com.ruoyi.generator.domain.Community.CommunityTagBlock;
|
|
|
|
+import com.ruoyi.generator.mapper.community.CommunityCollectionMapper;
|
|
|
|
+import com.ruoyi.generator.mapper.community.CommunityCollectionUserMapper;
|
|
|
|
+import com.ruoyi.generator.mapper.community.CommunityTagBlockMapper;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class CommunityCollectionUserImpl extends ServiceImpl<CommunityCollectionUserMapper, CommunityCollectionUser> implements ICommunityCollectionUserService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommunityCollectionUserMapper communityCollectionUserMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CommunityCollectionUser subscribeCollection(CommunityCollectionUser communityCollectionUser) {
|
|
|
|
+ CommunityCollectionUser collectionUser = communityCollectionUserMapper.selectOne(new QueryWrapper<CommunityCollectionUser>()
|
|
|
|
+ .eq("user_id", communityCollectionUser.getUserId())
|
|
|
|
+ .eq("collection_id", communityCollectionUser.getCollectionId()));
|
|
|
|
+
|
|
|
|
+ if (collectionUser != null) {
|
|
|
|
+ Boolean isdelete = false;
|
|
|
|
+ //是否取关
|
|
|
|
+ if (!collectionUser.isDelete()) {
|
|
|
|
+ isdelete = true;
|
|
|
|
+ }
|
|
|
|
+ collectionUser.setDelete(isdelete);
|
|
|
|
+ collectionUser.setUpdateBy(communityCollectionUser.getUserId());
|
|
|
|
+ collectionUser.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ communityCollectionUserMapper.updateById(collectionUser);
|
|
|
|
+ return collectionUser;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //新增记录
|
|
|
|
+ collectionUser = new CommunityCollectionUser();
|
|
|
|
+ BeanUtils.copyProperties(communityCollectionUser, collectionUser);
|
|
|
|
+ collectionUser.setCreateBy(communityCollectionUser.getUserId());
|
|
|
|
+ collectionUser.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ communityCollectionUserMapper.insert(collectionUser);
|
|
|
|
+ return collectionUser;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|