All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.base4j.mvc.sys.controller.SysUserRoleController Maven / Gradle / Ivy

The newest version!
package com.base4j.mvc.sys.controller;

import com.base4j.mvc.sys.entity.SysUserRole;
import com.base4j.mvc.sys.service.SysAccountRoleService;
import com.base4j.mvc.util.Res;
import com.base4j.mybatis.base.QueryParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sys/userRole")
public class SysUserRoleController {

    @Autowired
    private SysAccountRoleService sysAccountRoleService;


    @RequestMapping("/selectList")
    public Res selectList() {
        QueryParams queryParams = new QueryParams(SysUserRole.class);
        List sysUserRoles = sysAccountRoleService.selectListByParams(queryParams);
        return Res.ok(sysUserRoles);
    }

    @RequestMapping("/selectListForUser/{userId}")
    public Res selectListForUser(@PathVariable long userId) {
        QueryParams queryParams = new QueryParams(SysUserRole.class);
        QueryParams.Criteria criteria = queryParams.createCriteria();
        criteria.andEqualTo("sysUserId", userId);
        List sysUserRoles = sysAccountRoleService.selectListRelativeByParams(queryParams);
        return Res.ok(sysUserRoles);
    }

    @RequestMapping("/saveUserRole")
    public Res saveUserRole(@RequestBody List userRoleList) {
        sysAccountRoleService.saveUserRole(userRoleList);
        return Res.ok();
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy