package com.vetti.web.controller.hotake;

import com.vetti.common.annotation.Log;
import com.vetti.common.core.controller.BaseController;
import com.vetti.common.core.domain.R;
import com.vetti.common.core.page.TableWebDataInfo;
import com.vetti.common.enums.BusinessType;
import com.vetti.hotake.domain.HotakeSettingsJob;
import com.vetti.hotake.domain.dto.HotakeSettingsJobDictDto;
import com.vetti.hotake.service.IHotakeSettingsJobService;
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;

/**
 * 用户首选工作设置Controller
 *
 * @author wangxiangshun
 * @date 2025-11-02
 */
@Api(tags = "用户首选工作设置")
@RestController
@RequestMapping("/hotake/settingsJob")
public class HotakeSettingsJobController extends BaseController {
    @Autowired
    private IHotakeSettingsJobService hotakeSettingsJobService;

    /**
     * 查询用户首选工作设置列表
     */
    @ApiOperation("查询用户首选工作设置列表(分页)")
    @GetMapping("/getPagelist")
    public TableWebDataInfo<HotakeSettingsJob> list(HotakeSettingsJob hotakeSettingsJob) {
        startPage();
        hotakeSettingsJob.setCreateBy(getUsername());
        List<HotakeSettingsJob> list = hotakeSettingsJobService.selectHotakeSettingsJobList(hotakeSettingsJob);
        return getWebDataTable(list);
    }

    /**
     * 查询用户首选工作设置列表
     */
    @ApiOperation("查询用户首选工作设置列表(无分页)")
    @GetMapping("/getList")
    public R<List<HotakeSettingsJob>> getList(HotakeSettingsJob hotakeSettingsJob) {
        hotakeSettingsJob.setCreateBy(getUsername());
        List<HotakeSettingsJob> list = hotakeSettingsJobService.selectHotakeSettingsJobList(hotakeSettingsJob);
        return R.ok(list, "");
    }

    /**
     * 获取用户首选工作设置字典对照内容
     */
    @ApiOperation("获取用户首选工作设置字典对照内容")
    @GetMapping("/getDictData")
    public R<HotakeSettingsJobDictDto> getDictData() {
        HotakeSettingsJobDictDto dictData = hotakeSettingsJobService.getDictData();
        return R.ok(dictData, "");
    }

    /**
     * 获取用户首选工作设置详细信息
     */
    @ApiOperation("获取用户首选工作设置详细信息")
    @GetMapping(value = "/{id}")
    public R<HotakeSettingsJob> getInfo(@ApiParam("设置ID") @PathVariable("id") Long id) {
        return R.ok(hotakeSettingsJobService.selectHotakeSettingsJobById(id), "");
    }

    /**
     * 新增用户首选工作设置
     */
    @ApiOperation("新增用户首选工作设置")
    @Log(title = "用户首选工作设置", businessType = BusinessType.INSERT)
    @PostMapping
    public R<HotakeSettingsJob> add(@RequestBody HotakeSettingsJob hotakeSettingsJob) {
        return R.ok(hotakeSettingsJobService.insertHotakeSettingsJob(hotakeSettingsJob));
    }

    /**
     * 修改用户首选工作设置
     */
    @ApiOperation("修改用户首选工作设置")
    @Log(title = "用户首选工作设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<HotakeSettingsJob> edit(@RequestBody HotakeSettingsJob hotakeSettingsJob) {
        return R.ok(hotakeSettingsJobService.updateHotakeSettingsJob(hotakeSettingsJob));
    }

    /**
     * 删除用户首选工作设置
     */
    @ApiOperation("删除用户首选工作设置")
    @Log(title = "用户首选工作设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public R remove(@PathVariable Long id) {
        return R.ok(hotakeSettingsJobService.deleteHotakeSettingsJobById(id));
    }

}
