houzhongjian
2024-07-23 d9f9ba31913bb9f5053ad78109e8a3c1c00f1e6a
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.api.permission;
H 2
3 import com.iailab.framework.common.pojo.CommonResult;
d9f9ba 4 import com.iailab.framework.common.util.object.ConvertUtils;
H 5 import com.iailab.module.system.api.permission.dto.RoleDTO;
6 import com.iailab.module.system.dal.dataobject.permission.RoleDO;
e7c126 7 import com.iailab.module.system.service.permission.RoleService;
H 8 import org.springframework.validation.annotation.Validated;
9 import org.springframework.web.bind.annotation.RestController;
10
11 import javax.annotation.Resource;
12 import java.util.Collection;
13
14 import static com.iailab.framework.common.pojo.CommonResult.success;
15
16 @RestController // 提供 RESTful API 接口,给 Feign 调用
17 @Validated
18 public class RoleApiImpl implements RoleApi {
19
20     @Resource
21     private RoleService roleService;
22
23     @Override
24     public CommonResult<Boolean> validRoleList(Collection<Long> ids) {
25         roleService.validateRoleList(ids);
26         return success(true);
27     }
d9f9ba 28
H 29     @Override
30     public void saveRoleInfo(RoleDTO roleDTO) {
31         RoleDO entity = ConvertUtils.sourceToTarget(roleDTO, RoleDO.class);
32         if (roleService.getRoleByName(entity.getName()) == null) {
33             roleService.insert(entity);
34         }
35     }
36
37     @Override
38     public RoleDTO getRoleByName(String name) {
39         return ConvertUtils.sourceToTarget(roleService.getRoleByName(name),RoleDTO.class);
40     }
e7c126 41 }