package org.jeecg.modules.adweb.enterprise.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.*;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.SysRole;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 企业角色管理 @Author: jeecg-boot @Date: 2022-06-13 @Version: V1.0
 */
@Tag(name = "企业角色管理")
@RestController
@RequestMapping("/enterprise/role")
@Slf4j
public class EnterpriseRoleManageController {
  @Autowired private ISysRoleService sysRoleService;

  @RequestMapping(value = "/queryall", method = RequestMethod.GET)
  public Result<List<SysRole>> queryall(SysUser user) {
    Result<List<SysRole>> result = new Result<>();
    QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("role_code", "adweb_sub_vip").or().eq("create_by", user.getUsername());
    List<SysRole> list = sysRoleService.list(queryWrapper);
    if (list == null || list.size() <= 0) {
      result.error500("未找到角色信息");
    } else {
      result.setResult(list);
      result.setSuccess(true);
    }
    return result;
  }
}
