Blame view

yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_crud/java/SystemUserServiceImpl 2.47 KB
2f6456e2   zhijiantianya@gmail.com   代码生成器:主子表,支持多个从字段...
1
  package cn.iocoder.yudao.module.system.service.user;
9705ae06   zhijiantianya@gmail.com   codegen:1)增加 vue3...
2
3
4
5
6
7
  
  import org.springframework.stereotype.Service;
  import javax.annotation.Resource;
  import org.springframework.validation.annotation.Validated;
  
  import java.util.*;
2f6456e2   zhijiantianya@gmail.com   代码生成器:主子表,支持多个从字段...
8
9
  import cn.iocoder.yudao.module.system.controller.admin.user.vo.*;
  import cn.iocoder.yudao.module.system.dal.dataobject.user.SystemUserDO;
9705ae06   zhijiantianya@gmail.com   codegen:1)增加 vue3...
10
11
  import cn.iocoder.yudao.framework.common.pojo.PageResult;
  
2f6456e2   zhijiantianya@gmail.com   代码生成器:主子表,支持多个从字段...
12
13
  import cn.iocoder.yudao.module.system.convert.user.SystemUserConvert;
  import cn.iocoder.yudao.module.system.dal.mysql.user.SystemUserMapper;
9705ae06   zhijiantianya@gmail.com   codegen:1)增加 vue3...
14
15
  
  import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
2f6456e2   zhijiantianya@gmail.com   代码生成器:主子表,支持多个从字段...
16
  import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
9705ae06   zhijiantianya@gmail.com   codegen:1)增加 vue3...
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
  
  import cn.hutool.core.collection.CollUtil;
  import cn.hutool.core.collection.ListUtil;
  
  /**
   * 用户 Service 实现类
   *
   * @author 芋道源码
   */
  @Service
  @Validated
  public class SystemUserServiceImpl implements SystemUserService {
  
      @Resource
      private SystemUserMapper userMapper;
  
      @Override
      public Long createUser(SystemUserCreateReqVO createReqVO) {
          // 插入
          SystemUserDO user = SystemUserConvert.INSTANCE.convert(createReqVO);
          userMapper.insert(user);
          // 返回
          return user.getId();
      }
  
      @Override
      public void updateUser(SystemUserUpdateReqVO updateReqVO) {
          // 校验存在
          validateUserExists(updateReqVO.getId());
          // 更新
          SystemUserDO updateObj = SystemUserConvert.INSTANCE.convert(updateReqVO);
          userMapper.updateById(updateObj);
      }
  
      @Override
      public void deleteUser(Long id) {
          // 校验存在
          validateUserExists(id);
          // 删除
          userMapper.deleteById(id);
      }
  
      private void validateUserExists(Long id) {
          if (userMapper.selectById(id) == null) {
              throw exception(USER_NOT_EXISTS);
          }
      }
  
      @Override
      public SystemUserDO getUser(Long id) {
          return userMapper.selectById(id);
      }
  
      @Override
      public List<SystemUserDO> getUserList(Collection<Long> ids) {
          if (CollUtil.isEmpty(ids)) {
              return ListUtil.empty();
          }
          return userMapper.selectBatchIds(ids);
      }
  
      @Override
      public PageResult<SystemUserDO> getUserPage(SystemUserPageReqVO pageReqVO) {
          return userMapper.selectPage(pageReqVO);
      }
  
      @Override
      public List<SystemUserDO> getUserList(SystemUserExportReqVO exportReqVO) {
          return userMapper.selectList(exportReqVO);
      }
  
  }