|
|
@@ -0,0 +1,112 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package org.springblade.modules.ycwh.controller.wx;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.modules.ycwh.entity.LikeInfoEntity;
|
|
|
+import org.springblade.modules.ycwh.service.ILikeInfoService;
|
|
|
+import org.springblade.modules.ycwh.vo.LikeInfoVO;
|
|
|
+import org.springblade.modules.ycwh.wrapper.LikeInfoWrapper;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 名菜名点名店收藏 控制器
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2023-08-29
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("yuecai-wx/like_info")
|
|
|
+@Api(value = "名菜名点名店收藏", tags = "名菜名点名店收藏接口")
|
|
|
+public class WXLikeInfoController extends BladeController {
|
|
|
+
|
|
|
+ private final ILikeInfoService likeInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 名菜名点名店收藏 分页
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "分页", notes = "传入likeInfo")
|
|
|
+ public R<IPage<LikeInfoVO>> list(@ApiIgnore @RequestParam Map<String, Object> likeInfo, Query query) {
|
|
|
+ BladeUser user = AuthUtil.getUser();
|
|
|
+ if (Func.isEmpty(user)) {
|
|
|
+ return R.fail("未登录");
|
|
|
+ }
|
|
|
+ QueryWrapper<LikeInfoEntity> qw = Condition.getQueryWrapper(likeInfo, LikeInfoEntity.class);
|
|
|
+ qw.eq("member_id", user.getUserId());
|
|
|
+ IPage<LikeInfoEntity> pages = likeInfoService.page(Condition.getPage(query), qw);
|
|
|
+ return R.data(LikeInfoWrapper.build().pageVO(pages));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 名菜名点名店收藏 新增
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "新增", notes = "传入likeInfo")
|
|
|
+ public R save(@Valid @RequestBody LikeInfoEntity likeInfo) {
|
|
|
+ BladeUser user = AuthUtil.getUser();
|
|
|
+ if (Func.isEmpty(user)) {
|
|
|
+ return R.fail("未登录");
|
|
|
+ }
|
|
|
+ if (Func.isEmpty(likeInfo.getLikeId()) || Func.isEmpty(likeInfo.getLikeType())) {
|
|
|
+ return R.fail("收藏内容有误,请重新再试");
|
|
|
+ }
|
|
|
+ likeInfo.setMemberId(user.getUserId());
|
|
|
+ return R.status(likeInfoService.save(likeInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 名菜名点名店收藏 删除
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "id, 收藏类型")
|
|
|
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam Long likeId, @ApiParam(value = "收藏类型", required = true) @RequestParam String likeType) {
|
|
|
+ BladeUser user = AuthUtil.getUser();
|
|
|
+ if (Func.isEmpty(user)) {
|
|
|
+ return R.fail("未登录");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<LikeInfoEntity> lqw = new LambdaQueryWrapper();
|
|
|
+ lqw.eq(LikeInfoEntity::getMemberId, user.getUserId());
|
|
|
+ lqw.eq(LikeInfoEntity::getLikeId, likeId);
|
|
|
+ lqw.eq(LikeInfoEntity::getLikeType, likeType);
|
|
|
+ return R.status(likeInfoService.remove(lqw));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|