Files
mosty-dyga-cloud/mosty-yjzl/src/main/java/com/mosty/yjzl/controller/TbZdxlFgdwController.java

125 lines
4.3 KiB
Java
Raw Normal View History

2025-09-05 17:43:45 +08:00
package com.mosty.yjzl.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
2025-09-05 17:43:45 +08:00
import com.mosty.base.model.dto.yjzl.TbZdxlFgdwUpdateDTO;
import com.mosty.base.model.query.yjzl.TbZdxlFgdwQuery;
2025-09-05 17:43:45 +08:00
import com.mosty.base.model.vo.yjzl.TbZdxlFgdwVO;
import com.mosty.base.utils.MessageUtils;
import com.mosty.base.utils.spring.SpringValidUtils;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.base.util.StringUtils;
import com.mosty.common.token.JwtSysUser;
import com.mosty.yjzl.service.TbZdxlFgdwService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @author zhangzhao
* @description 指导巡逻方格点位接口
* @modifier zhangzhao
* @modifiedTime 2025/05/15 21:53
* @since 2025/05/15 21:53
*/
@Api(tags = {"指导巡逻-方格点位接口"})
@RestController
@AllArgsConstructor
@RequestMapping("/tbZdxlFgdw")
public class TbZdxlFgdwController {
/**
* 指导巡逻方格点位表Service
*/
private final TbZdxlFgdwService tbZdxlFgdwService;
/**
* 查询单条根据主键ID
* @param id 主键ID
* @return ResponseResult 实体信息
*/
@ApiOperation(value = "查询单条根据主键ID")
@GetMapping("{id}")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-查询单条根据主键ID", businessType = BusinessType.OTHER)
public ResponseResult<TbZdxlFgdwVO> selectById(@PathVariable("id") Long id) {
2025-09-05 17:43:45 +08:00
return ResponseResult.success(tbZdxlFgdwService.selectById(id));
}
/**
* 查询全量列表
* @return ResponseResult 实体信息列表
*/
@ApiOperation(value = "查询全量列表")
@GetMapping("/selectAllList")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-查询全量列表", businessType = BusinessType.OTHER)
public ResponseResult<List<TbZdxlFgdwVO>> selectAllList() {
return ResponseResult.success(tbZdxlFgdwService.selectAllList());
}
/**
* 查询分页
* @param query 实体查询对象
* @return ResponseResult 实体信息分页列表
*/
@ApiOperation(value = "查询分页")
@GetMapping("/selectPage")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-查询分页", businessType = BusinessType.OTHER)
public ResponseResult<IPage<TbZdxlFgdwVO>> selectPage(TbZdxlFgdwQuery query) {
return ResponseResult.success(tbZdxlFgdwService.selectPage(query));
}
/**
* 查询列表
* @param query 实体查询对象
* @return ResponseResult 实体信息列表
*/
@ApiOperation(value = "查询列表")
@GetMapping("/selectList")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-查询列表", businessType = BusinessType.OTHER)
public ResponseResult<List<TbZdxlFgdwVO>> selectList(TbZdxlFgdwQuery query) {
return ResponseResult.success(tbZdxlFgdwService.selectList(query));
}
2025-09-05 17:43:45 +08:00
/**
* 修改单条
* @param dto 修改DTO对象
* @param bindResult 校验对象
* @return ResponseResult 实体主键ID
*/
@ApiOperation(value = "修改单条")
@PostMapping("update")
@JwtSysUser
@Log(title = "指导巡逻-方格点位接口-修改单条", businessType = BusinessType.UPDATE)
public ResponseResult<Long> update(@RequestBody @Valid TbZdxlFgdwUpdateDTO dto, BindingResult bindResult){
2025-09-05 17:43:45 +08:00
try {
//基础信息校验
String message = SpringValidUtils.getErrorsMsg(bindResult);
if (StringUtils.isNotBlank(message)) {
return ResponseResult.fail(MessageUtils.getEditFailMsg() + message);
}
//修改
Long resultId = tbZdxlFgdwService.updateEntity(dto);
2025-09-05 17:43:45 +08:00
if(ObjectUtils.isNotEmpty(resultId)){
return ResponseResult.success(resultId);
}
return ResponseResult.fail(MessageUtils.getEditFailMsg());
} catch (Exception e) {
e.printStackTrace();
return ResponseResult.fail(MessageUtils.getEditServerErrorMsg());
}
}
}