|
|
|
|
@ -1,74 +1,97 @@
|
|
|
|
|
package com.macro.mall.portal.controller;
|
|
|
|
|
|
|
|
|
|
import com.macro.mall.common.api.CommonPage;
|
|
|
|
|
import com.macro.mall.common.api.CommonResult;
|
|
|
|
|
import com.macro.mall.portal.domain.MemberBrandAttention;
|
|
|
|
|
import com.macro.mall.portal.service.MemberAttentionService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
package com.macro.mall.portal.controller;// 声明包名
|
|
|
|
|
import com.macro.mall.common.api.CommonPage;// 导入通用分页对象,用于分页查询结果的封装
|
|
|
|
|
import com.macro.mall.common.api.CommonResult;// 导入通用结果对象,用于统一返回结果的封装
|
|
|
|
|
import com.macro.mall.portal.domain.MemberBrandAttention;// 导入会员品牌关注实体类,用于封装会员关注品牌的相关信息
|
|
|
|
|
import com.macro.mall.portal.service.MemberAttentionService;// 导入会员关注服务接口,用于业务逻辑处理
|
|
|
|
|
import io.swagger.annotations.Api;// 导入Swagger注解,用于接口文档的生成
|
|
|
|
|
import io.swagger.annotations.ApiOperation;// 导入所需的类
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;// 导入OpenAPI 3.0的注解,用于接口文档的生成
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;// 导入Spring框架的自动注入注解,用于依赖注入
|
|
|
|
|
import org.springframework.data.domain.Page;// 导入Spring Data的Page接口,用于分页查询
|
|
|
|
|
import org.springframework.stereotype.Controller;// 导入Spring框架的控制器注解,标识这是一个控制器类
|
|
|
|
|
import org.springframework.web.bind.annotation.*;// 导入Spring框架的请求映射注解,用于映射URL到对应的方法
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 会员品牌关注管理Controller
|
|
|
|
|
* Created by macro on 2018/8/2.
|
|
|
|
|
* 会员品牌关注管理Controller//文件描述
|
|
|
|
|
* Created by macro on 2018/8/2.//创建日期
|
|
|
|
|
*/
|
|
|
|
|
@Controller
|
|
|
|
|
@Api(tags = "MemberAttentionController")
|
|
|
|
|
@Tag(name = "MemberAttentionController",description = "会员关注品牌管理")
|
|
|
|
|
@RequestMapping("/member/attention")
|
|
|
|
|
public class MemberAttentionController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MemberAttentionService memberAttentionService;
|
|
|
|
|
@ApiOperation("添加品牌关注")
|
|
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult add(@RequestBody MemberBrandAttention memberBrandAttention) {
|
|
|
|
|
int count = memberAttentionService.add(memberBrandAttention);
|
|
|
|
|
if(count>0){
|
|
|
|
|
return CommonResult.success(count);
|
|
|
|
|
}else{
|
|
|
|
|
return CommonResult.failed();
|
|
|
|
|
@Controller// 使用@Controller注解,标识这是一个Spring MVC的控制器
|
|
|
|
|
@Api(tags = "MemberAttentionController")// 使用@Api注解,为类添加Swagger文档的标签信息
|
|
|
|
|
@Tag(name = "MemberAttentionController",description = "会员关注品牌管理")// 使用@Tag注解,为类添加OpenAPI 3.0文档的标签信息
|
|
|
|
|
@RequestMapping("/member/attention")// 使用@RequestMapping注解,为类添加基础的URL映射路径
|
|
|
|
|
public class MemberAttentionController {// 定义控制器类
|
|
|
|
|
@Autowired// 使用@Autowired注解,自动注入MemberAttentionService服务
|
|
|
|
|
private MemberAttentionService memberAttentionService;// 成员变量,用于会员关注品牌的业务逻辑处理
|
|
|
|
|
/**
|
|
|
|
|
* 添加品牌关注的方法
|
|
|
|
|
* 使用@ApiOperation注解,为方法添加Swagger文档的操作描述
|
|
|
|
|
* 使用@RequestMapping注解,将URL路径映射到方法
|
|
|
|
|
* 使用@ResponseBody注解,表示方法的返回值作为响应体
|
|
|
|
|
* @param memberBrandAttention 会员品牌关注对象
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("添加品牌关注")//注解
|
|
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)//注解,用于将HTTP请求映射到特定的处理方法上
|
|
|
|
|
@ResponseBody//这个方法的返回值应该直接作为HTTP响应的正文(Body)返回
|
|
|
|
|
public CommonResult add(@RequestBody MemberBrandAttention memberBrandAttention) {// 定义方法,接收会员品牌关注对象,返回操作结果
|
|
|
|
|
int count = memberAttentionService.add(memberBrandAttention);// 调用服务层方法,添加品牌关注
|
|
|
|
|
if(count>0){// 判断操作是否成功,返回相应的结果
|
|
|
|
|
return CommonResult.success(count);//返回成功结果
|
|
|
|
|
}else{//相反
|
|
|
|
|
return CommonResult.failed();//返回失败
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("取消品牌关注")
|
|
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult delete(Long brandId) {
|
|
|
|
|
int count = memberAttentionService.delete(brandId);
|
|
|
|
|
if(count>0){
|
|
|
|
|
return CommonResult.success(count);
|
|
|
|
|
}else{
|
|
|
|
|
return CommonResult.failed();
|
|
|
|
|
/**
|
|
|
|
|
* 取消品牌关注。
|
|
|
|
|
* @param brandId 品牌ID。
|
|
|
|
|
* @return CommonResult对象,包含操作结果和影响的记录数。
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("取消品牌关注")//注解
|
|
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.POST)//注解,用于将HTTP请求映射到特定的处理方法上
|
|
|
|
|
@ResponseBody//这个方法的返回值应该直接作为HTTP响应的正文(Body)返回
|
|
|
|
|
public CommonResult delete(Long brandId) {// 定义方法
|
|
|
|
|
int count = memberAttentionService.delete(brandId);// 调用服务层取消关注
|
|
|
|
|
if(count>0){// 如果取消成功,返回成功的结果
|
|
|
|
|
return CommonResult.success(count);//成功结果
|
|
|
|
|
}else{// 如果取消失败,返回失败的结果
|
|
|
|
|
return CommonResult.failed();//失败结果
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("分页查询当前用户品牌关注列表")
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询当前用户品牌关注列表。
|
|
|
|
|
* @param pageNum 当前页码,默认为1。
|
|
|
|
|
* @param pageSize 每页显示的记录数,默认为5。
|
|
|
|
|
* @return CommonResult对象,包含分页结果。
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("分页查询当前用户品牌关注列表")//注解
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)//注解,用于将HTTP请求映射到特定的处理方法上
|
|
|
|
|
@ResponseBody//这个方法的返回值应该直接作为HTTP响应的正文(Body)返回
|
|
|
|
|
public CommonResult<CommonPage<MemberBrandAttention>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
|
|
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
|
|
|
|
|
Page<MemberBrandAttention> page = memberAttentionService.list(pageNum,pageSize);
|
|
|
|
|
return CommonResult.success(CommonPage.restPage(page));
|
|
|
|
|
Page<MemberBrandAttention> page = memberAttentionService.list(pageNum,pageSize);// 调用服务层获取分页数据
|
|
|
|
|
return CommonResult.success(CommonPage.restPage(page));// 返回分页结果
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("根据品牌ID获取品牌关注详情")
|
|
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult<MemberBrandAttention> detail(@RequestParam Long brandId) {
|
|
|
|
|
MemberBrandAttention memberBrandAttention = memberAttentionService.detail(brandId);
|
|
|
|
|
return CommonResult.success(memberBrandAttention);
|
|
|
|
|
/**
|
|
|
|
|
* 根据品牌ID获取品牌关注详情。
|
|
|
|
|
* @param brandId 品牌ID。
|
|
|
|
|
* @return CommonResult对象,包含品牌关注详情。
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("根据品牌ID获取品牌关注详情")//注解
|
|
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)//注解,用于将HTTP请求映射到特定的处理方法上
|
|
|
|
|
@ResponseBody//这个方法的返回值应该直接作为HTTP响应的正文(Body)返回
|
|
|
|
|
public CommonResult<MemberBrandAttention> detail(@RequestParam Long brandId) {// 定义方法
|
|
|
|
|
MemberBrandAttention memberBrandAttention = memberAttentionService.detail(brandId);// 调用服务层获取关注详情
|
|
|
|
|
return CommonResult.success(memberBrandAttention);// 返回关注详情
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("清空当前用户品牌关注列表")
|
|
|
|
|
@RequestMapping(value = "/clear", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult clear() {
|
|
|
|
|
memberAttentionService.clear();
|
|
|
|
|
return CommonResult.success(null);
|
|
|
|
|
/**
|
|
|
|
|
* 清空当前用户品牌关注列表。
|
|
|
|
|
* @return CommonResult对象,包含操作结果。
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("清空当前用户品牌关注列表")//注解
|
|
|
|
|
@RequestMapping(value = "/clear", method = RequestMethod.POST)//注解,用于将HTTP请求映射到特定的处理方法上
|
|
|
|
|
@ResponseBody//这个方法的返回值应该直接作为HTTP响应的正文(Body)返回
|
|
|
|
|
public CommonResult clear() {// 定义方法
|
|
|
|
|
memberAttentionService.clear();// 调用服务层清空关注列表
|
|
|
|
|
return CommonResult.success(null);// 返回成功的结果
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|