Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
wangshilong 2024-11-24 12:04:55 +08:00
commit bde580678a
19 changed files with 303 additions and 185 deletions

View File

@ -43,23 +43,25 @@ public class BlockController {
/**
* 查询区块列表
*/
@GetMapping
public Response<Page<BlockVO>> page(BlockPageQuery query) {
return Response.succeed(blockService.pageForQuery(query));
@GetMapping(value = "/page")
public Response<Page<BlockVO>> page(@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false) String name) {
return Response.succeed(blockService.pageForQuery(currentPage, pageSize, name));
}
/**
* 获取区块详细信息
*/
@GetMapping(value = "/{id}")
public Response<BlockVO> getInfo(@PathVariable("id") Long id) {
@GetMapping(value = "/getBlock")
public Response<BlockVO> getInfo(@RequestParam Long id) {
return Response.succeed(blockService.selectBlockById(id));
}
/**
* 新增区块
*/
@PostMapping
@PostMapping(value = "/add")
@OperationLog(description = "新增区块", type = LogType.ADD)
public Response<String> add(@RequestBody @Valid BlockCreateRequest blockCreateRequest) {
blockService.insertBlock(blockCreateRequest);
@ -69,7 +71,7 @@ public class BlockController {
/**
* 修改区块
*/
@PutMapping
@PostMapping(value = "/edit")
@OperationLog(description = "修改区块", type = LogType.UPDATE)
public Response<String> edit(@RequestBody BlockEditRequest blockEditRequest) {
blockService.updateBlock(blockEditRequest);
@ -79,11 +81,19 @@ public class BlockController {
/**
* 删除区块
*/
@DeleteMapping("/{ids}")
@GetMapping("/delete")
@OperationLog(description = "删除区块", type = LogType.DELETE)
public Response<String> delete(@PathVariable Collection<Long> ids) {
blockService.deleteBlockByIds(ids);
public Response<String> delete(@RequestParam Long id) {
blockService.deleteBlockById(id);
return Response.succeed();
}
/**
* 查询区块列表
*/
@GetMapping("/list")
public Response<List<BlockVO>> list() {
return Response.succeed(blockService.selectBlockList());
}
}

View File

@ -4,11 +4,9 @@ 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;
/**
@ -31,18 +29,17 @@ public interface BlockDao extends BaseMapper<Block> {
/**
* 查询区块列表
*
* @param block 区块
* @return 区块集合
*/
List<Block> selectBlockList(Block block);
List<BlockVO> selectBlockList(Long departmentId);
/**
* 分页查询区块列表
*
* @param query 查询条件
* @param page 分页信息
* @param name 区块名称
* @return 区块
*/
Page<BlockVO> pageForQuery(Page<BlockVO> page, @Param("query") BlockPageQuery query);
Page<BlockVO> pageForQuery(Page<BlockVO> page, String name);
/**
* 新增区块

View File

@ -0,0 +1,13 @@
package com.isu.gaswellwatch.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isu.gaswellwatch.entity.BlockDepartment;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface BlockDepartmentDao extends BaseMapper<BlockDepartment> {
}

View File

@ -1,5 +1,6 @@
package com.isu.gaswellwatch.dto;
import jakarta.validation.constraints.NotBlank;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -28,14 +29,18 @@ public class BlockCreateRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** 上级标识 */
private Long parentId;
/** id */
private Long id;
@NotBlank(message = "名称不能为空!")
/** 名称 */
private String name;
/** 描述 */
private String details;
/** 部门id */
private Long departmentId;
}

View File

@ -1,5 +1,7 @@
package com.isu.gaswellwatch.dto;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -29,15 +31,17 @@ public class BlockEditRequest implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键 */
@NotNull(message = "ID不能为空")
private Long id;
/** 上级标识 */
private Long parentId;
/** 名称 */
@NotBlank(message = "名称不能为空!")
private String name;
/** 描述 */
private String details;
/** 部门id */
private Long departmentId;
}

View File

@ -1,10 +1,7 @@
package com.isu.gaswellwatch.entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import com.isu.gaswellwatch.vo.DepartmentVO;
import lombok.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
@ -14,11 +11,10 @@ import java.time.LocalDateTime;
* @author scwsl
* @date 2024-11-17
*/
@Getter
@Setter
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class Block extends Model<Block> {
private static final long serialVersionUID = 1L;
@ -26,29 +22,20 @@ public class Block extends Model<Block> {
/** 主键 */
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 String createTime;
/** 更新时间 */
private LocalDateTime updateTime;
private String updateTime;
/** 关联部门 */
private DepartmentVO department;
}

View File

@ -0,0 +1,32 @@
package com.isu.gaswellwatch.entity;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BlockDepartment extends Model<BlockDepartment> {
private Long id;
//区块id
private Long blockId;
//角色id
private Long departmentId;
//创建时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
//更新时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}

View File

@ -36,26 +36,9 @@ public interface BlockMapper {
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());
}
Block block =Block.builder().build();
create(request, block);
return block;
}

View File

@ -0,0 +1,10 @@
package com.isu.gaswellwatch.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.isu.gaswellwatch.entity.BlockDepartment;
public interface BlockDepartmentService extends IService<BlockDepartment> {
}

View File

@ -29,18 +29,16 @@ public interface BlockService extends IService<Block> {
/**
* 查询区块列表
*
* @param block 区块
* @return 区块集合
*/
List<BlockVO> selectBlockList(Block block);
List<BlockVO> selectBlockList();
/**
* 分页查询区块列表
*
* @param query 查询条件
* @return 区块
*/
Page<BlockVO> pageForQuery(BlockPageQuery query);
Page<BlockVO> pageForQuery(Integer currentPage,Integer pageSize,String name);
/**
* 新增区块
@ -48,7 +46,7 @@ public interface BlockService extends IService<Block> {
* @param blockCreateRequest 区块
* @return 结果
*/
int insertBlock(BlockCreateRequest blockCreateRequest);
void insertBlock(BlockCreateRequest blockCreateRequest);
/**
* 修改区块
@ -56,7 +54,7 @@ public interface BlockService extends IService<Block> {
* @param blockEditRequest 区块
* @return 结果
*/
int updateBlock(BlockEditRequest blockEditRequest);
void updateBlock(BlockEditRequest blockEditRequest);
/**
* 删除区块信息
@ -64,7 +62,7 @@ public interface BlockService extends IService<Block> {
* @param id 区块主键
* @return 结果
*/
int deleteBlockById(Long id);
void deleteBlockById(Long id);
/**
* 批量删除区块

View File

@ -30,4 +30,6 @@ public interface UserService extends IService<User> {
void export(HttpServletResponse response, String username, String name, Long roleId, String isEnable);
void setEnable(Long userId, String isEnable);
List<MenuVO> getMenuList(String username);
UserVO selectUserInfo(String usernamee);
}

View File

@ -0,0 +1,15 @@
package com.isu.gaswellwatch.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isu.gaswellwatch.dao.BlockDepartmentDao;
import com.isu.gaswellwatch.entity.BlockDepartment;
import com.isu.gaswellwatch.service.BlockDepartmentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service("blockDepartmentService")
@Transactional(rollbackFor = Exception.class)
public class BlockDepartmentServiceImpl extends ServiceImpl<BlockDepartmentDao, BlockDepartment> implements BlockDepartmentService {
}

View File

@ -1,7 +1,20 @@
package com.isu.gaswellwatch.service.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.isu.gaswellwatch.config.SnowflakeConfig;
import com.isu.gaswellwatch.constants.UserConstant;
import com.isu.gaswellwatch.entity.*;
import com.isu.gaswellwatch.service.BlockDepartmentService;
import com.isu.gaswellwatch.service.UserService;
import com.isu.gaswellwatch.utils.ConverterUtil;
import com.isu.gaswellwatch.vo.UserLoginInfoVO;
import com.isu.gaswellwatch.vo.UserVO;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -11,7 +24,6 @@ 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;
@ -30,6 +42,12 @@ public class BlockServiceImpl extends ServiceImpl<BlockDao, Block> implements B
private final BlockDao blockDao;
private final BlockMapper blockMapper = Mappers.getMapper(BlockMapper.class);
@Resource
private BlockDepartmentService blockDepartmentService;
@Resource
private UserService userService;
@Resource
private SnowflakeConfig snowflakeConfig;
/**
* 查询区块
@ -39,29 +57,41 @@ public class BlockServiceImpl extends ServiceImpl<BlockDao, Block> implements B
*/
@Override
public BlockVO selectBlockById(Long id) {
return blockMapper.toPageVO(blockDao.selectBlockById(id));
return ConverterUtil.convert(blockDao.selectBlockById(id),BlockVO.class);
}
/**
* 查询区块列表
*
* @param block 区块
* @return 区块
*/
@Override
public List<BlockVO> selectBlockList(Block block) {
return blockMapper.toPageVO(blockDao.selectBlockList(block));
public List<BlockVO> selectBlockList() {
//根据当前用户所属的部门筛选可以看到的区块
UserLoginInfoVO userLoginInfoVO = (UserLoginInfoVO) StpUtil.getTokenSession().get(UserConstant.TOKEN_SESSION);
UserVO userVO = userService.selectUserInfo(userLoginInfoVO.getUserVO().getUsername());
if("admin".equals(userVO.getUsername())){
//对admin用户不进行过滤筛选
return blockDao.selectBlockList(null);
}else{
if(userVO.getDepartment()!=null){
return blockDao.selectBlockList(userVO.getDepartment().getId());
}else{
return new ArrayList<>();
}
}
}
/**
* 分页查询区块列表
*
* @param query 查询条件
* @param name 区块名称
* @return 区块
*/
@Override
public Page<BlockVO> pageForQuery(BlockPageQuery query){
return blockDao.pageForQuery(new Page<>(query.getCurrentPage(), query.getPageSize()), query);
public Page<BlockVO> pageForQuery(Integer currentPage,Integer pageSize,String name){
return blockDao.pageForQuery(new Page<>(currentPage, pageSize), name);
}
/**
@ -72,8 +102,20 @@ public class BlockServiceImpl extends ServiceImpl<BlockDao, Block> implements B
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int insertBlock(BlockCreateRequest blockCreateRequest) {
return blockDao.insertBlock(blockMapper.create(blockCreateRequest));
public void insertBlock(BlockCreateRequest blockCreateRequest) {
blockCreateRequest.setId(snowflakeConfig.snowflakeId());
blockDao.insertBlock(blockMapper.create(blockCreateRequest));
//增加区块部门关联
if(blockCreateRequest.getDepartmentId()!=null){
blockDepartmentService.remove(new LambdaQueryWrapper<BlockDepartment>().eq(BlockDepartment::getBlockId, blockCreateRequest.getId()));
addDepartment(blockCreateRequest.getDepartmentId(), blockCreateRequest.getId());
}
}
private void addDepartment(Long departmentId, Long blockId) {
BlockDepartment.builder().id(snowflakeConfig.snowflakeId()).blockId(blockId).departmentId(departmentId).build().insert();
}
/**
@ -84,10 +126,14 @@ public class BlockServiceImpl extends ServiceImpl<BlockDao, Block> implements B
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int updateBlock(BlockEditRequest blockEditRequest) {
Block block = blockDao.selectBlockById(blockEditRequest.getId());
blockMapper.copyToEntity(blockEditRequest, block);
return blockDao.updateBlock(block);
public void updateBlock(BlockEditRequest blockEditRequest) {
updateById(Block.builder().id(blockEditRequest.getId()).name(blockEditRequest.getName()).details(blockEditRequest.getDetails()).build());
//增加区块部门关联
if(blockEditRequest.getDepartmentId()!=null){
blockDepartmentService.remove(new LambdaQueryWrapper<BlockDepartment>().eq(BlockDepartment::getBlockId, blockEditRequest.getId()));
addDepartment(blockEditRequest.getDepartmentId(), blockEditRequest.getId());
}
}
/**
@ -98,8 +144,11 @@ public class BlockServiceImpl extends ServiceImpl<BlockDao, Block> implements B
*/
@Override
@Transactional(rollbackFor = Throwable.class)
public int deleteBlockById(Long id) {
return blockDao.deleteBlockById(id);
public void deleteBlockById(Long id) {
//TODO 校验区块是否被气井关联
blockDao.deleteBlockById(id);
blockDepartmentService.remove(new LambdaQueryWrapper<BlockDepartment>().eq(BlockDepartment::getBlockId, id));
}
/**

View File

@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isu.gaswellwatch.config.SnowflakeConfig;
import com.isu.gaswellwatch.entity.BlockDepartment;
import com.isu.gaswellwatch.service.BlockDepartmentService;
import com.isu.gaswellwatch.service.DepartmentService;
import com.isu.gaswellwatch.dao.DepartmentDao;
import com.isu.gaswellwatch.dto.*;
@ -28,6 +30,9 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentDao, Department
@Resource
private DepartmentDao companyDao;
@Resource
private BlockDepartmentService blockDepartmentService;
@Override
public Page<DepartmentVO> page(Integer currentPage, Integer pageSize, String name, String code){
Page<DepartmentVO> page = companyDao.page(new Page<>(currentPage, pageSize),name,code);
@ -56,10 +61,13 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentDao, Department
@Override
public void delete(Long id){
//TODO 如果部门绑定了气井 不能删除
//删除
removeById(id);
//如果部门绑定了区块 不能删除
BlockDepartment blockDepartment = blockDepartmentService.getOne(new LambdaQueryWrapper<BlockDepartment>().eq(BlockDepartment::getDepartmentId, id));
if(blockDepartment != null){
throw new BusinessException("该部门已被区块绑定,不能删除");
}else {
removeById(id);
}
}

View File

@ -38,7 +38,6 @@ import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
@Service("userService")
@ -265,6 +264,11 @@ public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserS
return new ArrayList<>();
}
@Override
public UserVO selectUserInfo(String username){
return userDao.selectUserInfo(username);
}
private UserLoginInfoVO buildTokenSession(String username){
UserLoginInfoVO userInfoVO = new UserLoginInfoVO();
UserVO userVO = userDao.selectUserInfo(username);

View File

@ -24,13 +24,7 @@ public class BlockPageQuery extends PageQuery {
@Serial
private static final long serialVersionUID = 1L;
/** 上级标识 */
private Long parentId;
/** 名称 */
private String name;
/** 是否已删除 */
private Integer deleted;
}

View File

@ -9,7 +9,6 @@ import lombok.experimental.SuperBuilder;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 区块页面返回对象 blocks
@ -31,28 +30,18 @@ public class BlockVO implements Serializable {
/** 主键 */
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 String createTime;
/** 更新时间 */
private LocalDateTime updateTime;
private String updateTime;
/** 关联部门 */
private DepartmentVO department;
}

View File

@ -11,33 +11,56 @@
Target Server Version : 80034
File Encoding : 65001
Date: 22/11/2024 17:54:19
Date: 23/11/2024 18:48:09
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for blocks
-- Table structure for block
-- ----------------------------
DROP TABLE IF EXISTS `blocks`;
CREATE TABLE `blocks` (
`id` bigint NOT NULL COMMENT '主键',
`parent_id` bigint NOT NULL COMMENT '上级标识',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '名称',
`details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已删除',
`create_by` bigint NOT NULL COMMENT '创建人',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` bigint NOT NULL COMMENT '更新人',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
DROP TABLE IF EXISTS `block`;
CREATE TABLE `block` (
`id` bigint NOT NULL COMMENT '主键',
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '名称',
`details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='区块管理';
-- ----------------------------
-- Records of blocks
-- Records of block
-- ----------------------------
BEGIN;
INSERT INTO `block` (`id`, `name`, `details`, `create_time`, `update_time`) VALUES (1860217436825976832, '桃7', '测试用', '2024-11-23 15:02:52', '2024-11-23 15:02:52');
INSERT INTO `block` (`id`, `name`, `details`, `create_time`, `update_time`) VALUES (1860217990331498496, '苏5', '测试用', '2024-11-23 15:05:04', '2024-11-23 15:05:04');
INSERT INTO `block` (`id`, `name`, `details`, `create_time`, `update_time`) VALUES (1860218019209281536, '苏46', '测试用', '2024-11-23 15:05:11', '2024-11-23 15:05:11');
INSERT INTO `block` (`id`, `name`, `details`, `create_time`, `update_time`) VALUES (1860233760696434688, '苏59', '测试用', '2024-11-23 16:07:44', '2024-11-23 16:07:44');
COMMIT;
-- ----------------------------
-- Table structure for block_department
-- ----------------------------
DROP TABLE IF EXISTS `block_department`;
CREATE TABLE `block_department` (
`id` bigint NOT NULL COMMENT '主键',
`block_id` bigint NOT NULL,
`department_id` bigint NOT NULL,
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='区块部门关联表';
-- ----------------------------
-- Records of block_department
-- ----------------------------
BEGIN;
INSERT INTO `block_department` (`id`, `block_id`, `department_id`, `create_time`, `update_time`) VALUES (1860217436872114176, 1860217436825976832, 1, '2024-11-23 15:02:52', '2024-11-23 15:02:52');
INSERT INTO `block_department` (`id`, `block_id`, `department_id`, `create_time`, `update_time`) VALUES (1860217990339887104, 1860217990331498496, 1, '2024-11-23 15:05:04', '2024-11-23 15:05:04');
INSERT INTO `block_department` (`id`, `block_id`, `department_id`, `create_time`, `update_time`) VALUES (1860218019217670144, 1860218019209281536, 1, '2024-11-23 15:05:11', '2024-11-23 15:05:11');
INSERT INTO `block_department` (`id`, `block_id`, `department_id`, `create_time`, `update_time`) VALUES (1860233760709017600, 1860233760696434688, 2, '2024-11-23 16:07:44', '2024-11-23 16:07:44');
COMMIT;
-- ----------------------------
@ -172,7 +195,7 @@ CREATE TABLE `dictionary` (
PRIMARY KEY (`id`),
KEY `type_index` (`type`) USING BTREE,
KEY `type_code_index` (`type`,`code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='字典表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统字典表';
-- ----------------------------
-- Records of dictionary
@ -220,7 +243,7 @@ CREATE TABLE `menu` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='菜单管理';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='菜单管理';
-- ----------------------------
-- Records of menu
@ -247,7 +270,7 @@ CREATE TABLE `role` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='角色管理';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色管理';
-- ----------------------------
-- Records of role
@ -274,7 +297,7 @@ CREATE TABLE `role_menu` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='角色菜单关联表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色菜单关联表';
-- ----------------------------
-- Records of role_menu
@ -288,11 +311,14 @@ INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859271166338793472, 1854121363019661312, 1834500987037941760, NULL, '2024-11-21 00:22:44', '2024-11-21 00:22:44');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859271166338793473, 1854121363019661312, 1834501029547212800, NULL, '2024-11-21 00:22:44', '2024-11-21 00:22:44');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859271166338793474, 1854121363019661312, 1834501061923045376, NULL, '2024-11-21 00:22:44', '2024-11-21 00:22:44');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859898030757511168, 1, 1834501029547212800, NULL, '2024-11-22 17:53:40', '2024-11-22 17:53:40');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859898030757511169, 1, 1834500987037941760, NULL, '2024-11-22 17:53:40', '2024-11-22 17:53:40');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859898030757511170, 1, 1834501061923045376, NULL, '2024-11-22 17:53:40', '2024-11-22 17:53:40');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859898030757511171, 1, 1834501151140085760, NULL, '2024-11-22 17:53:40', '2024-11-22 17:53:40');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859898030757511172, 1, 1834500910013743104, NULL, '2024-11-22 17:53:40', '2024-11-22 17:53:40');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543232, 1, 1834501029547212800, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543233, 1, 1834499936926826496, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543234, 1, 1834500987037941760, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543235, 1, 1834501061923045376, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543236, 1, 1834501151140085760, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543237, 1, 1834500910013743104, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543238, 1, 1834501113332629504, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
INSERT INTO `role_menu` (`id`, `role_id`, `menu_id`, `identifier`, `create_time`, `update_time`) VALUES (1859942446616543239, 1, 1834501183620775936, NULL, '2024-11-22 20:50:09', '2024-11-22 20:50:09');
COMMIT;
-- ----------------------------
@ -310,7 +336,7 @@ CREATE TABLE `user` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户表';
-- ----------------------------
-- Records of user
@ -319,7 +345,7 @@ BEGIN;
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `phone`, `picture`, `is_enable`, `create_time`, `update_time`) VALUES (1, 'admin', '7c4a8d09ca3762af61e59520943dc26494f8941b', 'admin', '13028138200', NULL, '1', '2024-08-30 10:17:10', '2024-10-25 10:14:24');
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `phone`, `picture`, `is_enable`, `create_time`, `update_time`) VALUES (1850801224132067328, 'test1', '7c4a8d09ca3762af61e59520943dc26494f8941b', '张四', '13012341234', NULL, '1', '2024-10-28 15:26:12', '2024-10-28 15:56:52');
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `phone`, `picture`, `is_enable`, `create_time`, `update_time`) VALUES (1850812935484473344, 'test2', '7c4a8d09ca3762af61e59520943dc26494f8941b', '王五', '13012341235', NULL, '1', '2024-10-28 16:12:44', '2024-10-28 16:12:44');
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `phone`, `picture`, `is_enable`, `create_time`, `update_time`) VALUES (1853726975508611072, '123d', '7c4a8d09ca3762af61e59520943dc26494f8941b', '123dd', '13333333331', NULL, '0', '2024-11-05 17:12:06', '2024-11-06 15:04:57');
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `phone`, `picture`, `is_enable`, `create_time`, `update_time`) VALUES (1853726975508611072, '123d', '7c4a8d09ca3762af61e59520943dc26494f8941b', '123dd', '13333333331', NULL, '1', '2024-11-05 17:12:06', '2024-11-23 18:39:45');
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `phone`, `picture`, `is_enable`, `create_time`, `update_time`) VALUES (1859282476250169344, '123dd', '7c4a8d09ca3762af61e59520943dc26494f8941b', '安定', '13333333333', NULL, '1', '2024-11-21 01:07:40', '2024-11-21 01:07:40');
INSERT INTO `user` (`id`, `username`, `password`, `nickname`, `phone`, `picture`, `is_enable`, `create_time`, `update_time`) VALUES (1859283318915203072, 'dfg2', '7c4a8d09ca3762af61e59520943dc26494f8941b', '213安定', '13999999999', NULL, '1', '2024-11-21 01:11:01', '2024-11-21 01:11:01');
COMMIT;
@ -335,7 +361,7 @@ CREATE TABLE `user_department` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='用户部门关联表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户部门关联表';
-- ----------------------------
-- Records of user_department
@ -367,7 +393,7 @@ CREATE TABLE `user_operation_record` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户操作记录表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户操作记录表';
-- ----------------------------
-- Records of user_operation_record
@ -386,7 +412,7 @@ CREATE TABLE `user_role` (
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户角色关联表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户角色关联表';
-- ----------------------------
-- Records of user_role

View File

@ -6,103 +6,95 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<association property="department" javaType="com.isu.gaswellwatch.vo.DepartmentVO" select="getBlockDepartment" column="{block_id=id}">
</association>
</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" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<association property="department" javaType="com.isu.gaswellwatch.vo.DepartmentVO" >
<id column="departmentId" property="id"/>
<result column="departmentName" property="name"/>
<result column="departmentDescription" property="description"/>
<result column="departmentCode" property="code"/>
</association>
</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
select t1.id, t1.`name`, t1.details, t1.create_time, t1.update_time from block 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>
<if test="name != null and name != ''"> and t1.name like concat('%', #{name}, '%')</if>
</where>
order by t1.id desc
</select>
<select id="selectBlockList" resultMap="BlockResult">
<select id="selectBlockList" resultMap="BlockVO" parameterType="Long">
<include refid="selectBlockVo"/>
left join block_department bd on t1.id = bd.block_id
<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>
<if test="departmentId != null and departmentId != ''"> bd.department_id = #{departmentId}</if>
</where>
</select>
<select id="selectBlockById" parameterType="Long" resultMap="BlockResult">
<include refid="selectBlockVo"/>
select t1.id, t1.`name`, t1.details, t1.create_time, t1.update_time,
d.id as departmentId, d.name as departmentName, d.description as departmentDescription,d.code as departmentCode from block t1
left join block_department bd on t1.id = bd.block_id
left join department d on bd.department_id = d.id
where t1.id = #{id}
</select>
<insert id="insertBlock" useGeneratedKeys="true" keyProperty="id">
insert into blocks
insert into block
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="id != null">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="id != null">#{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">#{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
update block
<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 from block where id = #{id}
</delete>
<delete id="deleteBlockByIds">
delete from blocks where id in
delete from block where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getBlockDepartment" resultType="com.isu.gaswellwatch.vo.DepartmentVO">
SELECT d.id, d.name, d.description
FROM department d
LEFT JOIN block_department bd ON bd.department_id=d.id
where bd.block_id=#{block_id}
</select>
</mapper>