package com.mortals.xhx.module.ent.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.menu.model.MenuEntity;
import com.mortals.xhx.base.system.param.service.ParamService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.ent.model.EntLifeCycleEntity;
import com.mortals.xhx.module.ent.service.EntLifeCycleService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;

import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*;
/**
*
* 企业生命周期
*
* @author zxfei
* @date 2025-03-15
*/
@RestController
@RequestMapping("ent/life/cycle")
public class EntLifeCycleController extends BaseCRUDJsonBodyMappingController<EntLifeCycleService,EntLifeCycleEntity,Long> {

    @Autowired
    private ParamService paramService;

    public EntLifeCycleController(){
        super.setModuleDesc( "企业生命周期");
    }

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


    @Override
    protected void doListBefore(EntLifeCycleEntity query, Map<String, Object> model, Context context) throws AppException {
        super.doListBefore(query, model, context);
        List<OrderCol> orderColList = new ArrayList<>();
        orderColList.add(new OrderCol("sort"));
        query.setOrderColList(orderColList);
    }

    /**
     * 更换排序
     */
    @ApiOperation(value = "更换排序")
    @PostMapping(value = "upOrDown")
    public String upOrDownTopicList(@RequestBody MenuEntity query) {
        JSONObject ret = new JSONObject();
        ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
        try {
            this.service.upOrDown(query.getId(), query.getType());
        } catch (Exception e) {
            log.error("更新错误", e);
            ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
            ret.put(KEY_RESULT_MSG, e.getMessage());
        }
        return ret.toJSONString();
    }


}