package com.ruoyi.cms.controller.app;

import com.ruoyi.common.core.domain.entity.UserWorkExperiences;
import com.ruoyi.cms.service.UserWorkExperiencesService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SiteSecurityUtils;
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.List;


/**
 * 用户工作经历表
 *
 * @author 
 * @email 
 * @date 2025-10-10 16:26:26
 */
@RestController
@RequestMapping("/app/userworkexperiences")
@Api(tags = "移动端：用户工作经历")
public class AppUserWorkExperiencesController extends BaseController {

    @Autowired
    private UserWorkExperiencesService userWorkExperiencesService;

    /**
     * 列表
     */
    @ApiOperation("工作经历列表信息")
    @GetMapping("/list")
    public TableDataInfo list(UserWorkExperiences userWorkExperiences){
        if(userWorkExperiences.getUserId()==null){
            userWorkExperiences.setUserId(SiteSecurityUtils.getUserId());
        }
        startPage();
        List<UserWorkExperiences> list=userWorkExperiencesService.getWorkExperiencesList(userWorkExperiences);
        return getDataTable(list);
    }


    /**
     * 获取详细信息
     */
    @ApiOperation("获取工作经历详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult query(@PathVariable("id") Long id){
        return success(userWorkExperiencesService.getWorkExperiencesById(id));
    }

    /**
     * 保存
     */
    @ApiOperation("新增工作经历")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody UserWorkExperiences userWorkExperiences){
        if(userWorkExperiences.getUserId()==null){
            userWorkExperiences.setUserId(SiteSecurityUtils.getUserId());
        }
        return toAjax(userWorkExperiencesService.insertWorkExperiences(userWorkExperiences));
    }

    /**
     * 修改
     */
    @ApiOperation("修改工作经历")
    @PutMapping("/edit")
    public AjaxResult update(@RequestBody UserWorkExperiences userWorkExperiences){
        return toAjax(userWorkExperiencesService.updateWorkExperiencesById(userWorkExperiences));
    }

    /**
     * 删除
     */
    @ApiOperation("删除工作经历")
    @DeleteMapping("/{id}")
    public AjaxResult remove(@ApiParam("招聘会id") @PathVariable Long id){

        return toAjax(userWorkExperiencesService.deleteWorkExperiencesIds(new Long[]{id}));
    }

}
