package com.jeequan.jeepay.mch.ctrl.account;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.db.entity.AccountChangeInfo;
import com.jeequan.jeepay.mch.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.AccountChangeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author crystal
 * @date 2023/12/6 15:11
 */
@RestController
@RequestMapping("/api/accountChange")
public class AccountChangeInfoController extends CommonCtrl {

    @Autowired private AccountChangeInfoService accountChangeInfoService;

    @PreAuthorize("hasAuthority('ENT_ACCOUNT_CHANGE_LIST')")
    @GetMapping
    public ApiRes list() {
        AccountChangeInfo info = getObject(AccountChangeInfo.class);
        JSONObject paramJSON = getReqParamJSON();
        LambdaQueryWrapper<AccountChangeInfo> wrapper = AccountChangeInfo.gw(info);
        wrapper.eq(AccountChangeInfo::getMchNo, getCurrentMchNo());
        Page<AccountChangeInfo> pages = accountChangeInfoService.pageList(getIPage(),wrapper,info,paramJSON);
        return ApiRes.page(pages);
    }
}
