RoleController.java 2.2 KB
Newer Older
X
xiongchun 已提交
1 2
package com.pulanit.pangu.admin.web.system;

X
xiongchun 已提交
3
import cn.hutool.core.lang.Assert;
X
xiongchun 已提交
4
import com.gitee.pulanos.pangu.framework.common.model.PageResult;
X
xiongchun 已提交
5
import com.gitee.pulanos.pangu.framework.common.model.Result;
X
xiongchun 已提交
6 7 8
import com.pulanit.pangu.admin.system.api.entity.RoleEntity;
import com.pulanit.pangu.admin.system.api.param.RoleIn;
import com.pulanit.pangu.admin.system.api.service.RoleService;
X
xiongchun 已提交
9
import lombok.extern.slf4j.Slf4j;
X
xiongchun 已提交
10 11 12 13
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;
X
xiongchun 已提交
14 15 16 17 18 19 20 21 22 23 24

/**
 * 角色
 *
 * @author xiongchun
 */
@Slf4j
@RestController
@RequestMapping("/api/system/role")
public class RoleController {

X
xiongchun 已提交
25 26 27
    @Reference(version = "1.0.0", group = "pangu-admin-system-app")
    private RoleService roleService;

X
xiongchun 已提交
28 29 30 31 32
    /**
     * 获取角色
     * @return
     */
    @GetMapping("/list")
X
xiongchun 已提交
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
    public Result<PageResult<RoleEntity>> list(RoleIn roleIn) {
        PageResult<RoleEntity> pageResult = roleService.list(roleIn);
        return Result.success(pageResult);
    }

    /**
     * 新增
     *
     * @param roleEntity
     * @return
     */
    @PostMapping("/add")
    public Result<Void> add(@RequestBody RoleEntity roleEntity) {
        roleService.add(roleEntity);
        return Result.success();
    }


    /**
     * 修改
     *
     * @param roleEntity
     * @return
     */
    @PostMapping("/update")
    public Result<Void> update(@RequestBody RoleEntity roleEntity) {
        Assert.notNull(roleEntity.getId(), "部门 ID 不能为空");
        roleService.update(roleEntity);
        return Result.success();
    }


    /**
     * 删除
     *
     * @param id
     * @return
     */
    @PostMapping("/delete")
    public Result<Void> delete(@RequestParam Long id) {
        Assert.notNull(id, "角色 ID 不能为空");
        roleService.delete(id);
        return Result.success();
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @PostMapping("/batchDelete")
    public Result<Void> batchDelete(@RequestParam List<Long> ids) {
        Assert.notEmpty(ids, "角色 ID 不能为空");
        roleService.batchDelete(ids);
        return Result.success();
X
xiongchun 已提交
89 90 91
    }

}