| | |
| | | package com.ycl.platform.controller; |
| | | |
| | | import com.ycl.platform.domain.form.BatchEditPointForm; |
| | | import com.ycl.system.domain.group.Update; |
| | | import com.ycl.system.domain.group.Add; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import lombok.RequiredArgsConstructor; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | |
| | | import com.ycl.platform.domain.query.YwPointQuery; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * 运维点位 前端控制器 |
| | |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | @PreAuthorize("@ss.hasPermi('point:add')") |
| | | public Result add(@RequestBody @Validated(Add.class) YwPointForm form) { |
| | | return ywPointService.add(form); |
| | | } |
| | | |
| | | @PostMapping("/batch") |
| | | @ApiOperation(value = "批量添加", notes = "批量添加") |
| | | @PreAuthorize("@ss.hasPermi('point:add')") |
| | | public Result batchAdd(@RequestBody @NotEmpty(message = "数据不能为空") List<YwPointForm> form) { |
| | | return ywPointService.batchAdd(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | @PreAuthorize("@ss.hasPermi('point:edit')") |
| | | public Result update(@RequestBody @Validated(Update.class) YwPointForm form) { |
| | | return ywPointService.update(form); |
| | | } |
| | | |
| | | @PutMapping("/batch") |
| | | @ApiOperation(value = "批量修改运维单位", notes = "批量修改运维单位") |
| | | @PreAuthorize("@ss.hasPermi('point:edit')") |
| | | public Result batchEdit(@RequestBody @Validated BatchEditPointForm form) { |
| | | return ywPointService.batchEdit(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | @PreAuthorize("@ss.hasPermi('point:remove')") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return ywPointService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | @PreAuthorize("@ss.hasPermi('point:remove')") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return ywPointService.remove(ids); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('point:page')") |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | @PreAuthorize("@ss.hasPermi('point:page')") |
| | | public Result page(YwPointQuery query) { |
| | | return ywPointService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | @PreAuthorize("@ss.hasPermi('point:query')") |
| | | public Result detail(@PathVariable("id") String id) { |
| | | return ywPointService.detail(id); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | // @PreAuthorize("@ss.hasPermi('point:list')") |
| | | public Result list() { |
| | | return ywPointService.all(); |
| | | } |
| | | |
| | | @GetMapping("/select") |
| | | @ApiOperation(value = "点位下拉", notes = "点位下拉") |
| | | public Result select(@NotBlank(message = "请输入点位") String keyword) { |
| | | return ywPointService.select(keyword); |
| | | } |
| | | |
| | | @GetMapping("/export") |
| | | @ApiOperation(value = "导出数据", notes = "导出数据") |
| | | public void export(YwPointQuery query, HttpServletResponse response) throws IOException { |
| | | ywPointService.export(query, response); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @ApiOperation(value = "导入数据", notes = "导入数据") |
| | | public Result importData(MultipartFile file, |
| | | Integer unitId, |
| | | String startTime, |
| | | Boolean needUpdateUnit, |
| | | String endTime) throws IOException, ParseException { |
| | | Date start = null; |
| | | Date end = null; |
| | | if (-1 == unitId) { |
| | | unitId = null; |
| | | } |
| | | if (StringUtils.hasText(startTime)) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | start = format.parse(startTime); |
| | | } |
| | | if (StringUtils.hasText(startTime)) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | end = format.parse(endTime); |
| | | } |
| | | return ywPointService.importData(file, unitId, start, end, needUpdateUnit); |
| | | } |
| | | |
| | | } |