package com.yh.saas.platform.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alipay.sofa.runtime.api.annotation.SofaReference;
import com.winsea.svc.base.base.entity.AccountResult;
import com.winsea.svc.base.base.service.IAccountResultService;
import com.winsea.svc.base.security.util.AuthSecurityUtils;
import com.yh.saas.common.support.util.StringUtils;

/**
 * <p>
 * APP使用 - 登录写入推送ID
 * </p>
 *
 * @author ZhangMingyu
 * @since 2020年2月26日11:15:43
 */

@RestController
@RequestMapping("/accountResultId")
public class AccountResultController {

	@SofaReference
	private IAccountResultService accountResultService;

	@PostMapping("/api/setReg")
	public void setReg(@RequestBody AccountResult accountResult) {
		String accountId = AuthSecurityUtils.getCurrentUserInfo().getAccountId();
		if (StringUtils.isEmpty(accountId)) {
			// TODO 需要添加空登录人错误
			return;
		}
		accountResultService.create(accountId, accountResult.getRegId());
	}
}
