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

import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.module.task.model.TaskFinishEntity;
import com.mortals.xhx.module.task.service.TaskFinishService;
import org.apache.poi.ss.formula.functions.T;
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 java.util.HashMap;
import java.util.Map;


/**
 * <p>Title: 工作已办表</p>
 * <p>Description: TaskFinishController  </p>
 * <p>Copyright: Copyright &reg;  </p>
 * <p>Company: </p>
 *
 * @author zxfei
 * @version 1.0.0
 */
@RestController
@RequestMapping("task/finish")
public class TaskFinishController extends BaseCRUDJsonBodyMappingController<TaskFinishService, TaskFinishEntity, Long> {

    public TaskFinishController() {
        super.setFormClass(TaskFinishForm.class);
        super.setModuleDesc("工作已办表");
    }

    @Override
    public Rest<Object> list(@RequestBody TaskFinishEntity query) {
        Rest<Object> ret = new Rest();
        Map<String, Object> model = new HashMap();
        Context context = this.getContext();
        String busiDesc = "查询" + this.getModuleDesc();

        int code;
        try {
            this.doListBefore(query, model, context);
            PageInfo pageInfo = this.buildPageInfo(query);

            Result result = this.service.finishList(query,pageInfo, getContext());

            model.put("data", result.getList());
            model.put("pageInfo", result.getPageInfo());
            this.parsePageInfo(model, result.getPageInfo());
            code = this.doListAfter(query, (Map)model, context);
            model.put("message_info", busiDesc + "成功");
            this.recordSysLog(this.request, busiDesc + " 【成功】");
        } catch (Exception var9) {
            code = -1;
            this.doException(this.request, busiDesc, model, var9);
        }

        this.init(model, context);
        ret.setCode(code);
        ret.setData(model);
        ret.setDict(model.get("dict"));
        ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
        return ret;
    }

}