package com.zcloud.basic.info.web;

import cn.hutool.core.util.IdcardUtil;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.basic.info.api.UserServiceI;
import com.zcloud.basic.info.api.sync.SyncServiceI;
import com.zcloud.basic.info.dto.AppUserRegisterCmd;
import com.zcloud.basic.info.dto.clientobject.UserCO;
import com.zcloud.basic.info.dto.sync.SyncDepartmentQryPageCmd;
import com.zcloud.basic.info.dto.sync.SyncUserQryPageCmd;
import com.zcloud.basic.info.persistence.dataobject.UserDO;
import com.zcloud.basic.info.utils.SyncPageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhangyue
 * @date 2026/4/23 9:45
 */
@Api(tags = "演示登录")
@RequestMapping("/${application.gateway}/login")
@RestController
@AllArgsConstructor
public class LoginController {

    private final UserServiceI userService;
    @ApiOperation("获取用户数据")
    @GetMapping("/getUserInfo")
    public SingleResponse listPageSyncUser(@RequestParam(value = "userCode", required = false) String userCode) {
            UserCO user = userService.getInfoByUserId(Long.valueOf(userCode));
            Map<String,  Object> params = new HashMap<>();
            params.put("phone", user.getPhone());
            params.put("userName", user.getUsername());
            params.put("uid", user.getId());
        return SingleResponse.of(params);
    }

    @ApiOperation("注册用户")
    @PostMapping("/registerYanshi")
    public SingleResponse<UserCO> registerYanshi(@Validated @RequestBody AppUserRegisterCmd cmd) {

        return userService.registerYanshi(cmd);
    }

}
