package com.goafanti.customer.controller;

import com.goafanti.common.bo.Result;
import com.goafanti.common.constant.ErrorConstants;
import com.goafanti.common.controller.BaseApiController;
import com.goafanti.common.model.UserReceiveLog;
import com.goafanti.common.utils.StringUtils;
import com.goafanti.customer.bo.UserReceiveLogListBo;
import com.goafanti.customer.service.UserReceiveLogService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/admin/userRecevieLog")
public class UserReceiveLogApiController extends BaseApiController {
    @Resource
    private UserReceiveLogService userReceiveLogService;


    /**
     * 客户领取日志列表
     * @return
     */
    @GetMapping("/list")
    public Result<UserReceiveLogListBo> list(UserReceiveLog in, Integer pageNo, Integer pageSize) {
        Result res = new Result();
        if (StringUtils.isEmpty(in.getUid())){
            res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "客户Id", "客户Id"));
            return res;
        }
        res.setData(userReceiveLogService.list(in, pageNo, pageSize));
        return res;
    }

    /**
     * 上传图片
     **/
    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public Result uploadOrderInvoiceFile(HttpServletRequest req){
        Result res = new Result();
        res.setData(handleFile(res, "/UserReceiveLog/", false, req, "UserReceiveLog"));
        return res;
    }
}
