master
王皓雯 6 years ago
parent 8147e9c981
commit 4f1225d92f

@ -0,0 +1,34 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.model.CmsPrefrenceArea;
import com.macro.mall.service.CmsPrefrenceAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* Controller
* Created by macro on 2018/6/1.
*/
@Controller//控制器处理由DispatcherServlet分发的请求
@Api(tags = "CmsPrefrenceAreaController", description = "商品优选管理")
@RequestMapping("/prefrenceArea")//映射
public class CmsPrefrenceAreaController {
@Autowired//注入资源,减少设置
private CmsPrefrenceAreaService prefrenceAreaService;
@ApiOperation("获取所有商品优选")
@RequestMapping(value = "/listAll", method = RequestMethod.GET)//表示当请求/listAll.do的时候访问的是CmsPrefrenceAreaController的liseAll方法
@ResponseBody//对象转换写入body区返回JSON数据或者XML
public Object listAll() {
List<CmsPrefrenceArea> prefrenceAreaList = prefrenceAreaService.listAll();
return new CommonResult().success(prefrenceAreaList);//成功则返回包括全部商品的listAll表
}
}

@ -0,0 +1,45 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.model.CmsSubject;
import com.macro.mall.service.CmsSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* Controller
* Created by macro on 2018/6/1.
*/
@Controller
@Api(tags = "CmsSubjectController", description = "商品专题管理")
@RequestMapping("/subject")
public class CmsSubjectController {
@Autowired
private CmsSubjectService subjectService;
@ApiOperation("获取全部商品专题")
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
@ResponseBody
public Object listAll() {
List<CmsSubject> subjectList = subjectService.listAll();
return new CommonResult().success(subjectList);
}
@ApiOperation(value = "根据专题名称分页获取专题")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
/*@RequestParam绑定HTTPServletRequest请求参数到控制器参数*/
public Object getList(@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
List<CmsSubject> subjectList = subjectService.list(keyword, pageNum, pageSize);
return new CommonResult().pageSuccess(subjectList);
}
Loading…
Cancel
Save