区块管理、气井管理

This commit is contained in:
wangshilong 2024-11-17 22:07:00 +08:00
parent 91ca2b51f2
commit adb74629bb
29 changed files with 1741 additions and 3 deletions

57
pom.xml
View File

@ -28,9 +28,23 @@
<druid.version>1.2.20</druid.version>
<easyexcel.version>3.1.0</easyexcel.version>
<jakarta.version>6.0.0</jakarta.version>
<lombok.version>1.18.30</lombok.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<lombok-maven-plugin.version>1.18.20.0</lombok-maven-plugin.version>
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
@ -39,6 +53,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
@ -204,6 +222,45 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>${lombok-maven-plugin.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${lombok-mapstruct-binding.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>3.2.8</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.unmappedTargetPolicy=IGNORE
</compilerArg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -3,11 +3,15 @@ package com.isu.gaswellwatch.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.isu.gaswellwatch.utils.LocalDateTimeToStringConverter;
import com.isu.gaswellwatch.utils.StringToLocalDateTimeConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.time.LocalDateTime;
import java.util.List;
@Configuration
@ -16,12 +20,14 @@ public class WebConfig implements WebMvcConfigurer {
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(LocalDateTime.class, LocalDateTimeToStringConverter.INSTANCE);
simpleModule.addDeserializer(LocalDateTime.class, StringToLocalDateTimeConverter.INSTANCE);
objectMapper.registerModule(simpleModule);
jackson2HttpMessageConverter.setObjectMapper(objectMapper);
converters.addFirst(jackson2HttpMessageConverter);
}

View File

@ -0,0 +1,89 @@
package com.isu.gaswellwatch.controller;
import java.util.Collection;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isu.gaswellwatch.service.BlockService;
import com.isu.gaswellwatch.entity.Response;
import com.isu.gaswellwatch.enums.LogType;
import com.isu.gaswellwatch.dto.BlockCreateRequest;
import com.isu.gaswellwatch.dto.BlockEditRequest;
import com.isu.gaswellwatch.vo.BlockPageQuery;
import com.isu.gaswellwatch.vo.BlockVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isu.gaswellwatch.annotation.OperationLog;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;
/**
* 区块管理
*
* @author scwsl
* @date 2024-11-17
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/blocks")
public class BlockController {
private final BlockService blockService;
/**
* 查询区块列表
*/
@GetMapping
public Response<Page<BlockVO>> page(BlockPageQuery query) {
return Response.succeed(blockService.pageForQuery(query));
}
/**
* 获取区块详细信息
*/
@GetMapping(value = "/{id}")
public Response<BlockVO> getInfo(@PathVariable("id") Long id) {
return Response.succeed(blockService.selectBlockById(id));
}
/**
* 新增区块
*/
@PostMapping
@OperationLog(description = "新增区块", type = LogType.ADD)
public Response<String> add(@RequestBody @Valid BlockCreateRequest blockCreateRequest) {
blockService.insertBlock(blockCreateRequest);
return Response.succeed();
}
/**
* 修改区块
*/
@PutMapping
@OperationLog(description = "修改区块", type = LogType.UPDATE)
public Response<String> edit(@RequestBody BlockEditRequest blockEditRequest) {
blockService.updateBlock(blockEditRequest);
return Response.succeed();
}
/**
* 删除区块
*/
@DeleteMapping("/{ids}")
@OperationLog(description = "删除区块", type = LogType.DELETE)
public Response<String> delete(@PathVariable Collection<Long> ids) {
blockService.deleteBlockByIds(ids);
return Response.succeed();
}
}

View File

@ -0,0 +1,89 @@
package com.isu.gaswellwatch.controller;
import java.util.Collection;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isu.gaswellwatch.service.GasWellService;
import com.isu.gaswellwatch.entity.Response;
import com.isu.gaswellwatch.enums.LogType;
import com.isu.gaswellwatch.dto.GasWellCreateRequest;
import com.isu.gaswellwatch.dto.GasWellEditRequest;
import com.isu.gaswellwatch.vo.GasWellPageQuery;
import com.isu.gaswellwatch.vo.GasWellVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isu.gaswellwatch.annotation.OperationLog;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;
/**
* 气井管理
*
* @author scwsl
* @date 2024-11-17
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/gaswell")
public class GasWellController {
private final GasWellService gasWellService;
/**
* 查询气井列表
*/
@GetMapping
public Response<Page<GasWellVO>> page(GasWellPageQuery query) {
return Response.succeed(gasWellService.pageForQuery(query));
}
/**
* 获取气井详细信息
*/
@GetMapping(value = "/{id}")
public Response<GasWellVO> getInfo(@PathVariable("id") Long id) {
return Response.succeed(gasWellService.selectGasWellById(id));
}
/**
* 新增气井
*/
@PostMapping
@OperationLog(description = "新增气井", type = LogType.ADD)
public Response<String> add(@RequestBody @Valid GasWellCreateRequest gasWellCreateRequest) {
gasWellService.insertGasWell(gasWellCreateRequest);
return Response.succeed();
}
/**
* 修改气井
*/
@PutMapping
@OperationLog(description = "修改气井", type = LogType.UPDATE)
public Response<String> edit(@RequestBody GasWellEditRequest gasWellEditRequest) {
gasWellService.updateGasWell(gasWellEditRequest);
return Response.succeed();
}
/**
* 删除气井
*/
@DeleteMapping("/{ids}")
@OperationLog(description = "删除气井", type = LogType.DELETE)
public Response<String> delete(@PathVariable Collection<Long> ids) {
gasWellService.deleteGasWellByIds(ids);
return Response.succeed();
}
}

View File

@ -0,0 +1,79 @@
package com.isu.gaswellwatch.dao;
import java.util.Collection;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isu.gaswellwatch.vo.BlockVO;
import com.isu.gaswellwatch.vo.BlockPageQuery;
import com.isu.gaswellwatch.entity.Block;
/**
* 区块Mapper接口
*
* @author scwsl
* @date 2024-11-17
*/
@Mapper
@Repository
public interface BlockDao extends BaseMapper<Block> {
/**
* 查询区块
*
* @param id 区块主键
* @return 区块
*/
Block selectBlockById(Long id);
/**
* 查询区块列表
*
* @param block 区块
* @return 区块集合
*/
List<Block> selectBlockList(Block block);
/**
* 分页查询区块列表
*
* @param query 查询条件
* @return 区块
*/
Page<BlockVO> pageForQuery(Page<BlockVO> page, @Param("query") BlockPageQuery query);
/**
* 新增区块
*
* @param block 区块
* @return 结果
*/
int insertBlock(Block block);
/**
* 修改区块
*
* @param block 区块
* @return 结果
*/
int updateBlock(Block block);
/**
* 删除区块
*
* @param id 区块主键
* @return 结果
*/
int deleteBlockById(Long id);
/**
* 批量删除区块
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteBlockByIds(Collection<Long> ids);
}

View File

@ -0,0 +1,79 @@
package com.isu.gaswellwatch.dao;
import java.util.Collection;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isu.gaswellwatch.vo.GasWellVO;
import com.isu.gaswellwatch.vo.GasWellPageQuery;
import com.isu.gaswellwatch.entity.GasWell;
/**
* 气井Mapper接口
*
* @author scwsl
* @date 2024-11-17
*/
@Mapper
@Repository
public interface GasWellDao extends BaseMapper<GasWell> {
/**
* 查询气井
*
* @param id 气井主键
* @return 气井
*/
GasWell selectGasWellById(Long id);
/**
* 查询气井列表
*
* @param gasWell 气井
* @return 气井集合
*/
List<GasWell> selectGasWellList(GasWell gasWell);
/**
* 分页查询气井列表
*
* @param query 查询条件
* @return 气井
*/
Page<GasWellVO> pageForQuery(Page<GasWellVO> page, @Param("query") GasWellPageQuery query);
/**
* 新增气井
*
* @param gasWell 气井
* @return 结果
*/
int insertGasWell(GasWell gasWell);
/**
* 修改气井
*
* @param gasWell 气井
* @return 结果
*/
int updateGasWell(GasWell gasWell);
/**
* 删除气井
*
* @param id 气井主键
* @return 结果
*/
int deleteGasWellById(Long id);
/**
* 批量删除气井
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteGasWellByIds(Collection<Long> ids);
}

View File

@ -0,0 +1,41 @@
package com.isu.gaswellwatch.dto;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* 创建区块对象 blocks
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class BlockCreateRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** 上级标识 */
private Long parentId;
/** 名称 */
private String name;
/** 描述 */
private String details;
}

View File

@ -0,0 +1,43 @@
package com.isu.gaswellwatch.dto;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* 修改区块对象 blocks
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class BlockEditRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 上级标识 */
private Long parentId;
/** 名称 */
private String name;
/** 描述 */
private String details;
}

View File

@ -0,0 +1,40 @@
package com.isu.gaswellwatch.dto;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* 创建气井对象 gas_wells
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class GasWellCreateRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** 关联公司 */
private Long companyId;
/** 气井名称 */
private String name;
/** 描述 */
private String details;
}

View File

@ -0,0 +1,43 @@
package com.isu.gaswellwatch.dto;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* 修改气井对象 gas_wells
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class GasWellEditRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 关联公司 */
private Long companyId;
/** 气井名称 */
private String name;
/** 描述 */
private String details;
}

View File

@ -0,0 +1,54 @@
package com.isu.gaswellwatch.entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
/**
* 区块对象 blocks
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class Block extends Model<Block> {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 上级标识 */
private Long parentId;
/** 名称 */
private String name;
/** 描述 */
private String details;
/** 是否已删除 */
private Integer deleted;
/** 创建人 */
private Long createBy;
/** 创建时间 */
private LocalDateTime createTime;
/** 更新人 */
private Long updateBy;
/** 更新时间 */
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,51 @@
package com.isu.gaswellwatch.entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
/**
* 气井对象 gas_wells
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class GasWell extends Model<GasWell> {
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 关联公司 */
private Long companyId;
/** 气井名称 */
private String name;
/** 描述 */
private String details;
/** 创建人 */
private Long createBy;
/** 创建时间 */
private LocalDateTime createTime;
/** 更新人 */
private Long updateBy;
/** 更新时间 */
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,63 @@
package com.isu.gaswellwatch.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import com.isu.gaswellwatch.entity.Block;
import com.isu.gaswellwatch.dto.BlockCreateRequest;
import com.isu.gaswellwatch.dto.BlockEditRequest;
import com.isu.gaswellwatch.vo.BlockVO;
import com.isu.gaswellwatch.vo.UserLoginInfoVO;
import cn.dev33.satoken.stp.StpUtil;
import com.isu.gaswellwatch.constants.UserConstant;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.List;
/**
* 区块Mapper blocks
*
* @author scwsl
* @date 2024-11-17
*/
@Mapper
public interface BlockMapper {
void create(BlockCreateRequest request, @MappingTarget Block block);
@Mapping(target = "id", ignore = true)
void copyToEntity(BlockEditRequest request, @MappingTarget Block block);
BlockVO toPageVO(Block entity);
List<BlockVO> toPageVO(List<Block> entities);
default void copy(BlockEditRequest request, Block block) {
UserLoginInfoVO userLoginInfoVO = (UserLoginInfoVO) StpUtil.getTokenSession()
.get(UserConstant.TOKEN_SESSION);
if (Objects.nonNull(userLoginInfoVO) && Objects.nonNull(userLoginInfoVO.getUserVO())) {
block.setUpdateBy(block.getCreateBy());
}
block.setUpdateTime(LocalDateTime.now());
copyToEntity(request, block);
}
default Block create(BlockCreateRequest request) {
UserLoginInfoVO userLoginInfoVO = (UserLoginInfoVO) StpUtil.getTokenSession()
.get(UserConstant.TOKEN_SESSION);
Block block =new Block();
block.setCreateTime(LocalDateTime.now());
block.setUpdateTime(block.getCreateTime());
if (Objects.nonNull(userLoginInfoVO) && Objects.nonNull(userLoginInfoVO.getUserVO())) {
block.setCreateBy(userLoginInfoVO.getUserVO().getId());
block.setUpdateBy(block.getCreateBy());
}
create(request, block);
return block;
}
}

View File

@ -0,0 +1,63 @@
package com.isu.gaswellwatch.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import com.isu.gaswellwatch.entity.GasWell;
import com.isu.gaswellwatch.dto.GasWellCreateRequest;
import com.isu.gaswellwatch.dto.GasWellEditRequest;
import com.isu.gaswellwatch.vo.GasWellVO;
import com.isu.gaswellwatch.vo.UserLoginInfoVO;
import cn.dev33.satoken.stp.StpUtil;
import com.isu.gaswellwatch.constants.UserConstant;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.List;
/**
* 气井Mapper gas_wells
*
* @author scwsl
* @date 2024-11-17
*/
@Mapper
public interface GasWellMapper {
void create(GasWellCreateRequest request, @MappingTarget GasWell gasWell);
@Mapping(target = "id", ignore = true)
void copyToEntity(GasWellEditRequest request, @MappingTarget GasWell gasWell);
GasWellVO toPageVO(GasWell entity);
List<GasWellVO> toPageVO(List<GasWell> entities);
default void copy(GasWellEditRequest request, GasWell gasWell) {
UserLoginInfoVO userLoginInfoVO = (UserLoginInfoVO) StpUtil.getTokenSession()
.get(UserConstant.TOKEN_SESSION);
if (Objects.nonNull(userLoginInfoVO) && Objects.nonNull(userLoginInfoVO.getUserVO())) {
gasWell.setUpdateBy(gasWell.getCreateBy());
}
gasWell.setUpdateTime(LocalDateTime.now());
copyToEntity(request, gasWell);
}
default GasWell create(GasWellCreateRequest request) {
UserLoginInfoVO userLoginInfoVO = (UserLoginInfoVO) StpUtil.getTokenSession()
.get(UserConstant.TOKEN_SESSION);
GasWell gasWell =new GasWell();
gasWell.setCreateTime(LocalDateTime.now());
gasWell.setUpdateTime(gasWell.getCreateTime());
if (Objects.nonNull(userLoginInfoVO) && Objects.nonNull(userLoginInfoVO.getUserVO())) {
gasWell.setCreateBy(userLoginInfoVO.getUserVO().getId());
gasWell.setUpdateBy(gasWell.getCreateBy());
}
create(request, gasWell);
return gasWell;
}
}

View File

@ -0,0 +1,77 @@
package com.isu.gaswellwatch.service;
import java.util.List;
import java.util.Collection;
import com.isu.gaswellwatch.dto.BlockCreateRequest;
import com.isu.gaswellwatch.dto.BlockEditRequest;
import com.isu.gaswellwatch.vo.BlockPageQuery;
import com.isu.gaswellwatch.vo.BlockVO;
import com.isu.gaswellwatch.entity.Block;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* 区块Service接口
*
* @author scwsl
* @date 2024-11-17
*/
public interface BlockService extends IService<Block> {
/**
* 查询区块
*
* @param id 区块主键
* @return 区块
*/
BlockVO selectBlockById(Long id);
/**
* 查询区块列表
*
* @param block 区块
* @return 区块集合
*/
List<BlockVO> selectBlockList(Block block);
/**
* 分页查询区块列表
*
* @param query 查询条件
* @return 区块
*/
Page<BlockVO> pageForQuery(BlockPageQuery query);
/**
* 新增区块
*
* @param blockCreateRequest 区块
* @return 结果
*/
int insertBlock(BlockCreateRequest blockCreateRequest);
/**
* 修改区块
*
* @param blockEditRequest 区块
* @return 结果
*/
int updateBlock(BlockEditRequest blockEditRequest);
/**
* 删除区块信息
*
* @param id 区块主键
* @return 结果
*/
int deleteBlockById(Long id);
/**
* 批量删除区块
*
* @param ids 需要删除的区块主键集合
* @return 结果
*/
int deleteBlockByIds(Collection<Long> ids);
}

View File

@ -0,0 +1,77 @@
package com.isu.gaswellwatch.service;
import java.util.List;
import java.util.Collection;
import com.isu.gaswellwatch.dto.GasWellCreateRequest;
import com.isu.gaswellwatch.dto.GasWellEditRequest;
import com.isu.gaswellwatch.vo.GasWellPageQuery;
import com.isu.gaswellwatch.vo.GasWellVO;
import com.isu.gaswellwatch.entity.GasWell;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* 气井Service接口
*
* @author scwsl
* @date 2024-11-17
*/
public interface GasWellService extends IService<GasWell> {
/**
* 查询气井
*
* @param id 气井主键
* @return 气井
*/
GasWellVO selectGasWellById(Long id);
/**
* 查询气井列表
*
* @param gasWell 气井
* @return 气井集合
*/
List<GasWellVO> selectGasWellList(GasWell gasWell);
/**
* 分页查询气井列表
*
* @param query 查询条件
* @return 气井
*/
Page<GasWellVO> pageForQuery(GasWellPageQuery query);
/**
* 新增气井
*
* @param gasWellCreateRequest 气井
* @return 结果
*/
int insertGasWell(GasWellCreateRequest gasWellCreateRequest);
/**
* 修改气井
*
* @param gasWellEditRequest 气井
* @return 结果
*/
int updateGasWell(GasWellEditRequest gasWellEditRequest);
/**
* 删除气井信息
*
* @param id 气井主键
* @return 结果
*/
int deleteGasWellById(Long id);
/**
* 批量删除气井
*
* @param ids 需要删除的气井主键集合
* @return 结果
*/
int deleteGasWellByIds(Collection<Long> ids);
}

View File

@ -0,0 +1,117 @@
package com.isu.gaswellwatch.service.impl;
import java.util.Collection;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isu.gaswellwatch.dto.BlockCreateRequest;
import com.isu.gaswellwatch.dto.BlockEditRequest;
import com.isu.gaswellwatch.vo.BlockPageQuery;
import com.isu.gaswellwatch.vo.BlockVO;
import com.isu.gaswellwatch.dao.BlockDao;
import com.isu.gaswellwatch.entity.Block;
import com.isu.gaswellwatch.service.BlockService;
import com.isu.gaswellwatch.mapper.BlockMapper;
import org.mapstruct.factory.Mappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* 区块Service业务层处理
*
* @author scwsl
* @date 2024-11-17
*/
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class BlockServiceImpl extends ServiceImpl<BlockDao, Block> implements BlockService {
private final BlockDao blockDao;
private final BlockMapper blockMapper = Mappers.getMapper(BlockMapper.class);
/**
* 查询区块
*
* @param id 区块主键
* @return 区块
*/
@Override
public BlockVO selectBlockById(Long id) {
return blockMapper.toPageVO(blockDao.selectBlockById(id));
}
/**
* 查询区块列表
*
* @param block 区块
* @return 区块
*/
@Override
public List<BlockVO> selectBlockList(Block block) {
return blockMapper.toPageVO(blockDao.selectBlockList(block));
}
/**
* 分页查询区块列表
*
* @param query 查询条件
* @return 区块
*/
@Override
public Page<BlockVO> pageForQuery(BlockPageQuery query){
return blockDao.pageForQuery(new Page<>(query.getCurrentPage(), query.getPageSize()), query);
}
/**
* 新增区块
*
* @param blockCreateRequest 区块
* @return 结果
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int insertBlock(BlockCreateRequest blockCreateRequest) {
return blockDao.insertBlock(blockMapper.create(blockCreateRequest));
}
/**
* 修改区块
*
* @param blockEditRequest 区块
* @return 结果
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int updateBlock(BlockEditRequest blockEditRequest) {
Block block = blockDao.selectBlockById(blockEditRequest.getId());
blockMapper.copyToEntity(blockEditRequest, block);
return blockDao.updateBlock(block);
}
/**
* 删除区块信息
*
* @param id 区块主键
* @return 结果
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int deleteBlockById(Long id) {
return blockDao.deleteBlockById(id);
}
/**
* 批量删除删除区块信息
*
* @param ids 区块主键
* @return 数量
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int deleteBlockByIds(Collection<Long> ids) {
return blockDao.deleteBlockByIds(ids);
}
}

View File

@ -0,0 +1,117 @@
package com.isu.gaswellwatch.service.impl;
import java.util.Collection;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isu.gaswellwatch.dto.GasWellCreateRequest;
import com.isu.gaswellwatch.dto.GasWellEditRequest;
import com.isu.gaswellwatch.vo.GasWellPageQuery;
import com.isu.gaswellwatch.vo.GasWellVO;
import com.isu.gaswellwatch.dao.GasWellDao;
import com.isu.gaswellwatch.entity.GasWell;
import com.isu.gaswellwatch.service.GasWellService;
import com.isu.gaswellwatch.mapper.GasWellMapper;
import org.mapstruct.factory.Mappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* 气井Service业务层处理
*
* @author scwsl
* @date 2024-11-17
*/
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class GasWellServiceImpl extends ServiceImpl<GasWellDao, GasWell> implements GasWellService {
private final GasWellDao gasWellDao;
private final GasWellMapper gasWellMapper = Mappers.getMapper(GasWellMapper.class);
/**
* 查询气井
*
* @param id 气井主键
* @return 气井
*/
@Override
public GasWellVO selectGasWellById(Long id) {
return gasWellMapper.toPageVO(gasWellDao.selectGasWellById(id));
}
/**
* 查询气井列表
*
* @param gasWell 气井
* @return 气井
*/
@Override
public List<GasWellVO> selectGasWellList(GasWell gasWell) {
return gasWellMapper.toPageVO(gasWellDao.selectGasWellList(gasWell));
}
/**
* 分页查询气井列表
*
* @param query 查询条件
* @return 气井
*/
@Override
public Page<GasWellVO> pageForQuery(GasWellPageQuery query){
return gasWellDao.pageForQuery(new Page<>(query.getCurrentPage(), query.getPageSize()), query);
}
/**
* 新增气井
*
* @param gasWellCreateRequest 气井
* @return 结果
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int insertGasWell(GasWellCreateRequest gasWellCreateRequest) {
return gasWellDao.insertGasWell(gasWellMapper.create(gasWellCreateRequest));
}
/**
* 修改气井
*
* @param gasWellEditRequest 气井
* @return 结果
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int updateGasWell(GasWellEditRequest gasWellEditRequest) {
GasWell gasWell = gasWellDao.selectGasWellById(gasWellEditRequest.getId());
gasWellMapper.copyToEntity(gasWellEditRequest, gasWell);
return gasWellDao.updateGasWell(gasWell);
}
/**
* 删除气井信息
*
* @param id 气井主键
* @return 结果
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int deleteGasWellById(Long id) {
return gasWellDao.deleteGasWellById(id);
}
/**
* 批量删除删除气井信息
*
* @param ids 气井主键
* @return 数量
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int deleteGasWellByIds(Collection<Long> ids) {
return gasWellDao.deleteGasWellByIds(ids);
}
}

View File

@ -0,0 +1,48 @@
package com.isu.gaswellwatch.utils;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.springframework.core.convert.converter.Converter;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/1/26 16:02
*/
public class LocalDateTimeToStringConverter extends JsonSerializer<LocalDateTime> implements Converter<LocalDateTime, String> {
public static final LocalDateTimeToStringConverter INSTANCE = new LocalDateTimeToStringConverter();
@Override
public void serialize(LocalDateTime value, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
if (Objects.isNull(value)) {
jsonGenerator.writeNull();
} else {
jsonGenerator.writeString(convert(value));
}
}
@Override
public void serializeWithType(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException {
serialize(value, gen, serializers);
}
@Override
public String convert(LocalDateTime source) {
if (Objects.isNull(source)) {
return null;
}
return StringToLocalDateTimeConverter.ZH_CN_LOCAL_DATE_TIME.format(source);
}
@Override
public Class<LocalDateTime> handledType() {
return LocalDateTime.class;
}
}

View File

@ -0,0 +1,42 @@
package com.isu.gaswellwatch.utils;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
/**
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/2/1 14:39
*/
@MappedTypes(LocalDateTime.class)
@MappedJdbcTypes({JdbcType.DATE, JdbcType.TIMESTAMP})
public class LocalDateTimeTypeHandler extends BaseTypeHandler<LocalDateTime> {
@Override
public void setNonNullParameter(PreparedStatement ps, int i, LocalDateTime localDateTime, JdbcType jdbcType) throws SQLException {
ps.setObject(i, localDateTime);
}
@Override
public LocalDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
return rs.getObject(columnName, LocalDateTime.class);
}
@Override
public LocalDateTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return rs.getObject(columnIndex, LocalDateTime.class);
}
@Override
public LocalDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return cs.getObject(columnIndex, LocalDateTime.class);
}
}

View File

@ -0,0 +1,51 @@
package com.isu.gaswellwatch.utils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author <a href="mailto:scwsl@foxmail.com">王仕龙</a>
* 2024/1/26 16:04
*/
public class StringToLocalDateTimeConverter extends JsonDeserializer<LocalDateTime> implements Converter<String, LocalDateTime> {
public static final StringToLocalDateTimeConverter INSTANCE = new StringToLocalDateTimeConverter();
public static final DateTimeFormatter ZH_CN_LOCAL_DATE_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Override
public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException {
return convert(jsonParser.getText());
}
@Override
public LocalDateTime convert(String source) {
if (StringUtils.isBlank(source)) {
return null;
}
LocalDateTime localDateTime = null;
if (source.length() == 10) {
localDateTime = LocalDate.parse(source).atStartOfDay();
} else {
if (source.contains("T")) {
localDateTime = LocalDateTime.parse(source, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
} else {
localDateTime = LocalDateTime.parse(source, ZH_CN_LOCAL_DATE_TIME);
}
}
return localDateTime;
}
@Override
public Class<LocalDateTime> handledType() {
return LocalDateTime.class;
}
}

View File

@ -0,0 +1,36 @@
package com.isu.gaswellwatch.vo;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.io.Serial;
/**
* 区块对象 blocks
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class BlockPageQuery extends PageQuery {
@Serial
private static final long serialVersionUID = 1L;
/** 上级标识 */
private Long parentId;
/** 名称 */
private String name;
/** 是否已删除 */
private Integer deleted;
}

View File

@ -0,0 +1,58 @@
package com.isu.gaswellwatch.vo;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 区块页面返回对象 blocks
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@EqualsAndHashCode
@ToString(callSuper = true)
public class BlockVO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 上级标识 */
private Long parentId;
/** 名称 */
private String name;
/** 描述 */
private String details;
/** 是否已删除 */
private Integer deleted;
/** 创建人 */
private Long createBy;
/** 创建时间 */
private LocalDateTime createTime;
/** 更新人 */
private Long updateBy;
/** 更新时间 */
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,33 @@
package com.isu.gaswellwatch.vo;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.io.Serial;
/**
* 气井对象 gas_wells
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class GasWellPageQuery extends PageQuery {
@Serial
private static final long serialVersionUID = 1L;
/** 关联公司 */
private Long companyId;
/** 气井名称 */
private String name;
}

View File

@ -0,0 +1,55 @@
package com.isu.gaswellwatch.vo;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 气井页面返回对象 gas_wells
*
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@EqualsAndHashCode
@ToString(callSuper = true)
public class GasWellVO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 关联公司 */
private Long companyId;
/** 气井名称 */
private String name;
/** 描述 */
private String details;
/** 创建人 */
private Long createBy;
/** 创建时间 */
private LocalDateTime createTime;
/** 更新人 */
private Long updateBy;
/** 更新时间 */
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,21 @@
package com.isu.gaswellwatch.vo;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
/**
* @author <a href="mailto:shilong.wang@alpha-ess.com">王仕龙</a>
* 2024/11/15 21:07
*/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public class PageQuery implements Serializable {
private Integer currentPage;
private Integer pageSize;
}

View File

@ -3,5 +3,5 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://127.0.0.1:3306/gaswellwatch?characterEncoding=UTF-8&useUnicode=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: QINjie5111.com
password: 1qaz@WSX
driver-class-name: com.mysql.cj.jdbc.Driver

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.isu.gaswellwatch.dao.BlockDao">
<resultMap type="com.isu.gaswellwatch.vo.BlockVO" id="BlockVO">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="name" column="name" />
<result property="details" column="details" />
<result property="deleted" column="deleted" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
</resultMap>
<resultMap type="com.isu.gaswellwatch.entity.Block" id="BlockResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="name" column="name" />
<result property="details" column="details" />
<result property="deleted" column="deleted" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
</resultMap>
<sql id="selectBlockVo">
select t1.id, t1.parent_id, t1.name, t1.details, t1.deleted, t1.create_by, t1.create_time, t1.update_by, t1.update_time from blocks t1
</sql>
<select id="pageForQuery" resultMap="BlockVO">
<include refid="selectBlockVo"/>
<where>
<if test="query.parentId != null "> and t1.parent_id = #{parentId}</if>
<if test="query.name != null and query.name != ''"> and t1.name like concat('%', #{query.name}, '%')</if>
<if test="query.deleted != null "> and t1.deleted = #{deleted}</if>
</where>
order by t1.id desc
</select>
<select id="selectBlockList" resultMap="BlockResult">
<include refid="selectBlockVo"/>
<where>
<if test="parentId != null "> and t1.parent_id = #{parentId}</if>
<if test="name != null and name != ''"> and t1.name like concat('%', #{name}, '%')</if>
<if test="deleted != null "> and t1.deleted = #{deleted}</if>
</where>
</select>
<select id="selectBlockById" parameterType="Long" resultMap="BlockResult">
<include refid="selectBlockVo"/>
where t1.id = #{id}
</select>
<insert id="insertBlock" useGeneratedKeys="true" keyProperty="id">
insert into blocks
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="details != null">details,</if>
<if test="deleted != null">deleted,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="details != null">#{details},</if>
<if test="deleted != null">#{deleted},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateBlock">
update blocks
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="details != null">details = #{details},</if>
<if test="deleted != null">deleted = #{deleted},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBlockById" parameterType="Long">
delete from blocks where id = #{id}
</delete>
<delete id="deleteBlockByIds">
delete from blocks where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.isu.gaswellwatch.dao.GasWellDao">
<resultMap type="com.isu.gaswellwatch.vo.GasWellVO" id="GasWellVO">
<result property="id" column="id" />
<result property="companyId" column="company_id" />
<result property="name" column="name" />
<result property="details" column="details" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
</resultMap>
<resultMap type="com.isu.gaswellwatch.entity.GasWell" id="GasWellResult">
<result property="id" column="id" />
<result property="companyId" column="company_id" />
<result property="name" column="name" />
<result property="details" column="details" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" jdbcType="DATE" typeHandler="com.isu.gaswellwatch.utils.LocalDateTimeTypeHandler" />
</resultMap>
<sql id="selectGasWellVo">
select t1.id, t1.company_id, t1.name, t1.details, t1.create_by, t1.create_time, t1.update_by, t1.update_time from gas_wells t1
</sql>
<select id="pageForQuery" resultMap="GasWellVO">
<include refid="selectGasWellVo"/>
<where>
<if test="query.companyId != null "> and t1.company_id = #{companyId}</if>
<if test="query.name != null and query.name != ''"> and t1.name like concat('%', #{query.name}, '%')</if>
</where>
order by t1.id desc
</select>
<select id="selectGasWellList" resultMap="GasWellResult">
<include refid="selectGasWellVo"/>
<where>
<if test="companyId != null "> and t1.company_id = #{companyId}</if>
<if test="name != null and name != ''"> and t1.name like concat('%', #{name}, '%')</if>
</where>
</select>
<select id="selectGasWellById" parameterType="Long" resultMap="GasWellResult">
<include refid="selectGasWellVo"/>
where t1.id = #{id}
</select>
<insert id="insertGasWell" useGeneratedKeys="true" keyProperty="id">
insert into gas_wells
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyId != null">company_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="details != null">details,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyId != null">#{companyId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="details != null">#{details},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateGasWell">
update gas_wells
<trim prefix="SET" suffixOverrides=",">
<if test="companyId != null">company_id = #{companyId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="details != null">details = #{details},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteGasWellById" parameterType="Long">
delete from gas_wells where id = #{id}
</delete>
<delete id="deleteGasWellByIds">
delete from gas_wells where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>