|
|
|
@ -1,107 +0,0 @@
|
|
|
|
|
// 定义包名和导入所需的类
|
|
|
|
|
package com.macro.mall.portal.controller;
|
|
|
|
|
|
|
|
|
|
// 导入公共API类,用于返回通用结果和分页数据
|
|
|
|
|
import com.macro.mall.common.api.CommonPage;
|
|
|
|
|
import com.macro.mall.common.api.CommonResult;
|
|
|
|
|
// 导入会员浏览记录的实体类
|
|
|
|
|
import com.macro.mall.portal.domain.MemberReadHistory;
|
|
|
|
|
// 导入会员浏览记录的服务接口
|
|
|
|
|
import com.macro.mall.portal.service.MemberReadHistoryService;
|
|
|
|
|
// 导入Swagger注解,用于API文档的生成
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
// 导入Spring框架的注解,用于依赖注入和声明组件
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
// 导入Java.util包,用于操作列表
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 会员商品浏览记录管理Controller,用于处理会员商品浏览记录的增删改查
|
|
|
|
|
* Created by macro on 2018/8/3.
|
|
|
|
|
*/
|
|
|
|
|
@Controller
|
|
|
|
|
@Api(tags = "MemberReadHistoryController")
|
|
|
|
|
@Tag(name = "MemberReadHistoryController", description = "会员商品浏览记录管理")
|
|
|
|
|
@RequestMapping("/member/readHistory")
|
|
|
|
|
public class MemberReadHistoryController {
|
|
|
|
|
// 自动注入会员浏览记录服务
|
|
|
|
|
@Autowired
|
|
|
|
|
private MemberReadHistoryService memberReadHistoryService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建浏览记录的方法
|
|
|
|
|
* @param memberReadHistory 会员浏览记录对象
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("创建浏览记录")
|
|
|
|
|
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult create(@RequestBody MemberReadHistory memberReadHistory) {
|
|
|
|
|
// 调用服务层方法创建浏览记录
|
|
|
|
|
int count = memberReadHistoryService.create(memberReadHistory);
|
|
|
|
|
// 如果创建成功,返回成功结果
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
return CommonResult.success(count);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果创建失败,返回失败结果
|
|
|
|
|
return CommonResult.failed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除浏览记录的方法
|
|
|
|
|
* @param ids 要删除的浏览记录ID列表
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("删除浏览记录")
|
|
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult delete(@RequestParam("ids") List<String> ids) {
|
|
|
|
|
// 调用服务层方法删除浏览记录
|
|
|
|
|
int count = memberReadHistoryService.delete(ids);
|
|
|
|
|
// 如果删除成功,返回成功结果
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
return CommonResult.success(count);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果删除失败,返回失败结果
|
|
|
|
|
return CommonResult.failed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 清空浏览记录的方法
|
|
|
|
|
* @return 操作结果
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("清空浏览记录")
|
|
|
|
|
@RequestMapping(value = "/clear", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult clear() {
|
|
|
|
|
// 调用服务层方法清空浏览记录
|
|
|
|
|
memberReadHistoryService.clear();
|
|
|
|
|
// 返回成功结果
|
|
|
|
|
return CommonResult.success(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页获取浏览记录的方法
|
|
|
|
|
* @param pageNum 当前页码
|
|
|
|
|
* @param pageSize 每页显示数量
|
|
|
|
|
* @return 分页后的浏览记录
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("分页获取浏览记录")
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public CommonResult<CommonPage<MemberReadHistory>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
|
|
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
|
|
|
|
|
// 调用服务层方法分页获取浏览记录
|
|
|
|
|
Page<MemberReadHistory> page = memberReadHistoryService.list(pageNum, pageSize);
|
|
|
|
|
// 将分页结果封装到CommonPage对象中,并返回
|
|
|
|
|
return CommonResult.success(CommonPage.restPage(page));
|
|
|
|
|
}
|
|
|
|
|
}
|