package com.ruoyi.applet.contoller;


import com.ruoyi.applet.pojo.dto.ApiQueryIIdMyUserDTO;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.model.domain.AppUsers;
import com.ruoyi.model.domain.AppletComment;
import com.ruoyi.model.domain.AppletServiceLog;
import com.ruoyi.model.domain.AppletUsersTeacher;
import com.ruoyi.model.service.IAppUsersService;
import com.ruoyi.model.service.IAppletCommentService;
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.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "伴宠师-我的流程")
@RestController
@RequestMapping("/applet/info")
public class ApiAppletInfoController {

    @Autowired
    private IAppUsersService appUsersService;
    @Autowired
    private IAppletUsersTeacherService appletUsersTeacherService;
    @Autowired
    private IAppletCommentService appletCommentService;

    //修改用户信息接口
    @ApiOperation("修改用户信息接口")
    @PostMapping("/updateInfo")
    public AjaxResult updateInfo(@RequestBody AppUsers appUsers){
        if((appUsers.getUserId() == null)){
            return AjaxResult.error("用户标识不能为空");
        }
        appUsersService.updateAppUsers(appUsers);
        return AjaxResult.success("修改成功");
    }



    //获取我的评价列表数据带分页
    @ApiOperation("获取我的评价列表数据带分页")
    @GetMapping("/appletCommentList")
    public AjaxResult appletCommentList(AppletComment comment){
        List<AppletComment> logList = appletCommentService.selectAppletCommentList(comment);

        for (AppletComment appletComment : logList) {
            //关联评价人员信息
            AppUsers appUsers = appUsersService.selectAppUsersByUserId(appletComment.getUser1Id());
            appletComment.setAppUsers(appUsers);
            //关联服务人员信息
            AppletUsersTeacher appletUsersTeacher = appletUsersTeacherService.selectAppletUsersTeacherById(appletComment.getUser2Id());
            appletComment.setAppletUsersTeacher(appletUsersTeacher);
        }

        return AjaxResult.success("获取我的评价列表数据带分页",logList);
    }






}
