package com.huigou.topsun.base.checkPassword.controller;

import com.huigou.context.Operator;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.client.CommonController;
import com.huigou.uasp.log.domain.model.HistoricSession;
import com.huigou.util.SDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

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

/**
 * Created by LX on 2020/5/18.
 * description:检验是否是第一次登录
 */
@Controller
@ControllerMapping("check")
public class CheckPasswordController extends CommonController {

    @Autowired
    private HisSessionRepository hisSessionRepository;

    protected String getPagePath() {
        return "/HomePage";
    }

    public String checkPassword(){
        SDO sdo = this.getSDO();
        Operator operator = sdo.getOperator();
        String loginCode = operator.getLoginUser().getLoginName();
        Integer count = 1;
        Map<String, Object> data = new HashMap<>();
        List<HistoricSession> list = hisSessionRepository.findByLoginName(loginCode);
            count=list.size();
            data.put("count",count);
            return toResult(data);
    }

}
