| | |
| | | package cn.gistack.sm.collect.service.impl; |
| | | |
| | | import cn.gistack.sm.collect.vo.CollectVO; |
| | | import cn.gistack.sm.collect.entity.UserCollect; |
| | | import cn.gistack.sm.collect.mapper.UserCollectMapper; |
| | | import cn.gistack.sm.collect.service.IUserCollectService; |
| | |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class UserCollectServiceImpl extends BaseServiceImpl<UserCollectMapper, UserCollect> implements IUserCollectService { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateCollect(UserCollect userCollect) { |
| | | public String updateCollect(UserCollect userCollect) { |
| | | if (ObjectUtil.isEmpty(userCollect.getUserId())){ |
| | | userCollect.setUserId(AuthUtil.getUserId().toString()); |
| | | } |
| | |
| | | UserCollect detail = baseMapper.selectOne(Condition.getQueryWrapper(params)); |
| | | if (ObjectUtil.isEmpty(detail)){ |
| | | //库里不存在该数据就新增 |
| | | return save(userCollect); |
| | | save(userCollect); |
| | | }else { |
| | | //更新收藏状态 |
| | | detail.setStatus(userCollect.getStatus()); |
| | | return updateById(detail); |
| | | updateById(detail); |
| | | } |
| | | return baseMapper.getMyCollect(userCollect.getUserId()); |
| | | } |
| | | |
| | | @Override |
| | | public List<CollectVO> getMyCollectVO(String userId) { |
| | | return baseMapper.getMyCollectVO(userId); |
| | | } |
| | | |
| | | |