龚焕茏
2024-03-25 5fb5605185db191834d2e98bc9f6e7bfa7af47c8
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.ycl.platform.service.impl;
 
import com.ycl.platform.base.BaseSelect;
import com.ycl.platform.domain.entity.TCheckPublish;
import com.ycl.platform.mapper.TCheckPublishMapper;
import com.ycl.platform.service.ITCheckPublishService;
import com.ycl.system.Result;
import com.ycl.system.entity.SysDept;
import com.ycl.system.entity.SysUser;
import com.ycl.system.mapper.SysUserMapper;
import com.ycl.system.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import utils.DateUtils;
 
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * 考核发布Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-07
 */
@Service
public class TCheckPublishServiceImpl implements ITCheckPublishService
{
    @Autowired
    private TCheckPublishMapper tCheckPublishMapper;
    @Autowired
    private SysUserMapper userMapper;
    /**
     * 查询考核发布
     * 
     * @param id 考核发布主键
     * @return 考核发布
     */
    @Override
    public TCheckPublish selectTCheckPublishById(Long id)
    {
        return tCheckPublishMapper.selectTCheckPublishById(id);
    }
 
    /**
     * 查询考核发布列表
     * 
     * @param tCheckPublish 考核发布
     * @return 考核发布
     */
    @Override
    public List<TCheckPublish> selectTCheckPublishList(TCheckPublish tCheckPublish)
    {
        return tCheckPublishMapper.selectTCheckPublishList(tCheckPublish);
    }
 
    /**
     * 新增考核发布
     * 
     * @param tCheckPublish 考核发布
     * @return 结果
     */
    @Override
    public int insertTCheckPublish(TCheckPublish tCheckPublish)
    {
        Date nowDate = DateUtils.getNowDate();
        tCheckPublish.setCreateTime(nowDate);
        tCheckPublish.setUpdateTime(nowDate);
        LoginUser user = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        tCheckPublish.setCreateUser(user.getUserId());
        tCheckPublish.setCreateUserName(user.getUsername());
        tCheckPublish.setUpdateUser(user.getUserId());
        tCheckPublish.setUpdateUserName(user.getUsername());
        return tCheckPublishMapper.insertTCheckPublish(tCheckPublish);
    }
 
    /**
     * 修改考核发布
     * 
     * @param tCheckPublish 考核发布
     * @return 结果
     */
    @Override
    public int updateTCheckPublish(TCheckPublish tCheckPublish)
    {
        tCheckPublish.setUpdateTime(DateUtils.getNowDate());
        LoginUser user = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        tCheckPublish.setUpdateUser(user.getUserId());
        tCheckPublish.setUpdateUserName(user.getUsername());
        return tCheckPublishMapper.updateTCheckPublish(tCheckPublish);
    }
 
    /**
     * 批量删除考核发布
     * 
     * @param ids 需要删除的考核发布主键
     * @return 结果
     */
    @Override
    public int deleteTCheckPublishByIds(Long[] ids)
    {
        return tCheckPublishMapper.deleteTCheckPublishByIds(ids);
    }
 
    /**
     * 删除考核发布信息
     * 
     * @param id 考核发布主键
     * @return 结果
     */
    @Override
    public int deleteTCheckPublishById(Long id)
    {
        return tCheckPublishMapper.deleteTCheckPublishById(id);
    }
    /**
     * 下拉列表
     * */
    @Override
    public Result all() {
        List<BaseSelect> vos = tCheckPublishMapper.selectTCheckPublishList(new TCheckPublish()).stream().map(checkPublish -> {
                    BaseSelect baseSelect = new BaseSelect();
                    baseSelect.setId(Integer.parseInt(checkPublish.getId() + ""));
                    baseSelect.setValue(checkPublish.getExamineName());
                    return baseSelect;
                }
        ).collect(Collectors.toList());
        return Result.ok().data(vos);
    }
}