package com.ruoyi.applet.contoller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.model.domain.AppletServiceLog;
import com.ruoyi.model.domain.AppletUsersTeacher;
import com.ruoyi.model.service.IAppUsersService;
import com.ruoyi.model.service.IAppletServiceLogService;
import com.ruoyi.model.service.IAppletUsersTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "伴宠师工作台-服务记录")
@RestController
@RequestMapping("/applet/serviceLog")
public class ApiAppletServiceLogController {
    @Autowired
    private IAppletServiceLogService appletServiceLogService;


    @ApiOperation("伴宠师工作台-服务记录列表数据查询")
    @GetMapping("/serviceLogList")
    public AjaxResult serviceLogList(AppletServiceLog serviceLog){
        List<AppletServiceLog> logList = appletServiceLogService.selectAppletServiceLogList(serviceLog);
        return AjaxResult.success("服务记录列表数据",logList);
    }

    @ApiOperation("伴宠师工作台-服务记录添加")
    @PostMapping("/insertServiceLog")
    public AjaxResult insertUser(@RequestBody AppletServiceLog serviceLog){
        return toAjax(appletServiceLogService.insertAppletServiceLog(serviceLog));
    }

    @ApiOperation("伴宠师工作台-服务记录修改")
    @PostMapping("/udpateServiceLog")
    public AjaxResult udpateUser(@RequestBody AppletServiceLog serviceLog){
        return toAjax(appletServiceLogService.updateAppletServiceLog(serviceLog));
    }

    @ApiOperation("伴宠师工作台-服务记录删除")
    @PostMapping("/deleteServiceLog")
    public AjaxResult deleteUser(long id){
        return toAjax(appletServiceLogService.deleteAppletServiceLogById(id));
    }

    protected AjaxResult toAjax(int rows) {
        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
    }
}
