package com.ym.mec.web.controller;

import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.dto.CashAccountDetail;
import com.ym.mec.biz.dal.entity.SysUserCashAccount;
import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
import com.ym.mec.biz.service.SysUserCashAccountDetailService;
import com.ym.mec.biz.service.SysUserCashAccountService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;
import com.ym.mec.common.security.AuthUser;
import com.ym.mec.common.security.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RequestMapping("userCashAccountDetail")
@Api(tags = "用户交易明细服务")
@RestController
public class SysUserCashAccountDetailController extends BaseController {

    @Autowired
    private SysUserCashAccountDetailService sysUserCashAccountDetailService;

    @ApiOperation(value = "新增用户交易明细")
    @PostMapping("/add")
    public Object add(SysUserCashAccountDetail sysUserCashAccountDetail) {
        sysUserCashAccountDetailService.insert(sysUserCashAccountDetail);
        return succeed();
    }

//    @ApiOperation(value = "修改用户交易明细")
//    @PostMapping("/update")
//    public Object update(SysUserCashAccountDetail sysUserCashAccountDetail) {
//        sysUserCashAccountDetail.setUpdateTime(new Date());
//        sysUserCashAccountDetailService.update(sysUserCashAccountDetail);
//        return succeed();
//    }

    @ApiOperation(value = "分页查询用户交易明细")
    @GetMapping("/queryPage")
    public Object queryPage(CashAccountDetail queryInfo) {
        AuthUser user = SecurityUtils.getUser();
        if(user == null){
            return failed("请重新登录");
        }
        queryInfo.setUserId(user.getUserId());
        return succeed(sysUserCashAccountDetailService.queryPage(queryInfo));
    }

}
