package com.gkhy.exam.system.service.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.exam.common.api.CommonPage;
|
import com.gkhy.exam.common.api.CommonResult;
|
import com.gkhy.exam.common.exception.ApiException;
|
import com.gkhy.exam.common.utils.PageUtils;
|
import com.gkhy.exam.common.utils.SecurityUtils;
|
import com.gkhy.exam.system.domain.ProductItem;
|
import com.gkhy.exam.system.mapper.ProductItemMapper;
|
import com.gkhy.exam.system.service.ProductItemService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
|
@Service
|
public class ProductItemServiceImpl extends ServiceImpl<ProductItemMapper, ProductItem> implements ProductItemService {
|
|
@Autowired
|
private ProductItemMapper productItemMapper;
|
|
@Override
|
public CommonPage selectProductItem(ProductItem productItem) {
|
if (!SecurityUtils.adminUser()){
|
if (productItem.getCompanyId()==null){
|
throw new ApiException("非管理员操作,企业id不可为空");
|
}
|
}
|
PageUtils.startPage();
|
List<ProductItem> productItems = productItemMapper.selectProductItemList(productItem);
|
return CommonPage.restPage(productItems);
|
}
|
|
@Override
|
public CommonResult insertProductItem(ProductItem productItem) {
|
productItem.setCreateTime(LocalDateTime.now());
|
productItem.setCreateBy(SecurityUtils.getUsername());
|
productItemMapper.insert(productItem);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult updateProductItem(ProductItem productItem) {
|
productItem.setUpdateBy(SecurityUtils.getUsername());
|
productItem.setUpdateTime(LocalDateTime.now());
|
productItemMapper.updateById(productItem);
|
return CommonResult.success();
|
}
|
|
@Override
|
public CommonResult deletedProductItem(Integer itemId) {
|
ProductItem productItem = new ProductItem();
|
productItem.setId(itemId);
|
productItem.setUpdateTime(LocalDateTime.now());
|
productItem.setUpdateBy(SecurityUtils.getUsername());
|
productItem.setDelFlag(2);
|
productItemMapper.updateById(productItem);
|
return CommonResult.success();
|
}
|
}
|