package com.malk.ruisi.controller;

/**
 * 错误抛出与拦截详见 CatchException
 */

import com.malk.ruisi.service.RSService;
import com.malk.server.common.McException;
import com.malk.server.common.McR;
import com.malk.utils.UtilServlet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping
public class CosController {

    @Autowired
    private RSService rsService;

    /**
     * 创建投资人用户
     */
    @PostMapping("user/sync")
    McR syncUser() {
        
        log.info("syncUser");
        rsService.syncDingTalk_exclusive();
        return McR.success();
    }

    /**
     * 重置密码流程
     */
    @PostMapping("reset")
    McR resetPwd(HttpServletRequest request) {

        Map data = UtilServlet.getParamMap(request);
        log.info("reset, {}", data);

        McException.assertParamException_Null(data, "userId", "password");
        rsService.resetPwd(data);
        return McR.success();
    }

    @PostMapping("test")
    McR test() {

        return McR.success();
    }
}
