package com.xhkjedu.sapi.controller.dock;

import com.xhkjedu.annotation.Action;
import com.xhkjedu.sapi.model.system.TSchool;
import com.xhkjedu.sapi.service.dock.LcService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
import com.xhkjedu.sapi.vo.dock.LcSchoolVo;
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 javax.annotation.Resource;

/**
 * @ClassName LcController
 * Description TODO 领创对接
 * Author WN
 * Date 2021/5/24 11:48
 **/
@RestController
@RequestMapping("/lc")
public class LcController {
    @Resource
    private LcService lcService;

    //绑定领创管控信息
    @PostMapping("/add")
    @Action("领创管控-绑定学校")
    public ResultVo addSchool(@RequestBody LcSchoolVo school) {
        Integer schoolid = school.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});
        return lcService.saveSchool(school);
    }

    //绑定管理员
    @PostMapping("/adda")
    @Action("领创管控-绑定学校管理员")
    public ResultVo addAdmin(@RequestBody TSchool school) {
        Integer schoolid = school.getSchoolid();
        N_Utils.validation(new Object[]{schoolid, "学校id", 1});

        return lcService.saveSchoolAdmin(schoolid);
    }

    @PostMapping("/update")
    public ResultVo updateSchool(@RequestBody TSchool school) {
        Integer schoolid = school.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});

        return lcService.updateLcSchool(schoolid);
    }

    @PostMapping("/del")
    public ResultVo deleteSchool(@RequestBody TSchool school) {
        Integer schoolid = school.getSchoolid();
        N_Utils.validation(new Object[]{schoolid,"学校id",1});

        return lcService.deleteLcSchool(schoolid);
    }


}
