package com.rf.psychological.scale.rest;

import com.rf.psychological.base.rest.BaseController;
import com.rf.psychological.dao.model.*;
import com.rf.psychological.scale.service.ScaleService;
import com.rf.psychological.service.*;
import com.rf.psychological.utils.Constant;
import com.rf.psychological.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author zzf
 * @description:量表查询
 * @date 2021/1/19 16:57
 */
@Slf4j
@RestController
@RequestMapping("/subject")
@Api(tags = "(APP专用)量表数据查询：量表的问答选项")
public class SubjectController extends BaseController {

    @Autowired
    private PSQIService psqiService;
    @Autowired
    private POMSService pomsService;
    @Autowired
    private SCLService sclService;
    @Autowired
    private ASKService askService;
    @Autowired
    private AviationService aviationService;
    @Autowired
    private SupportService supportService;
    @Autowired
    private DepressService depressService;
    @Autowired
    private MoodService moodService;
    @Autowired
    private StatusService statusService;
    @Autowired
    private LifeService lifeService;
    @Autowired
    private CattellService cattellService;
    @Autowired
    private ScaleService scaleService;


    //@SafetyProcess
    @PostMapping("/save/{flag}/POST")
    public Result saveSubject(@RequestBody Object object, @PathVariable String flag){
        if(Constant.QUEST_TYPE_PSQI.equals(flag)){
            PSQIEntity psqiEntity = (PSQIEntity) object;
            psqiEntity = this.psqiService.saveSubject(psqiEntity);
            return success(psqiEntity,"保存成功");
        }
        return fail();
    }



    /**
     * 查询全量检测列表
     * @param type
     * @return
     */
    //@SafetyProcess
    @GetMapping("/{type}")
    @ApiOperation("查询量表问题选项列表：flag量表标志")
    public Result getSubjectByType(@PathVariable String type){
        if(Constant.QUEST_TYPE_PSQI.equals(type)){
            List<PSQIEntity> psqiEntityList = this.psqiService.findAll();
            return success(psqiEntityList);
        }else if(Constant.QUEST_TYPE_POMS.equals(type)){
            List<POMSEntity> pomsEntityList = this.pomsService.findAll();
            return success(pomsEntityList);
        }else if(Constant.QUEST_TYPE_SCL.equals(type)){
            List<SCLEntity> sclEntityList = this.sclService.findAll();
            return success(sclEntityList);
        }else if(Constant.QUEST_TYPE_ASK.equals(type)){
            List<ASKEntity> askEntityList = this.askService.findAll();
            System.out.println(askEntityList);
            return success(askEntityList);
        }else if(Constant.QUEST_TYPE_AVAI.equals(type)){
            List<AviationEntity> aviationEntityList = this.aviationService.findAll();
            return success(aviationEntityList);
        }else if(Constant.QUEST_TYPE_SUPP.equals(type)){
            List<SupportEntity> supportEntityList = this.supportService.findAll();
            return success(supportEntityList);
        }else if(Constant.QUEST_TYPE_DEPR.equals(type)){
            List<DepressEntity> depressEntityList = this.depressService.findAll();
            return success(depressEntityList);
        }else if(Constant.QUEST_TYPE_MOOD.equals(type)){
            List<MoodEntity> moodEntityList = this.moodService.findAll();
            return success(moodEntityList);
        }else if(Constant.QUEST_TYPE_STATUS.equals(type)){
            List<StatusEntity>statusEntityList = this.statusService.findAll();
            return success(statusEntityList);
        }else if (Constant.QUEST_TYPE_LIFE.equals(type)){
            List<LifeEntity> lifeEntityList = this.lifeService.findAll();
            return success(lifeEntityList);
        }else if (Constant.QUEST_TYPE_CATTELL.equals(type)){
            List<CattellEntity> cattellEntityList = this.cattellService.findAll();
            return success(cattellEntityList);
        }
        return fail();

        /*else{
            List<ScaleEntity> scaleEntityList = this.scaleService.findAll();
            return success(scaleEntityList);
        }*/
    }

}
