This commit is contained in:
sxu 2023-12-05 21:38:30 +08:00
parent a5fc2bb3d5
commit 1df7b972e7
1 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package com.bonus.zlpt.equip.controller; package com.bonus.zlpt.equip.controller;
import java.util.List; import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.BooleanUtil;
@ -11,6 +12,8 @@ import com.bonus.zlpt.common.core.web.page.TableDataInfo;
import com.bonus.zlpt.common.log.annotation.Log; import com.bonus.zlpt.common.log.annotation.Log;
import com.bonus.zlpt.common.log.enums.BusinessType; import com.bonus.zlpt.common.log.enums.BusinessType;
import com.bonus.zlpt.common.security.annotation.RequiresPermissions; import com.bonus.zlpt.common.security.annotation.RequiresPermissions;
import com.bonus.zlpt.common.security.utils.SecurityUtils;
import com.bonus.zlpt.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -96,12 +99,17 @@ public class UserCollectController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody UserCollect userCollect) public AjaxResult edit(@RequestBody UserCollect userCollect)
{ {
if (BooleanUtil.isTrue(userCollect.getIsCollect())) { LoginUser loginUser = SecurityUtils.getLoginUser();
userCollectService.deleteUserCollectByMaId(userCollect.getMaId()); if (Objects.nonNull(loginUser)) {
return toAjax(userCollectService.insertUserCollect(userCollect)); userCollect.setUserId(loginUser.getUserid());
} else { if (BooleanUtil.isTrue(userCollect.getIsCollect())) {
return toAjax(userCollectService.deleteUserCollectByMaId(userCollect.getMaId())); userCollectService.deleteUserCollectByMaId(userCollect.getMaId());
return toAjax(userCollectService.insertUserCollect(userCollect));
} else {
return toAjax(userCollectService.deleteUserCollectByMaId(userCollect.getMaId()));
}
} }
return null;
} }
/** /**