104 lines
3.7 KiB
Java
104 lines
3.7 KiB
Java
package com.klp.aps.controller;
|
|
|
|
import com.klp.common.annotation.Log;
|
|
import com.klp.common.annotation.RepeatSubmit;
|
|
import com.klp.common.core.controller.BaseController;
|
|
import com.klp.common.core.domain.PageQuery;
|
|
import com.klp.common.core.domain.R;
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
import com.klp.common.core.validate.AddGroup;
|
|
import com.klp.common.core.validate.EditGroup;
|
|
import com.klp.common.enums.BusinessType;
|
|
import com.klp.common.utils.poi.ExcelUtil;
|
|
import com.klp.aps.domain.bo.ApsCalendarShiftBo;
|
|
import com.klp.aps.domain.vo.ApsCalendarShiftVo;
|
|
import com.klp.aps.service.ApsCalendarShiftService;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.constraints.NotEmpty;
|
|
import javax.validation.constraints.NotNull;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 日历班次配置Controller
|
|
*/
|
|
@Validated
|
|
@RequiredArgsConstructor
|
|
@RestController
|
|
@RequestMapping("/aps/calendar-shift")
|
|
public class ApsCalendarShiftController extends BaseController {
|
|
|
|
private final ApsCalendarShiftService apsCalendarShiftService;
|
|
|
|
/**
|
|
* 查询日历班次配置列表
|
|
*/
|
|
@GetMapping("/list")
|
|
public TableDataInfo<ApsCalendarShiftVo> list(ApsCalendarShiftBo bo, PageQuery pageQuery) {
|
|
return apsCalendarShiftService.queryPageList(bo, pageQuery);
|
|
}
|
|
|
|
/**
|
|
* 导出日历班次配置列表
|
|
*/
|
|
@Log(title = "日历班次配置", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
public void export(ApsCalendarShiftBo bo, HttpServletResponse response) {
|
|
List<ApsCalendarShiftVo> list = apsCalendarShiftService.queryList(bo);
|
|
ExcelUtil.exportExcel(list, "日历班次配置", ApsCalendarShiftVo.class, response);
|
|
}
|
|
|
|
/**
|
|
* 获取日历班次配置详细信息
|
|
*/
|
|
@GetMapping("/{configId}")
|
|
public R<ApsCalendarShiftVo> getInfo(@NotNull(message = "主键不能为空")
|
|
@PathVariable Long configId) {
|
|
return R.ok(apsCalendarShiftService.queryById(configId));
|
|
}
|
|
|
|
/**
|
|
* 新增日历班次配置
|
|
*/
|
|
@Log(title = "日历班次配置", businessType = BusinessType.INSERT)
|
|
@RepeatSubmit()
|
|
@PostMapping()
|
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody ApsCalendarShiftBo bo) {
|
|
return toAjax(apsCalendarShiftService.insertByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 修改日历班次配置
|
|
*/
|
|
@Log(title = "日历班次配置", businessType = BusinessType.UPDATE)
|
|
@RepeatSubmit()
|
|
@PutMapping()
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ApsCalendarShiftBo bo) {
|
|
return toAjax(apsCalendarShiftService.updateByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 删除日历班次配置
|
|
*/
|
|
@Log(title = "日历班次配置", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{configIds}")
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
@PathVariable Long[] configIds) {
|
|
return toAjax(apsCalendarShiftService.deleteWithValidByIds(Arrays.asList(configIds), true));
|
|
}
|
|
|
|
/**
|
|
* 一键生成全年工作日日历
|
|
*/
|
|
@Log(title = "日历班次配置", businessType = BusinessType.INSERT)
|
|
@PostMapping("/generate-workday-year/{year}")
|
|
public R<Integer> generateWorkdayYear(@PathVariable Integer year,
|
|
@RequestParam(value = "overwriteExisting", required = false, defaultValue = "false") Boolean overwriteExisting) {
|
|
return R.ok(apsCalendarShiftService.generateWorkdayForYear(year, overwriteExisting));
|
|
}
|
|
}
|