This commit is contained in:
sxu 2023-12-05 21:24:31 +08:00
parent 68a8915d36
commit a5fc2bb3d5
6 changed files with 15 additions and 7 deletions

View File

@ -33,4 +33,5 @@ public class UserCollect extends BaseEntity
@Excel(name = "收藏时间") @Excel(name = "收藏时间")
private String time; private String time;
private Boolean isCollect;
} }

View File

@ -2,6 +2,8 @@ package com.bonus.zlpt.equip.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.util.BooleanUtil;
import com.bonus.zlpt.common.core.utils.poi.ExcelUtil; import com.bonus.zlpt.common.core.utils.poi.ExcelUtil;
import com.bonus.zlpt.common.core.web.controller.BaseController; import com.bonus.zlpt.common.core.web.controller.BaseController;
import com.bonus.zlpt.common.core.web.domain.AjaxResult; import com.bonus.zlpt.common.core.web.domain.AjaxResult;
@ -94,7 +96,12 @@ public class UserCollectController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody UserCollect userCollect) public AjaxResult edit(@RequestBody UserCollect userCollect)
{ {
return toAjax(userCollectService.updateUserCollect(userCollect)); if (BooleanUtil.isTrue(userCollect.getIsCollect())) {
userCollectService.deleteUserCollectByMaId(userCollect.getMaId());
return toAjax(userCollectService.insertUserCollect(userCollect));
} else {
return toAjax(userCollectService.deleteUserCollectByMaId(userCollect.getMaId()));
}
} }
/** /**

View File

@ -62,7 +62,7 @@ public interface UserCollectMapper
主键 主键
* @return 结果 * @return 结果
*/ */
public int deleteUserCollectById(Long id); public int deleteUserCollectByMaId(Long id);
/** /**
* 批量删除我的收藏 * 批量删除我的收藏

View File

@ -72,5 +72,5 @@ public interface IUserCollectService
主键 主键
* @return 结果 * @return 结果
*/ */
public int deleteUserCollectById(Long id); public int deleteUserCollectByMaId(Long id);
} }

View File

@ -101,8 +101,8 @@ public class UserCollectServiceImpl implements IUserCollectService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteUserCollectById(Long id) public int deleteUserCollectByMaId(Long maId)
{ {
return userCollectMapper.deleteUserCollectById(id); return userCollectMapper.deleteUserCollectByMaId(maId);
} }
} }

View File

@ -55,8 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteUserCollectById" parameterType="Long"> <delete id="deleteUserCollectByMaId" parameterType="Long">
delete from ma_user_collect where id = #{id} delete from ma_user_collect where ma_id = #{maId}
</delete> </delete>
<delete id="deleteUserCollectByIds" parameterType="String"> <delete id="deleteUserCollectByIds" parameterType="String">