package com.mortals.xhx.module.door.web;

import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.door.model.DoorEntity;
import com.mortals.xhx.module.door.service.DoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.stream.Collectors;

/**
*
* 门禁设备
*
* @author zxfei
* @date 2023-11-22
*/
@RestController
@RequestMapping("door")
public class DoorController extends BaseCRUDJsonBodyMappingController<DoorService,DoorEntity,Long> {

    @Autowired
    private ParamService paramService;
    @Autowired
    private DeptService deptService;

    public DoorController(){
        super.setModuleDesc( "门禁设备");
    }

    @Override
    protected void init(Map<String, Object> model, Context context) {
        super.init(model, context);

        this.addDict(model, "deptId", deptService.find(new DeptQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getDeptName(), (o, n) -> n)));


    }


}