package com.community.huiju.controller;

import com.community.commom.mode.ResponseBean;
import com.community.huiju.common.base.BaseController;
import com.community.huiju.service.ITaUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 移动端 用户
 */
@RestController
@RequestMapping("/")
@RefreshScope
@Api(value = "移动用户API",description = "移动用户API")
public class TaUserController  extends BaseController {

    @Autowired
    private ITaUserService iTaUserService;

    @ApiOperation("查询所有用户")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataTypeClass = String.class, name = "userName", value = "用户名"),
            @ApiImplicitParam(paramType = "query", dataTypeClass = String.class, name = "loginName", value = "手机号"),
            @ApiImplicitParam(paramType = "query", dataTypeClass = String.class, name = "idCard", value = "身份证"),
            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageNum", value = "当前页"),
            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageSize", value = "一页多少行"),
    })
    @RequestMapping(value = "/ta/user/getAll", method = RequestMethod.GET)
    public ResponseBean getAll(@RequestParam(value = "userName", required = false) String userName,
                               @RequestParam(value = "loginName", required = false)String loginName,
                               @RequestParam(value = "idCard", required = false)String idCard,
                               @RequestParam(value = "pageNum", defaultValue = "1")Integer pageNum,
                               @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iTaUserService.getAll(userName, loginName, idCard, pageNum, pageSize);
        return responseBean;
    }

    @ApiOperation("拉黑用户")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "ids", value = "id集合"),
    })
    @RequestMapping(value = "/ta/user/blacklist", method = RequestMethod.PUT)
    public ResponseBean blacklistTaUser(@RequestBody List<Integer> ids) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iTaUserService.blacklistTaUser(ids);
        return responseBean;
    }

}
