fangyuan
2022-11-17 e413320d3a72baf7a631aeb56c05456de3cb4f1f
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
package com.ycl.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.mapper.NewsAdminDao;
import com.ycl.entity.NewsAdmin;
import com.ycl.entity.NewsPolice;
import com.ycl.service.NewsAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.sql.SQLException;
import java.util.Date;
 
/**
 * 后台用户表(NewsAdmin)表服务实现类
 *
 * @author makejava
 * @since 2022-11-17 11:38:27
 */
@Service("newsAdminService")
public class NewsAdminServiceImpl extends ServiceImpl<NewsAdminDao, NewsAdmin> implements NewsAdminService {
 
    @Autowired
    private NewsAdminDao newsAdminDao;
 
    @Value("${admin.defaultPassword}")
    private String defaultPassword;
 
    @Transactional(rollbackFor = SQLException.class)
    @Override
    public Integer autoCreateAdmin(NewsPolice newsPolice) {
        NewsAdmin admin = new NewsAdmin();
        admin.setUsername(newsPolice.getRname());
        admin.setPassword(defaultPassword);
        admin.setCreateTime(new Date());
        admin.setStatus(1);
        admin.setNewsPoliceId(newsPolice.getId());
        return newsAdminDao.insert(admin);
    }
}