electripper-v2/ruoyi-web/src/main/java/com/ruoyi/web/bst/LocationLogController.java
2025-03-24 18:05:02 +08:00

110 lines
3.6 KiB
Java

package com.ruoyi.web.bst;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.bst.locationLog.domain.LocationLogQuery;
import com.ruoyi.bst.locationLog.domain.LocationLogVO;
import com.ruoyi.bst.locationLog.service.LocationLogService;
import com.ruoyi.bst.locationLog.service.LocationLogValidator;
import com.ruoyi.common.annotation.Log;
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.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
/**
* 定位日志Controller
*
* @author ruoyi
* @date 2025-03-24
*/
@RestController
@RequestMapping("/bst/locationLog")
public class LocationLogController extends BaseController
{
@Autowired
private LocationLogService locationLogService;
@Autowired
private LocationLogValidator locationLogValidator;
/**
* 查询定位日志列表
*/
@PreAuthorize("@ss.hasPermi('bst:locationLog:list')")
@GetMapping("/list")
public TableDataInfo list(LocationLogQuery query)
{
startPage();
startOrderBy();
query.setScope(true);
List<LocationLogVO> list = locationLogService.selectLocationLogList(query);
return getDataTable(list);
}
/**
* 根据时间段查询全部定位日志
*/
@PreAuthorize("@ss.hasPermi('bst:locationLog:list')")
@GetMapping("/listByTime")
public AjaxResult listByTime(LocationLogQuery query) {
if (query.getStartTime() == null || query.getEndTime() == null) {
return error("开始时间和结束时间不能为空");
}
query.setScope(true);
List<LocationLogVO> list = locationLogService.selectLocationLogList(query);
return success(list);
}
/**
* 导出定位日志列表
*/
@PreAuthorize("@ss.hasPermi('bst:locationLog:export')")
@Log(title = "定位日志", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, LocationLogQuery query)
{
query.setScope(true);
List<LocationLogVO> list = locationLogService.selectLocationLogList(query);
ExcelUtil<LocationLogVO> util = new ExcelUtil<LocationLogVO>(LocationLogVO.class);
util.exportExcel(response, list, "定位日志数据");
}
/**
* 获取定位日志详细信息
*/
@PreAuthorize("@ss.hasPermi('bst:locationLog:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(locationLogService.selectLocationLogById(id, true));
}
/**
* 删除定位日志
*/
@PreAuthorize("@ss.hasPermi('bst:locationLog:remove')")
@Log(title = "定位日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids)
{
if (!locationLogValidator.canDeleteAll(ids)) {
return error("您无权删除ID为" + ids + "的定位日志");
}
return toAjax(locationLogService.deleteLocationLogByIds(ids));
}
}