获取品牌列表接口添加显示状态条件

This commit is contained in:
macro
2022-11-11 17:05:06 +08:00
parent 4b2062e878
commit 89c84ce8da
3 changed files with 7 additions and 4 deletions

View File

@@ -79,9 +79,10 @@ public class PmsBrandController {
@RequestMapping(value = "/list", method = RequestMethod.GET) @RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public CommonResult<CommonPage<PmsBrand>> getList(@RequestParam(value = "keyword", required = false) String keyword, public CommonResult<CommonPage<PmsBrand>> getList(@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "showStatus",required = false) Integer showStatus,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) { @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
List<PmsBrand> brandList = brandService.listBrand(keyword, pageNum, pageSize); List<PmsBrand> brandList = brandService.listBrand(keyword,showStatus,pageNum, pageSize);
return CommonResult.success(CommonPage.restPage(brandList)); return CommonResult.success(CommonPage.restPage(brandList));
} }

View File

@@ -40,7 +40,7 @@ public interface PmsBrandService {
/** /**
* 分页查询品牌 * 分页查询品牌
*/ */
List<PmsBrand> listBrand(String keyword, int pageNum, int pageSize); List<PmsBrand> listBrand(String keyword, Integer showStatus, int pageNum, int pageSize);
/** /**
* 获取品牌详情 * 获取品牌详情

View File

@@ -13,7 +13,6 @@ import com.macro.mall.service.PmsBrandService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
@@ -75,7 +74,7 @@ public class PmsBrandServiceImpl implements PmsBrandService {
} }
@Override @Override
public List<PmsBrand> listBrand(String keyword, int pageNum, int pageSize) { public List<PmsBrand> listBrand(String keyword, Integer showStatus, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize); PageHelper.startPage(pageNum, pageSize);
PmsBrandExample pmsBrandExample = new PmsBrandExample(); PmsBrandExample pmsBrandExample = new PmsBrandExample();
pmsBrandExample.setOrderByClause("sort desc"); pmsBrandExample.setOrderByClause("sort desc");
@@ -83,6 +82,9 @@ public class PmsBrandServiceImpl implements PmsBrandService {
if (!StrUtil.isEmpty(keyword)) { if (!StrUtil.isEmpty(keyword)) {
criteria.andNameLike("%" + keyword + "%"); criteria.andNameLike("%" + keyword + "%");
} }
if(showStatus!=null){
criteria.andShowStatusEqualTo(showStatus);
}
return brandMapper.selectByExample(pmsBrandExample); return brandMapper.selectByExample(pmsBrandExample);
} }