package com.yonge.cooleshow.student.controller;


import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
import com.yonge.cooleshow.auth.api.entity.SysUser;
import com.yonge.cooleshow.biz.dal.entity.ImGroupMember;
import com.yonge.cooleshow.biz.dal.entity.ImGroupMemberAudit;
import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType;
import com.yonge.cooleshow.biz.dal.service.ImGroupMemberAuditService;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * (ImGroupMemberAudit)表控制层
 *
 * @author zx
 * @since 2022-03-22 17:18:51
 */
@Api(tags = "入群申请")
@RestController
@RequestMapping("/imGroupMemberAudit")
public class ImGroupMemberAuditController extends BaseController {

    @Resource
    private ImGroupMemberAuditService imGroupMemberAuditService;
    @Resource
    private SysUserFeignService sysUserFeignService;

    @ApiOperation("申请入群")
    @PostMapping(value = "/apply")
    public HttpResponseResult apply(@Valid @RequestBody ImGroupMemberAudit imGroupMemberAudit) throws Exception {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        imGroupMemberAudit.setRoleType(ImGroupMemberRoleType.STUDENT);
        imGroupMemberAudit.setUserId(sysUser.getId());
        imGroupMemberAuditService.apply(imGroupMemberAudit);
        return succeed();
    }
}

