heheng
2025-12-03 3d400cfcc41df9bc35678751f6f5afb5cf6c1ae5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.gkhy.exam.system.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.common.constant.UserConstant;
import com.gkhy.exam.common.utils.PageUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.system.domain.InternalKnowledge;
import com.gkhy.exam.system.domain.ProductService;
import com.gkhy.exam.system.mapper.ProductServiceMapper;
import com.gkhy.exam.system.service.ProductServiceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.time.LocalDateTime;
import java.util.List;
 
/**
 * <p>
 * 产品服务实现过程 服务实现类
 * </p>
 *
 * @author hh
 * @since 2025-12-02 16:59:08
 */
@Service
public class ProductServiceServiceImpl extends ServiceImpl<ProductServiceMapper, ProductService> implements ProductServiceService {
 
    @Autowired
    private ProductServiceMapper productServiceMapper;
 
    @Override
    public CommonPage selectProductServiceList(ProductService productService) {
        PageUtils.startPage();
        List<ProductService> productServices = productServiceMapper.selectProductServiceList(productService);
        return CommonPage.restPage(productServices);
    }
 
    @Override
    public CommonResult saveProductService(ProductService productService) {
        String[] split = productService.getFileUrl().split(",");
        if (split.length > 3){
            return CommonResult.failed("最多上传3张图片");
        }
        if (productService.getId() == null){
            productService.setCreateTime(LocalDateTime.now());
            productService.setCreateBy(SecurityUtils.getUsername());
            productServiceMapper.insert(productService);
        }else {
            productService.setUpdateTime(LocalDateTime.now());
            productService.setUpdateBy(SecurityUtils.getUsername());
            productServiceMapper.updateById(productService);
        }
        return CommonResult.success();
    }
 
    @Override
    public CommonResult delProductService(Long id) {
        productServiceMapper.update(new ProductService(),
                new LambdaUpdateWrapper<ProductService>().eq(ProductService::getId, id)
                        .set(ProductService::getDelFlag, UserConstant.DISENABLE)
                        .set(ProductService::getUpdateTime, LocalDateTime.now())
                        .set(ProductService::getUpdateBy, SecurityUtils.getUsername()));
        return CommonResult.success();
    }
}