教育训练处考试制证系统后端
“djh”
2025-01-23 5be0be6c58130b6c8a638baaac04481f756adf15
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.gkhy.exam.pay.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.pay.entity.CoalCategory;
import com.gkhy.exam.pay.entity.CoalTicket;
import com.gkhy.exam.pay.mapper.CoalCategoryMapper;
import com.gkhy.exam.pay.service.CoalCategoryService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
 
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
import static com.ruoyi.common.core.domain.AjaxResult.success;
 
@Service
public class CoalCategoryServiceImpl extends ServiceImpl<CoalCategoryMapper, CoalCategory> implements CoalCategoryService {
 
    @Resource
    private CoalCategoryMapper coalCategoryMapper;
 
 
    @Override
    public CoalCategory selectCoalCategoryById(Long id) {
        return coalCategoryMapper.selectById(id);
    }
 
    /**
     * 煤矿工种类别列表
     * @param coalCategory
     * @return
     */
    @Override
    public List<CoalCategory> selectCoalCategoryList(CoalCategory coalCategory) {
        return coalCategoryMapper.selectCoalCategoryList(coalCategory);
    }
 
    /**
     * 新增煤矿工种类别
     * @param coalCategory
     * @return
     */
    @Override
    public int insertCoalCategory(CoalCategory coalCategory) {
        checkCoalCategory(coalCategory);
        coalCategory.setCreateBy(SecurityUtils.getUsername());
        coalCategory.setCreateTime(new Date());
        return coalCategoryMapper.insertCoalCategory(coalCategory);
    }
 
    private void checkCoalCategory(CoalCategory coalCategory) {
        int i = coalCategoryMapper.selectByCoalCategory(coalCategory);
        if (i>0){
            throw new RuntimeException("该工种已存在,请勿重复添加");
        }
    }
 
    /**
     * 修改煤矿工种类别
     * @param coalCategory
     * @return
     */
    @Override
    public int updateCoalCategory(CoalCategory coalCategory) {
        checkCoalCategory(coalCategory);
        coalCategory.setUpdateBy(SecurityUtils.getUsername());
        coalCategory.setUpdateTime(new Date());
        return coalCategoryMapper.updateCategoryById(coalCategory);
 
    }
 
    /**
     * 删除煤矿工种类别
     * @param ids
     * @return
     */
    @Override
    public int deleteCoalCategoryByIds(Long[] ids) {
        return coalCategoryMapper.updateBatchByIds(ids);
    }
 
    @Override
    public int saveCoalTicket(CoalTicket coalTicket) {
        return coalCategoryMapper.saveCoalTicket(coalTicket);
    }
 
    @Override
    public int updateCoalTicket(CoalTicket coalTicket) {
        return coalCategoryMapper.updateCoalTicket(coalTicket);
    }
 
    @Override
    public CoalTicket ticketList() {
        return coalCategoryMapper.selectCoalTicket();
    }
 
}