package cn.pluss.platform.controller.merchant.move;


import cn.pluss.platform.api.Result;
import cn.pluss.platform.base.BaseModelController;
import cn.pluss.platform.entity.MerchantMoveSetting;
import cn.pluss.platform.merchant.move.MerchantMoveSettingService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 商户动态码基本配置 前端控制器
 * </p>
 *
 * @author bzg
 * @since 2021-07-30
 */
@Controller
@RequestMapping("/merchantMoveSetting")
public class MerchantMoveSettingController extends BaseModelController<MerchantMoveSettingService, MerchantMoveSetting> {

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/index")
    public String index() {
        return "merchantMoveSetting/list";
    }

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = {"/detail/{id}", "/detail"})
    public String detail(HttpServletRequest request, @PathVariable(value = "id", required = false) Integer id) {
        if (id != null) {
            MerchantMoveSetting setting = new MerchantMoveSetting().setId(id);
            setting = baseService.getOne(new QueryWrapper<>(setting));
            request.setAttribute("entity", setting);
        }
        return "merchantMoveSetting/detail";
    }

    @Override
    public Result<Page<MerchantMoveSetting>> page(Page<MerchantMoveSetting> page, MerchantMoveSetting condition, OrderItem orderItem) {
        orderItem.setColumn("createTime");
        orderItem.setAsc(false);
        return super.page(page, condition, orderItem);
    }
}
