package com.mortals.xhx.base.system.param.web;


import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit;
import com.mortals.framework.common.code.PageDisplayType;
import com.mortals.framework.model.Context;

import com.mortals.framework.util.FileUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DataSatusEnum;
import com.mortals.xhx.common.code.ModStatusEnum;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * 参数信息
 *
 * @author: zxfei
 * @date: 2022/5/7 15:38
 */
@RestController
@RequestMapping("param")
public class ParamController extends BaseCRUDJsonBodyMappingController<ParamService, ParamEntity, Long> {

    public ParamController() {
        super.setModuleDesc("参数信息");
    }

    @Override
    protected void init(Map<String, Object> model, Context context) {
        Map<String, Object> status = new HashMap<String, Object>();
        status.put("validStatus", DataSatusEnum.getEnumMap(DataSatusEnum.CLOSE.getValue(),
                DataSatusEnum.DELETE.getValue(), DataSatusEnum.OVERDUE.getValue(), DataSatusEnum.USEOUT.getValue()));
        status.put("modStatus", ModStatusEnum.getEnumMap());
        status.put("displayType", getPageDisplayType());
        model.put(KEY_RESULT_DICT, status);
    }


    private Map<String, Object> getPageDisplayType() {
        PageDisplayType[] pageDisplayTypes = PageDisplayType.values();
        Map<String, Object> result = new HashMap<>(pageDisplayTypes.length);
        for (PageDisplayType pageDisplayType : pageDisplayTypes) {
            result.put(pageDisplayType.getValue() + "", pageDisplayType.getDesc());
        }
        return result;
    }

    public static void main(String[] args) {
        FileUtil.delete("E:\\pic\\1.png");
    }

}