mirror of
https://github.com/macrozheng/mall.git
synced 2025-06-27 04:20:01 +00:00
商品品牌接口完善
This commit is contained in:
parent
390132d9e8
commit
0ccc58178e
@ -128,4 +128,18 @@ public class PmsBrandController {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量更新厂家制造商状态")
|
||||
@RequestMapping(value = "/update/factoryStatus", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object updateFactoryStatus(@RequestParam("ids") List<Long> ids, @RequestParam("factoryStatus") Integer factoryStatus) {
|
||||
int count = brandService.updateFactoryStatus(ids, factoryStatus);
|
||||
if (count > 0) {
|
||||
LOGGER.debug("updateFactoryStatus success:{}", ids);
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
LOGGER.debug("updateFactoryStatus failed:{}", ids);
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,4 +24,6 @@ public interface PmsBrandService {
|
||||
PmsBrand getBrand(Long id);
|
||||
|
||||
int updateShowStatus(List<Long> ids, Integer showStatus);
|
||||
|
||||
int updateFactoryStatus(List<Long> ids, Integer factoryStatus);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||
* 商品品牌Service实现类
|
||||
*/
|
||||
@Service
|
||||
public class PmsBrandServiceImpl implements PmsBrandService{
|
||||
public class PmsBrandServiceImpl implements PmsBrandService {
|
||||
@Autowired
|
||||
private PmsBrandMapper brandMapper;
|
||||
|
||||
@ -29,10 +29,10 @@ public class PmsBrandServiceImpl implements PmsBrandService{
|
||||
@Override
|
||||
public int createBrand(PmsBrandParam pmsBrandParam) {
|
||||
PmsBrand pmsBrand = new PmsBrand();
|
||||
BeanUtils.copyProperties(pmsBrandParam,pmsBrand);
|
||||
BeanUtils.copyProperties(pmsBrandParam, pmsBrand);
|
||||
//如果创建时首字母为空,取名称的第一个为首字母
|
||||
if(StringUtils.isEmpty(pmsBrand.getFirstLetter())){
|
||||
pmsBrand.setFirstLetter(pmsBrand.getName().substring(0,1));
|
||||
if (StringUtils.isEmpty(pmsBrand.getFirstLetter())) {
|
||||
pmsBrand.setFirstLetter(pmsBrand.getName().substring(0, 1));
|
||||
}
|
||||
return brandMapper.insertSelective(pmsBrand);
|
||||
}
|
||||
@ -40,11 +40,11 @@ public class PmsBrandServiceImpl implements PmsBrandService{
|
||||
@Override
|
||||
public int updateBrand(Long id, PmsBrandParam pmsBrandParam) {
|
||||
PmsBrand pmsBrand = new PmsBrand();
|
||||
BeanUtils.copyProperties(pmsBrandParam,pmsBrand);
|
||||
BeanUtils.copyProperties(pmsBrandParam, pmsBrand);
|
||||
pmsBrand.setId(id);
|
||||
//如果创建时首字母为空,取名称的第一个为首字母
|
||||
if(StringUtils.isEmpty(pmsBrand.getFirstLetter())){
|
||||
pmsBrand.setFirstLetter(pmsBrand.getName().substring(0,1));
|
||||
if (StringUtils.isEmpty(pmsBrand.getFirstLetter())) {
|
||||
pmsBrand.setFirstLetter(pmsBrand.getName().substring(0, 1));
|
||||
}
|
||||
return brandMapper.updateByPrimaryKeySelective(pmsBrand);
|
||||
}
|
||||
@ -62,11 +62,12 @@ public class PmsBrandServiceImpl implements PmsBrandService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsBrand> listBrand(String keyword,int pageNum, int pageSize) {
|
||||
public List<PmsBrand> listBrand(String keyword, int pageNum, int pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
PmsBrandExample pmsBrandExample = new PmsBrandExample();
|
||||
if(!StringUtils.isEmpty(keyword)){
|
||||
pmsBrandExample.createCriteria().andNameLike("%"+keyword+"%");
|
||||
pmsBrandExample.setOrderByClause("sort asc");
|
||||
if (!StringUtils.isEmpty(keyword)) {
|
||||
pmsBrandExample.createCriteria().andNameLike("%" + keyword + "%");
|
||||
}
|
||||
return brandMapper.selectByExample(pmsBrandExample);
|
||||
}
|
||||
@ -82,6 +83,15 @@ public class PmsBrandServiceImpl implements PmsBrandService{
|
||||
pmsBrand.setShowStatus(showStatus);
|
||||
PmsBrandExample pmsBrandExample = new PmsBrandExample();
|
||||
pmsBrandExample.createCriteria().andIdIn(ids);
|
||||
return brandMapper.updateByExampleSelective(pmsBrand,pmsBrandExample);
|
||||
return brandMapper.updateByExampleSelective(pmsBrand, pmsBrandExample);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateFactoryStatus(List<Long> ids, Integer factoryStatus) {
|
||||
PmsBrand pmsBrand = new PmsBrand();
|
||||
pmsBrand.setFactoryStatus(factoryStatus);
|
||||
PmsBrandExample pmsBrandExample = new PmsBrandExample();
|
||||
pmsBrandExample.createCriteria().andIdIn(ids);
|
||||
return brandMapper.updateByExampleSelective(pmsBrand, pmsBrandExample);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user