首页管理接口添加
This commit is contained in:
parent
8ef1fcc93d
commit
0659f26e62
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
}
|
||||
}
|
@ -56,6 +56,13 @@ public class SmsHomeAdvertise implements Serializable {
|
||||
*/
|
||||
private String note;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*
|
||||
* @mbggenerated
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
@ -146,6 +153,14 @@ public class SmsHomeAdvertise implements Serializable {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -163,6 +178,7 @@ public class SmsHomeAdvertise implements Serializable {
|
||||
sb.append(", orderCount=").append(orderCount);
|
||||
sb.append(", url=").append(url);
|
||||
sb.append(", note=").append(note);
|
||||
sb.append(", sort=").append(sort);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
|
@ -804,6 +804,66 @@ public class SmsHomeAdvertiseExample {
|
||||
addCriterion("note not between", value1, value2, "note");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortIsNull() {
|
||||
addCriterion("sort is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortIsNotNull() {
|
||||
addCriterion("sort is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortEqualTo(Integer value) {
|
||||
addCriterion("sort =", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortNotEqualTo(Integer value) {
|
||||
addCriterion("sort <>", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortGreaterThan(Integer value) {
|
||||
addCriterion("sort >", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("sort >=", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortLessThan(Integer value) {
|
||||
addCriterion("sort <", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("sort <=", value, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortIn(List<Integer> values) {
|
||||
addCriterion("sort in", values, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortNotIn(List<Integer> values) {
|
||||
addCriterion("sort not in", values, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortBetween(Integer value1, Integer value2) {
|
||||
addCriterion("sort between", value1, value2, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSortNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("sort not between", value1, value2, "sort");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
@ -13,6 +13,7 @@
|
||||
<result column="order_count" jdbcType="INTEGER" property="orderCount" />
|
||||
<result column="url" jdbcType="VARCHAR" property="url" />
|
||||
<result column="note" jdbcType="VARCHAR" property="note" />
|
||||
<result column="sort" jdbcType="INTEGER" property="sort" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@ -74,7 +75,7 @@
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, name, type, pic, start_time, end_time, status, click_count, order_count, url,
|
||||
note
|
||||
note, sort
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.macro.mall.model.SmsHomeAdvertiseExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -113,11 +114,11 @@
|
||||
insert into sms_home_advertise (name, type, pic,
|
||||
start_time, end_time, status,
|
||||
click_count, order_count, url,
|
||||
note)
|
||||
note, sort)
|
||||
values (#{name,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{pic,jdbcType=VARCHAR},
|
||||
#{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},
|
||||
#{clickCount,jdbcType=INTEGER}, #{orderCount,jdbcType=INTEGER}, #{url,jdbcType=VARCHAR},
|
||||
#{note,jdbcType=VARCHAR})
|
||||
#{note,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.macro.mall.model.SmsHomeAdvertise">
|
||||
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
|
||||
@ -155,6 +156,9 @@
|
||||
<if test="note != null">
|
||||
note,
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">
|
||||
@ -187,6 +191,9 @@
|
||||
<if test="note != null">
|
||||
#{note,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
#{sort,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.macro.mall.model.SmsHomeAdvertiseExample" resultType="java.lang.Integer">
|
||||
@ -231,6 +238,9 @@
|
||||
<if test="record.note != null">
|
||||
note = #{record.note,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.sort != null">
|
||||
sort = #{record.sort,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -248,7 +258,8 @@
|
||||
click_count = #{record.clickCount,jdbcType=INTEGER},
|
||||
order_count = #{record.orderCount,jdbcType=INTEGER},
|
||||
url = #{record.url,jdbcType=VARCHAR},
|
||||
note = #{record.note,jdbcType=VARCHAR}
|
||||
note = #{record.note,jdbcType=VARCHAR},
|
||||
sort = #{record.sort,jdbcType=INTEGER}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -286,6 +297,9 @@
|
||||
<if test="note != null">
|
||||
note = #{note,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort = #{sort,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
@ -300,7 +314,8 @@
|
||||
click_count = #{clickCount,jdbcType=INTEGER},
|
||||
order_count = #{orderCount,jdbcType=INTEGER},
|
||||
url = #{url,jdbcType=VARCHAR},
|
||||
note = #{note,jdbcType=VARCHAR}
|
||||
note = #{note,jdbcType=VARCHAR},
|
||||
sort = #{sort,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user