package com.xmomen.module.order.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xmomen.framework.mybatis.dao.MybatisDao;
import com.xmomen.framework.mybatis.page.Page;
import com.xmomen.module.logger.Log;
import com.xmomen.module.order.mapper.TradeRecordMapper;
import com.xmomen.module.order.model.TradeRecordModel;


@RestController
public class TradeRecordController {
    // 注入MybatisDao
    @Autowired
    MybatisDao mybatisDao;


    // 使用@RequestMapping注解指定请求路径和请求方法
    @RequestMapping(value = "/tradeRecord", method = RequestMethod.GET)
    // 使用@Log注解记录操作日志
    @Log(actionName = " 查看交易记录")
    public Page<TradeRecordModel> getUserList(@RequestParam(value = "limit") Integer limit,
                                  @RequestParam(value = "offset") Integer offset,
                                  @RequestParam(value = "keyword", required = false) String keyword){
    	 // 创建一个Map对象，用于存放参数
    	 Map param = new HashMap();
         // 将keyword参数存入Map对象
         param.put("keyword", keyword);
        // 调用mybatisDao的selectPage方法，查询交易记录列表
        return  (Page<TradeRecordModel>) mybatisDao.selectPage(TradeRecordMapper.TradeRecordMapperNameSpace + "getTradeRecordList", param, limit, offset);
    }
}
