package com.playlet.web.controller.app;

import com.playlet.common.core.domain.Result;
import com.playlet.system.domain.PlayletPublicUser;
import com.playlet.system.domain.PublicUserRecord;
import com.playlet.web.service.app.PublicUserRecordAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "公众号*用户浏览记录接口")
@RestController
@RequestMapping(value = "/app/public/record")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PublicUserRecordAppController {

    private final PublicUserRecordAppService publicUserRecordAppService;

    @ResponseBody
    @PostMapping("/add")
    @ApiOperation(value = "新增用户浏览记录")
    public Result<PublicUserRecord> addRecord(@RequestBody PublicUserRecord userRecord) {
        publicUserRecordAppService.addRecord(userRecord);
        return Result.success(userRecord);
    }

    @ResponseBody
    @PostMapping("/update")
    @ApiOperation(value = "更新用户浏览记录")
    public Result<PublicUserRecord> updateRecord(@RequestBody PublicUserRecord userRecord) {
        publicUserRecordAppService.updateRecord(userRecord);
        return Result.success(userRecord);
    }

}
