package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.ChargeType;
import com.ym.mec.biz.dal.entity.SysUserCashAccount;
import com.ym.mec.biz.service.ChargeTypeService;
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("userCashAccount")
@Api(tags = "用户账户服务")
@RestController
public class SysUserCashAccountController extends BaseController {

    @Autowired
    private SysUserCashAccountService sysUserCashAccountService;

//    @ApiOperation(value = "新增用户账户")
//    @PostMapping("/add")
//    public Object add(SysUserCashAccount sysUserCashAccount) {
//        sysUserCashAccountService.insert(sysUserCashAccount);
//        return succeed();
//    }

    @ApiOperation(value = "获取用户账户信息")
    @GetMapping("/get")
    public Object add() {
        AuthUser user = SecurityUtils.getUser();
        if(user == null){
            return failed("请重新登录");
        }
        return succeed(sysUserCashAccountService.get(user.getUserId()));
    }

//    @ApiOperation(value = "删除收费类型")
//    @PostMapping("/del/{id}")
//    public Object del(@ApiParam(value = "收费类型编号", required = true) @PathVariable("id") Integer id) {
//        sysUserCashAccountService.delete(id);
//        return succeed();
//    }
//
//    @ApiOperation(value = "修改收费类型")
//    @PostMapping("/update")
//    public Object update(SysUserCashAccount sysUserCashAccount) {
//        sysUserCashAccount.setUpdateTime(new Date());
//        sysUserCashAccountService.update(sysUserCashAccount);
//        return succeed();
//    }

    @ApiOperation(value = "分页查询收费类型列表")
    @GetMapping("/queryPage")
    public Object queryPage(QueryInfo queryInfo) {
        return succeed(sysUserCashAccountService.queryPage(queryInfo));
    }

}
