RoleController.java 1.2 KB
package com.tianbo.warehouse.controller;

import com.github.pagehelper.PageInfo;
import com.tianbo.warehouse.controller.response.ResultJson;
import com.tianbo.warehouse.model.ROLE;
import com.tianbo.warehouse.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController()
public class RoleController {

    @Autowired
    RoleService roleService;

    @GetMapping("/role/list")
    public PageInfo<ROLE> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
                                        int pageNum,
                               @RequestParam(value = "pageSize",required = false,defaultValue = "5")
                                        int pageSize){
        return roleService.findAll(pageNum,pageSize);
    }

    @PostMapping("/role/add")
    public ResultJson add(@RequestBody ROLE role){
        int i =roleService.insertSelective(role);

        ResultJson resultJson = new ResultJson();
        if (1==i){
            resultJson = new ResultJson("200","添加账户成功");
        }else {
            resultJson = new ResultJson("500","insert faild");
        }
        return resultJson;
    }

}