首页管理接口添加
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.model.SmsHomeAdvertise;
|
||||
import com.macro.mall.service.SmsHomeAdvertiseService;
|
||||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页轮播广告管理Controller
|
||||
* Created by macro on 2018/11/7.
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "SmsHomeAdvertiseController", description = "首页轮播广告管理")
|
||||
@RequestMapping("/home/advertise")
|
||||
public class SmsHomeAdvertiseController {
|
||||
@Autowired
|
||||
private SmsHomeAdvertiseService advertiseService;
|
||||
|
||||
@ApiOperation("添加广告")
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object create(@RequestBody SmsHomeAdvertise advertise) {
|
||||
int count = advertiseService.create(advertise);
|
||||
if (count > 0)
|
||||
return new CommonResult().success(count);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("删除广告")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object delete(@RequestParam("ids") List<Long> ids) {
|
||||
int count = advertiseService.delete(ids);
|
||||
if (count > 0)
|
||||
return new CommonResult().success(count);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("修改上下线状态")
|
||||
@RequestMapping(value = "/update/status/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateStatus(@PathVariable Long id, Integer status) {
|
||||
int count = advertiseService.updateStatus(id, status);
|
||||
if (count > 0)
|
||||
return new CommonResult().success(count);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("获取广告详情")
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object getItem(@PathVariable Long id) {
|
||||
SmsHomeAdvertise advertise = advertiseService.getItem(id);
|
||||
return new CommonResult().success(advertise);
|
||||
}
|
||||
|
||||
@ApiOperation("修改广告")
|
||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object update(@PathVariable Long id, @RequestBody SmsHomeAdvertise advertise) {
|
||||
int count = advertiseService.update(id, advertise);
|
||||
if (count > 0)
|
||||
return new CommonResult().success(count);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询广告")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object list(@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "type", required = false) Integer type,
|
||||
@RequestParam(value = "endTime", required = false) String endTime,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<SmsHomeAdvertise> advertiseList = advertiseService.list(name, type, endTime, pageSize, pageNum);
|
||||
return new CommonResult().pageSuccess(advertiseList);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页品牌管理Controller
|
||||
* 首页新品管理Controller
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Controller
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.model.SmsHomeRecommendProduct;
|
||||
import com.macro.mall.service.SmsHomeRecommendProductService;
|
||||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页人气推荐管理Controller
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "SmsHomeRecommendProductController", description = "首页人气推荐管理")
|
||||
@RequestMapping("/home/recommendProduct")
|
||||
public class SmsHomeRecommendProductController {
|
||||
@Autowired
|
||||
private SmsHomeRecommendProductService recommendProductService;
|
||||
@ApiOperation("添加首页推荐")
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object create(@RequestBody List<SmsHomeRecommendProduct> homeBrandList) {
|
||||
int count = recommendProductService.create(homeBrandList);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("修改推荐排序")
|
||||
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateSort(@PathVariable Long id, Integer sort) {
|
||||
int count = recommendProductService.updateSort(id,sort);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除推荐")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object delete(@RequestParam("ids") List<Long> ids) {
|
||||
int count = recommendProductService.delete(ids);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改推荐状态")
|
||||
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
|
||||
int count = recommendProductService.updateRecommendStatus(ids,recommendStatus);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询推荐")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object list(@RequestParam(value = "productName", required = false) String productName,
|
||||
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<SmsHomeRecommendProduct> homeBrandList = recommendProductService.list(productName,recommendStatus,pageSize,pageNum);
|
||||
return new CommonResult().pageSuccess(homeBrandList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.model.SmsHomeRecommendSubject;
|
||||
import com.macro.mall.service.SmsHomeRecommendSubjectService;
|
||||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页专题推荐管理Controller
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "SmsHomeRecommendSubjectController", description = "首页专题推荐管理")
|
||||
@RequestMapping("/home/recommendSubject")
|
||||
public class SmsHomeRecommendSubjectController {
|
||||
@Autowired
|
||||
private SmsHomeRecommendSubjectService recommendSubjectService;
|
||||
@ApiOperation("添加首页推荐专题")
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object create(@RequestBody List<SmsHomeRecommendSubject> homeBrandList) {
|
||||
int count = recommendSubjectService.create(homeBrandList);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("修改推荐排序")
|
||||
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateSort(@PathVariable Long id, Integer sort) {
|
||||
int count = recommendSubjectService.updateSort(id,sort);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除推荐")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object delete(@RequestParam("ids") List<Long> ids) {
|
||||
int count = recommendSubjectService.delete(ids);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改推荐状态")
|
||||
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
|
||||
int count = recommendSubjectService.updateRecommendStatus(ids,recommendStatus);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询推荐")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object list(@RequestParam(value = "subjectName", required = false) String subjectName,
|
||||
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<SmsHomeRecommendSubject> homeBrandList = recommendSubjectService.list(subjectName,recommendStatus,pageSize,pageNum);
|
||||
return new CommonResult().pageSuccess(homeBrandList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.SmsHomeAdvertise;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页广告管理Service
|
||||
* Created by macro on 2018/11/7.
|
||||
*/
|
||||
public interface SmsHomeAdvertiseService {
|
||||
/**
|
||||
* 添加广告
|
||||
*/
|
||||
int create(SmsHomeAdvertise advertise);
|
||||
|
||||
/**
|
||||
* 批量删除广告
|
||||
*/
|
||||
int delete(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 修改上、下线状态
|
||||
*/
|
||||
int updateStatus(Long id, Integer status);
|
||||
|
||||
/**
|
||||
* 获取广告详情
|
||||
*/
|
||||
SmsHomeAdvertise getItem(Long id);
|
||||
|
||||
/**
|
||||
* 更新广告
|
||||
*/
|
||||
int update(Long id, SmsHomeAdvertise advertise);
|
||||
|
||||
/**
|
||||
* 分页查询广告
|
||||
*/
|
||||
List<SmsHomeAdvertise> list(String name, Integer type, String endTime, Integer pageSize, Integer pageNum);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public interface SmsHomeNewProductService {
|
||||
* 添加首页推荐
|
||||
*/
|
||||
@Transactional
|
||||
int create(List<SmsHomeNewProduct> homeBrandList);
|
||||
int create(List<SmsHomeNewProduct> homeNewProductList);
|
||||
|
||||
/**
|
||||
* 修改推荐排序
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.SmsHomeRecommendProduct;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页人气推荐管理Service
|
||||
* Created by macro on 2018/11/7.
|
||||
*/
|
||||
public interface SmsHomeRecommendProductService {
|
||||
/**
|
||||
* 添加首页推荐
|
||||
*/
|
||||
@Transactional
|
||||
int create(List<SmsHomeRecommendProduct> homeRecommendProductList);
|
||||
|
||||
/**
|
||||
* 修改推荐排序
|
||||
*/
|
||||
int updateSort(Long id, Integer sort);
|
||||
|
||||
/**
|
||||
* 批量删除推荐
|
||||
*/
|
||||
int delete(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 更新推荐状态
|
||||
*/
|
||||
int updateRecommendStatus(List<Long> ids, Integer recommendStatus);
|
||||
|
||||
/**
|
||||
* 分页查询推荐
|
||||
*/
|
||||
List<SmsHomeRecommendProduct> list(String productName, Integer recommendStatus, Integer pageSize, Integer pageNum);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.SmsHomeRecommendSubject;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页专题推荐管理Service
|
||||
* Created by macro on 2018/11/7.
|
||||
*/
|
||||
public interface SmsHomeRecommendSubjectService {
|
||||
/**
|
||||
* 添加首页推荐
|
||||
*/
|
||||
@Transactional
|
||||
int create(List<SmsHomeRecommendSubject> recommendSubjectList);
|
||||
|
||||
/**
|
||||
* 修改推荐排序
|
||||
*/
|
||||
int updateSort(Long id, Integer sort);
|
||||
|
||||
/**
|
||||
* 批量删除推荐
|
||||
*/
|
||||
int delete(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 更新推荐状态
|
||||
*/
|
||||
int updateRecommendStatus(List<Long> ids, Integer recommendStatus);
|
||||
|
||||
/**
|
||||
* 分页查询推荐
|
||||
*/
|
||||
List<SmsHomeRecommendSubject> list(String subjectName, Integer recommendStatus, Integer pageSize, Integer pageNum);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.mapper.SmsHomeAdvertiseMapper;
|
||||
import com.macro.mall.model.SmsHomeAdvertise;
|
||||
import com.macro.mall.model.SmsHomeAdvertiseExample;
|
||||
import com.macro.mall.service.SmsHomeAdvertiseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页广告管理Service实现类
|
||||
* Created by macro on 2018/11/7.
|
||||
*/
|
||||
@Service
|
||||
public class SmsHomeAdvertiseServiceImpl implements SmsHomeAdvertiseService {
|
||||
@Autowired
|
||||
private SmsHomeAdvertiseMapper advertiseMapper;
|
||||
|
||||
@Override
|
||||
public int create(SmsHomeAdvertise advertise) {
|
||||
return advertiseMapper.insert(advertise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(List<Long> ids) {
|
||||
SmsHomeAdvertiseExample example = new SmsHomeAdvertiseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return advertiseMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateStatus(Long id, Integer status) {
|
||||
SmsHomeAdvertise record = new SmsHomeAdvertise();
|
||||
record.setId(id);
|
||||
record.setStatus(status);
|
||||
return advertiseMapper.updateByPrimaryKeySelective(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsHomeAdvertise getItem(Long id) {
|
||||
return advertiseMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Long id, SmsHomeAdvertise advertise) {
|
||||
advertise.setId(id);
|
||||
return advertiseMapper.updateByPrimaryKey(advertise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsHomeAdvertise> list(String name, Integer type, String endTime, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
SmsHomeAdvertiseExample example = new SmsHomeAdvertiseExample();
|
||||
SmsHomeAdvertiseExample.Criteria criteria = example.createCriteria();
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
criteria.andNameLike("%" + name + "%");
|
||||
}
|
||||
if (type != null) {
|
||||
criteria.andTypeEqualTo(type);
|
||||
}
|
||||
if (!StringUtils.isEmpty(endTime)) {
|
||||
String startStr = endTime + " 00:00:00";
|
||||
String endStr = endTime + " 23:59:59";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date start = null;
|
||||
try {
|
||||
start = sdf.parse(startStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Date end = null;
|
||||
try {
|
||||
end = sdf.parse(endStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (start != null && end != null) {
|
||||
criteria.andEndTimeBetween(start, end);
|
||||
}
|
||||
}
|
||||
example.setOrderByClause("sort desc");
|
||||
return advertiseMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.mapper.SmsHomeRecommendProductMapper;
|
||||
import com.macro.mall.model.SmsHomeRecommendProduct;
|
||||
import com.macro.mall.model.SmsHomeRecommendProductExample;
|
||||
import com.macro.mall.service.SmsHomeRecommendProductService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页人气推荐管理Service实现类
|
||||
* Created by macro on 2018/11/7.
|
||||
*/
|
||||
@Service
|
||||
public class SmsHomeRecommendProductServiceImpl implements SmsHomeRecommendProductService {
|
||||
@Autowired
|
||||
private SmsHomeRecommendProductMapper recommendProductMapper;
|
||||
@Override
|
||||
public int create(List<SmsHomeRecommendProduct> homeRecommendProductList) {
|
||||
for (SmsHomeRecommendProduct recommendProduct : homeRecommendProductList) {
|
||||
recommendProduct.setRecommendStatus(1);
|
||||
recommendProduct.setSort(0);
|
||||
recommendProductMapper.insert(recommendProduct);
|
||||
}
|
||||
return homeRecommendProductList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSort(Long id, Integer sort) {
|
||||
SmsHomeRecommendProduct recommendProduct = new SmsHomeRecommendProduct();
|
||||
recommendProduct.setId(id);
|
||||
recommendProduct.setSort(sort);
|
||||
return recommendProductMapper.updateByPrimaryKeySelective(recommendProduct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(List<Long> ids) {
|
||||
SmsHomeRecommendProductExample example = new SmsHomeRecommendProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return recommendProductMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
|
||||
SmsHomeRecommendProductExample example = new SmsHomeRecommendProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
SmsHomeRecommendProduct record = new SmsHomeRecommendProduct();
|
||||
record.setRecommendStatus(recommendStatus);
|
||||
return recommendProductMapper.updateByExampleSelective(record,example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsHomeRecommendProduct> list(String productName, Integer recommendStatus, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
SmsHomeRecommendProductExample example = new SmsHomeRecommendProductExample();
|
||||
SmsHomeRecommendProductExample.Criteria criteria = example.createCriteria();
|
||||
if(!StringUtils.isEmpty(productName)){
|
||||
criteria.andProductNameLike("%"+productName+"%");
|
||||
}
|
||||
if(recommendStatus!=null){
|
||||
criteria.andRecommendStatusEqualTo(recommendStatus);
|
||||
}
|
||||
example.setOrderByClause("sort desc");
|
||||
return recommendProductMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.mapper.SmsHomeRecommendSubjectMapper;
|
||||
import com.macro.mall.model.SmsHomeRecommendSubject;
|
||||
import com.macro.mall.model.SmsHomeRecommendSubjectExample;
|
||||
import com.macro.mall.service.SmsHomeRecommendSubjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页专题推荐管理Service实现类
|
||||
* Created by macro on 2018/11/7.
|
||||
*/
|
||||
@Service
|
||||
public class SmsHomeRecommendSubjectServiceImpl implements SmsHomeRecommendSubjectService {
|
||||
@Autowired
|
||||
private SmsHomeRecommendSubjectMapper recommendProductMapper;
|
||||
@Override
|
||||
public int create(List<SmsHomeRecommendSubject> recommendSubjectList) {
|
||||
for (SmsHomeRecommendSubject recommendProduct : recommendSubjectList) {
|
||||
recommendProduct.setRecommendStatus(1);
|
||||
recommendProduct.setSort(0);
|
||||
recommendProductMapper.insert(recommendProduct);
|
||||
}
|
||||
return recommendSubjectList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSort(Long id, Integer sort) {
|
||||
SmsHomeRecommendSubject recommendProduct = new SmsHomeRecommendSubject();
|
||||
recommendProduct.setId(id);
|
||||
recommendProduct.setSort(sort);
|
||||
return recommendProductMapper.updateByPrimaryKeySelective(recommendProduct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(List<Long> ids) {
|
||||
SmsHomeRecommendSubjectExample example = new SmsHomeRecommendSubjectExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return recommendProductMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
|
||||
SmsHomeRecommendSubjectExample example = new SmsHomeRecommendSubjectExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
SmsHomeRecommendSubject record = new SmsHomeRecommendSubject();
|
||||
record.setRecommendStatus(recommendStatus);
|
||||
return recommendProductMapper.updateByExampleSelective(record,example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsHomeRecommendSubject> list(String subjectName, Integer recommendStatus, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
SmsHomeRecommendSubjectExample example = new SmsHomeRecommendSubjectExample();
|
||||
SmsHomeRecommendSubjectExample.Criteria criteria = example.createCriteria();
|
||||
if(!StringUtils.isEmpty(subjectName)){
|
||||
criteria.andSubjectNameLike("%"+subjectName+"%");
|
||||
}
|
||||
if(recommendStatus!=null){
|
||||
criteria.andRecommendStatusEqualTo(recommendStatus);
|
||||
}
|
||||
example.setOrderByClause("sort desc");
|
||||
return recommendProductMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user