主页管理代码

master
王皓雯 6 years ago
parent 09b6e91215
commit 6eb7968531

@ -0,0 +1,92 @@
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ʵÏÖÀà
*/
@Service
public class SmsHomeAdvertiseServiceImpl implements SmsHomeAdvertiseService {
@Autowired
private SmsHomeAdvertiseMapper advertiseMapper;
@Override
public int create(SmsHomeAdvertise advertise) {
advertise.setClickCount(0);
advertise.setOrderCount(0);
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.updateByPrimaryKeySelective(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,69 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.mapper.SmsHomeBrandMapper;
import com.macro.mall.model.SmsHomeBrand;
import com.macro.mall.model.SmsHomeBrandExample;
import com.macro.mall.service.SmsHomeBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* Ê×ҳƷÅƹÜÀíServiceʵÏÖÀà
*/
@Service
public class SmsHomeBrandServiceImpl implements SmsHomeBrandService {
@Autowired
private SmsHomeBrandMapper homeBrandMapper;
@Override
public int create(List<SmsHomeBrand> homeBrandList) {
for (SmsHomeBrand smsHomeBrand : homeBrandList) {
smsHomeBrand.setRecommendStatus(1);
smsHomeBrand.setSort(0);
homeBrandMapper.insert(smsHomeBrand);
}
return homeBrandList.size();
}
@Override
public int updateSort(Long id, Integer sort) {
SmsHomeBrand homeBrand = new SmsHomeBrand();
homeBrand.setId(id);
homeBrand.setSort(sort);
return homeBrandMapper.updateByPrimaryKeySelective(homeBrand);
}
@Override
public int delete(List<Long> ids) {
SmsHomeBrandExample example = new SmsHomeBrandExample();
example.createCriteria().andIdIn(ids);
return homeBrandMapper.deleteByExample(example);
}
@Override
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
SmsHomeBrandExample example = new SmsHomeBrandExample();
example.createCriteria().andIdIn(ids);
SmsHomeBrand record = new SmsHomeBrand();
record.setRecommendStatus(recommendStatus);
return homeBrandMapper.updateByExampleSelective(record,example);
}
@Override
public List<SmsHomeBrand> list(String brandName, Integer recommendStatus, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum,pageSize);
SmsHomeBrandExample example = new SmsHomeBrandExample();
SmsHomeBrandExample.Criteria criteria = example.createCriteria();
if(!StringUtils.isEmpty(brandName)){
criteria.andBrandNameLike("%"+brandName+"%");
}
if(recommendStatus!=null){
criteria.andRecommendStatusEqualTo(recommendStatus);
}
example.setOrderByClause("sort desc");
return homeBrandMapper.selectByExample(example);
}
}

@ -0,0 +1,69 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.mapper.SmsHomeNewProductMapper;
import com.macro.mall.model.SmsHomeNewProduct;
import com.macro.mall.model.SmsHomeNewProductExample;
import com.macro.mall.service.SmsHomeNewProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* Service
*/
@Service
public class SmsHomeNewProductServiceImpl implements SmsHomeNewProductService {
@Autowired
private SmsHomeNewProductMapper homeNewProductMapper;
@Override
public int create(List<SmsHomeNewProduct> homeNewProductList) {
for (SmsHomeNewProduct SmsHomeNewProduct : homeNewProductList) {
SmsHomeNewProduct.setRecommendStatus(1);
SmsHomeNewProduct.setSort(0);
homeNewProductMapper.insert(SmsHomeNewProduct);
}
return homeNewProductList.size();
}
@Override
public int updateSort(Long id, Integer sort) {
SmsHomeNewProduct homeNewProduct = new SmsHomeNewProduct();
homeNewProduct.setId(id);
homeNewProduct.setSort(sort);
return homeNewProductMapper.updateByPrimaryKeySelective(homeNewProduct);
}
@Override
public int delete(List<Long> ids) {
SmsHomeNewProductExample example = new SmsHomeNewProductExample();
example.createCriteria().andIdIn(ids);
return homeNewProductMapper.deleteByExample(example);
}
@Override
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
SmsHomeNewProductExample example = new SmsHomeNewProductExample();
example.createCriteria().andIdIn(ids);
SmsHomeNewProduct record = new SmsHomeNewProduct();
record.setRecommendStatus(recommendStatus);
return homeNewProductMapper.updateByExampleSelective(record,example);
}
@Override
public List<SmsHomeNewProduct> list(String productName, Integer recommendStatus, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum,pageSize);
SmsHomeNewProductExample example = new SmsHomeNewProductExample();
SmsHomeNewProductExample.Criteria criteria = example.createCriteria();
if(!StringUtils.isEmpty(productName)){
criteria.andProductNameLike("%"+productName+"%");
}
if(recommendStatus!=null){
criteria.andRecommendStatusEqualTo(recommendStatus);
}
example.setOrderByClause("sort desc");
return homeNewProductMapper.selectByExample(example);
}
}

@ -0,0 +1,69 @@
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
*/
@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,69 @@
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
*/
@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);
}
}
Loading…
Cancel
Save