package com.zhongshu.card.server.core.controller.user;

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.helper.AuthHelper;
import com.github.microservice.auth.security.type.AuthType;
import com.zhongshu.card.client.model.base.UserIdModel;
import com.zhongshu.card.client.model.org.*;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.client.service.org.OrganizationService;
import com.zhongshu.card.client.service.org.UserAccountService;
import com.zhongshu.card.server.core.service.org.IndexService;
import com.zhongshu.card.server.core.service.org.OrganizationUserServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author TRX
 * @date 2024/6/4
 */
@RestController
@RequestMapping("user")
@Tag(name = "用户管理")
public class UserManagerController {

    @Autowired
    UserAccountService userAccountService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "删除机构用户", description = "删除机构用户")
    @RequestMapping(value = {"deleteOrgUser"}, method = {RequestMethod.POST})
    public ResultContent deleteOrgUser(@RequestBody DelUserCountParam param) {
        return userAccountService.deleteOrgUser(param);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "平台修改用户信息", description = "平台修改用户信息")
    @RequestMapping(value = {"updateOrgUserState"}, method = {RequestMethod.POST})
    public ResultContent updateOrgUserState(@RequestBody UpdateUserStateParam param) {
        return userAccountService.updateOrgUserState(param);
    }

    //---------------------------------所有用户 start ----------------------------
    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "用户列表-分页查询(所有)", description = "用户列表-分页查询")
    @RequestMapping(value = {"pageAllUser"}, method = {RequestMethod.POST})
    public ResultContent<Page<UserCountModel>> pageAllUser(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, @Parameter(required = false) UserCountSearchParam param) {
        return userAccountService.list(param, pageable);
    }

}
