“djh”
23 小时以前 8182370136b1d91330ada09e2fcebdd01dde1161
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
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.Customer;
import com.gkhy.exam.system.mapper.CustomerMapper;
import com.gkhy.exam.system.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.time.LocalDateTime;
import java.util.List;
 
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
 
    @Autowired
    private CustomerMapper customerMapper;
 
    @Override
    public CommonPage selectCustomerList(Customer customer) {
        if (!SecurityUtils.adminUser()){
            if (customer.getCompanyId()==null){
                throw new ApiException("非管理员操作,企业id不可为空");
            }
        }
        PageUtils.startPage();
        List<Customer> customers = customerMapper.selectCustomerList(customer);
        return CommonPage.restPage(customers);
    }
 
    @Override
    public CommonResult insertCustomer(Customer customer) {
        customer.setCreateBy(SecurityUtils.getUsername());
        customer.setCreateTime(LocalDateTime.now());
        customerMapper.insert(customer);
        return CommonResult.success();
    }
 
    @Override
    public CommonResult updateCustomer(Customer customer) {
        customer.setUpdateBy(SecurityUtils.getUsername());
        customer.setUpdateTime(LocalDateTime.now());
        customerMapper.updateById(customer);
        return CommonResult.success();
    }
 
    @Override
    public CommonResult deletedCustomer(Integer customerId) {
        Customer customer = new Customer();
        customer.setId(customerId);
        customer.setUpdateTime(LocalDateTime.now());
        customer.setUpdateBy(SecurityUtils.getUsername());
        customer.setDelFlag(2);
        customerMapper.updateById(customer);
        return CommonResult.success();
    }
}