package com.ruoyi.web.controller.api;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.model.TEmploymentEntrepreneurship;
import com.ruoyi.system.query.TEmploymentEntrepreneurshipQuery;
import com.ruoyi.system.service.TEmploymentEntrepreneurshipService;
import com.ruoyi.system.vo.TEmploymentEntrepreneurshipVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
* 就业创业服务 前端控制器
*
*
* @author xiaochen
* @since 2025-11-06
*/
@Api(tags = "就业创业服务管理")
@RestController
@RequestMapping("/t-employment-entrepreneurship")
public class TEmploymentEntrepreneurshipController {
private final TEmploymentEntrepreneurshipService employmentEntrepreneurshipService;
private final TokenService tokenService;
@Autowired
public TEmploymentEntrepreneurshipController(TEmploymentEntrepreneurshipService employmentEntrepreneurshipService, TokenService tokenService) {
this.employmentEntrepreneurshipService = employmentEntrepreneurshipService;
this.tokenService = tokenService;
}
/**
* 获取就业创业服务管理管理列表
*/
@ApiOperation(value = "获取就业创业服务管理分页列表")
@PostMapping(value = "/pageList")
public R> pageList(@RequestBody TEmploymentEntrepreneurshipQuery query) {
return R.ok(employmentEntrepreneurshipService.pageList(query));
}
/**
* 获取就业创业服务管理管理列表
*/
@ApiOperation(value = "获取就业创业服务管理列表")
@PostMapping(value = "/list")
public R> list() {
return R.ok(employmentEntrepreneurshipService.list(Wrappers.lambdaQuery(TEmploymentEntrepreneurship.class).orderByDesc(TEmploymentEntrepreneurship::getCreateTime)));
}
/**
* 添加就业创业服务管理管理
*/
@Log(title = "就业创业服务管理信息-新增就业创业服务管理", businessType = BusinessType.INSERT)
@ApiOperation(value = "添加就业创业服务管理")
@PostMapping(value = "/add")
public R add(@Validated @RequestBody TEmploymentEntrepreneurship dto) {
if (employmentEntrepreneurshipService.isExit(dto)) {
return R.fail("就业创业服务标题已存在");
}
Long userId = tokenService.getLoginUser().getUser().getUserId();
String nickName = tokenService.getLoginUser().getUser().getNickName();
dto.setUserId(userId);
dto.setReleasePerson(nickName);
return R.ok(employmentEntrepreneurshipService.save(dto));
}
/**
* 修改就业创业服务管理
*/
@Log(title = "就业创业服务管理信息-修改就业创业服务管理", businessType = BusinessType.UPDATE)
@ApiOperation(value = "修改就业创业服务管理")
@PostMapping(value = "/update")
public R update(@Validated @RequestBody TEmploymentEntrepreneurship dto) {
if (employmentEntrepreneurshipService.isExit(dto)) {
return R.fail("就业创业服务标题已存在");
}
return R.ok(employmentEntrepreneurshipService.updateById(dto));
}
/**
* 查看就业创业服务管理详情
*/
@ApiOperation(value = "查看就业创业服务管理详情")
@GetMapping(value = "/getDetailById")
public R getDetailById(@RequestParam String id) {
return R.ok(employmentEntrepreneurshipService.getById(id));
}
/**
* 删除就业创业服务管理
*/
@Log(title = "就业创业服务管理信息-删除就业创业服务管理", businessType = BusinessType.DELETE)
@ApiOperation(value = "删除就业创业服务管理")
@DeleteMapping(value = "/deleteById")
public R deleteById(@RequestParam String id) {
return R.ok(employmentEntrepreneurshipService.removeById(id));
}
/**
* 批量删除就业创业服务管理
*/
@Log(title = "就业创业服务管理信息-删除就业创业服务管理", businessType = BusinessType.DELETE)
@ApiOperation(value = "批量删除就业创业服务管理")
@DeleteMapping(value = "/deleteByIds")
public R deleteByIds(@RequestBody List ids) {
return R.ok(employmentEntrepreneurshipService.removeByIds(ids));
}
}