package org.tio.sitexxx.server.controller;

import org.tio.sitexxx.server.utils.WebUtils;
import org.tio.http.common.HttpRequest;
import org.tio.http.server.annotation.RequestPath;
import org.tio.jfinal.kit.Ret;
import org.tio.sitexxx.service.service.UserCoinItemService;
import org.tio.sitexxx.service.service.UserCoinService;
import org.tio.utils.resp.Resp;

import java.util.Map;

/**
 * 用户财务信息请求类
 */
@RequestPath(value = "/usercoin")
public class UserCoinController {
	/**
	 * 充值记录
	 * @param request
	 * @param pageNumber
	 * @param pageSizes'm's
	 * @return
	 */
	@RequestPath(value = "/getRechargeList")
	public Resp getRechargeList(HttpRequest request, Integer pageNumber, Integer pageSize) {
		Integer userId = WebUtils.currUserId(request);
		Map<String, Object> params = WebUtils.getMapParams(request);
		Ret ret = UserCoinService.me.getUserRecharge(userId, params, pageNumber, pageSize);
		if (ret.isOk()) {
			return Resp.ok().data(ret.get("data"));
		} else {
			return Resp.fail(ret.getStr("msg"));
		}
	}

	/**
	 * 用户资产明细
	 * @param request
	 * @param coinmode
	 * @param month
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	@RequestPath(value = "/getCoinDetail")
	public Resp getCoinDetail(HttpRequest request, Short coinmode, String month, Integer pageNumber, Integer pageSize) {
		Integer userId = WebUtils.currUserId(request);
		Ret ret = UserCoinItemService.me.getUserCoinItem(userId, coinmode, month, pageNumber, pageSize);
		if (ret.isOk()) {
			return Resp.ok().data(ret.get("data"));
		} else {
			return Resp.fail(ret.getStr("msg"));
		}
	}
}
