AdminInfoController.java 2.35 KB
package com.xkl.controller.uploadsoft;

import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
import com.wordnik.swagger.annotations.ApiOperation;
import com.xkl.authorization.annotation.*;
import com.xkl.authorization.manager.ITokenManager;
import com.xkl.config.Constants;
import com.xkl.config.ResultStatus;
import com.xkl.domain.User;
import com.xkl.domain.XklAdminEntity;
import com.xkl.domain.XklCompanyEntity;
import com.xkl.domain.XklMemberEntity;
import com.xkl.model.AdminInfoModel;
import com.xkl.model.ResultModel;
import com.xkl.repository.AdminRepository;
import com.xkl.repository.UserRepository;
import com.xkl.repository.XklCompanyRepository;
import com.xkl.repository.XklMemberRespository;
import com.xkl.security.AntiXSS;
import com.xkl.security.SecurityTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 操作员信息查询接口
 */
@RestController
@RequestMapping("/adminInfo")
public class AdminInfoController {
    @Autowired
    private XklCompanyRepository xklCompanyRepository;

    @RequestMapping(method = RequestMethod.GET)
    @Authorization
    @ApiOperation(value = "操作员信息查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
    })
    public ResponseEntity<ResultModel> getAdminInfo(@CurrentAdmin XklAdminEntity admin) {
        XklCompanyEntity companyEntity = xklCompanyRepository.findById(admin.getCoid());
        if(companyEntity==null){
            return new ResponseEntity<>(ResultModel.error(ResultStatus.COMPANY_ERROR),HttpStatus.OK);
        }
        AdminInfoModel adminInfoModel = new AdminInfoModel(admin.getId(), admin.getAccount(), companyEntity.getId(), companyEntity.getName());
        return new ResponseEntity<>(ResultModel.ok(adminInfoModel), HttpStatus.OK);
    }
}