feat:人员车辆管理
This commit is contained in:
1 parent
2658786bd1
commit
9eaa9998c3
8 files changed
+367
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.admin.api.dto.car;
|
||||
|
||||
import com.bsd.pjcloud.admin.api.entity.car.SysUserCarEntity;
|
||||
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysUserCarDto extends SysUserCarEntity implements BaseUserInterface {
|
||||
|
||||
/**
|
||||
* 用户相关
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
private String username;
|
||||
|
||||
private String userMobile;
|
||||
|
||||
private String userAvatar;
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.bsd.pjcloud.admin.api.entity.car;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 车辆管理
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("sys_user_car")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "车辆管理")
|
||||
public class SysUserCarEntity extends Model<SysUserCarEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "编号")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
@Schema(description = "车牌号")
|
||||
private String carNumber;
|
||||
|
||||
/**
|
||||
* 车辆类型(字典)
|
||||
*/
|
||||
@Schema(description = "车辆类型(字典)")
|
||||
private String carType;
|
||||
|
||||
/**
|
||||
* 启用状态(字典)
|
||||
*/
|
||||
@Schema(description = "启用状态(字典)")
|
||||
private String enableStatus;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.bsd.pjcloud.admin.api.vo.car;
|
||||
|
||||
import com.bsd.pjcloud.admin.api.entity.car.SysUserCarEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysUserCarVo extends SysUserCarEntity {
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package com.bsd.pjcloud.admin.controller.car;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.dto.car.SysUserCarDto;
|
||||
import com.bsd.pjcloud.admin.api.entity.car.SysUserCarEntity;
|
||||
import com.bsd.pjcloud.admin.api.vo.car.SysUserCarVo;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.admin.service.SysUserCarService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 车辆管理
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/sysUserCar")
|
||||
@Tag(description = "sysUserCar", name = "车辆管理管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SysUserCarController {
|
||||
|
||||
private final SysUserCarService sysUserCarService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysUserCar_view')")
|
||||
public R<Page<SysUserCarVo>> getSysUserCarPage(@ParameterObject Page page, @ParameterObject SysUserCarDto dto) {
|
||||
return R.ok(sysUserCarService.scopePageJoin(page, dto, DataScope.of()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询车辆管理
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysUserCar_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(sysUserCarService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车辆管理
|
||||
*/
|
||||
@Operation(summary = "新增车辆管理", description = "新增车辆管理")
|
||||
@SysLog("新增车辆管理")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysUserCar_add')")
|
||||
public R save(@RequestBody SysUserCarDto sysUserCar) {
|
||||
return R.ok(sysUserCarService.create(sysUserCar));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车辆管理
|
||||
*/
|
||||
@Operation(summary = "修改车辆管理", description = "修改车辆管理")
|
||||
@SysLog("修改车辆管理")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysUserCar_edit')")
|
||||
public R updateById(@RequestBody SysUserCarDto sysUserCar) {
|
||||
sysUserCarService.edit(sysUserCar);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除车辆管理
|
||||
*/
|
||||
@Operation(summary = "通过id删除车辆管理", description = "通过id删除车辆管理")
|
||||
@SysLog("通过id删除车辆管理")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysUserCar_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(sysUserCarService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('admin_sysUserCar_export')")
|
||||
public List<SysUserCarEntity> export(SysUserCarEntity sysUserCar, Long[] ids) {
|
||||
return sysUserCarService.list(Wrappers.lambdaQuery(sysUserCar).in(ArrayUtil.isNotEmpty(ids), SysUserCarEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.bsd.pjcloud.admin.mapper.car;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.admin.api.dto.car.SysUserCarDto;
|
||||
import com.bsd.pjcloud.admin.api.entity.car.SysUserCarEntity;
|
||||
import com.bsd.pjcloud.admin.api.vo.car.SysUserCarVo;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface SysUserCarMapper extends PjcloudBaseMapper<SysUserCarEntity> {
|
||||
|
||||
Page<SysUserCarVo> scopePageJoin(Page page, @Param("dto") SysUserCarDto dto, DataScope dataScope);
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.bsd.pjcloud.admin.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.admin.api.dto.car.SysUserCarDto;
|
||||
import com.bsd.pjcloud.admin.api.entity.car.SysUserCarEntity;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
|
||||
public interface SysUserCarService extends IService<SysUserCarEntity> {
|
||||
|
||||
Page scopePageJoin(Page page, SysUserCarDto dto, DataScope dataScope);
|
||||
|
||||
Long create(SysUserCarDto sysUserCar);
|
||||
|
||||
void edit(SysUserCarDto sysUserCar);
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package com.bsd.pjcloud.admin.service.impl.car;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.bsd.pjcloud.admin.api.dto.car.SysUserCarDto;
|
||||
import com.bsd.pjcloud.admin.api.entity.car.SysUserCarEntity;
|
||||
import com.bsd.pjcloud.admin.api.vo.car.SysUserCarVo;
|
||||
import com.bsd.pjcloud.admin.mapper.car.SysUserCarMapper;
|
||||
import com.bsd.pjcloud.admin.service.SysUserCarService;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 车辆管理
|
||||
*/
|
||||
@Service
|
||||
public class SysUserCarServiceImpl extends ServiceImpl<SysUserCarMapper, SysUserCarEntity> implements SysUserCarService {
|
||||
|
||||
@Override
|
||||
public Page<SysUserCarVo> scopePageJoin(Page page, SysUserCarDto dto, DataScope dataScope) {
|
||||
return baseMapper.scopePageJoin(page, dto, dataScope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long create(SysUserCarDto sysUserCar) {
|
||||
if (existName(sysUserCar)) {
|
||||
throw new RuntimeException("车牌号不能重复");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(sysUserCar.getEnableStatus())) {
|
||||
sysUserCar.setEnableStatus(YesNoEnum.YES.getCode());
|
||||
}
|
||||
baseMapper.insert(sysUserCar);
|
||||
return sysUserCar.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysUserCarDto sysUserCar) {
|
||||
if (existName(sysUserCar)) {
|
||||
throw new RuntimeException("车牌号不能重复");
|
||||
}
|
||||
baseMapper.updateById(sysUserCar);
|
||||
}
|
||||
|
||||
// 判断车牌号是否重复
|
||||
private boolean existName(SysUserCarEntity dto) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<SysUserCarEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getCarNumber()), SysUserCarEntity::getCarNumber, dto.getCarNumber())
|
||||
.ne(ObjectUtil.isNotEmpty(dto.getId()), SysUserCarEntity::getId, dto.getId())
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dto.getId())) {
|
||||
return count >= 1;
|
||||
}
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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.bsd.pjcloud.admin.mapper.car.SysUserCarMapper">
|
||||
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.user_id,
|
||||
a.car_number,
|
||||
a.car_type,
|
||||
a.enable_status,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_time,
|
||||
a.del_flag,
|
||||
a.tenant_id
|
||||
</sql>
|
||||
|
||||
<sql id="whereA">
|
||||
a.del_flag = '0'
|
||||
<if test="dto.userId != null">
|
||||
and a.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.carNumber != null">
|
||||
and a.car_number LIKE CONCAT('%',#{dto.carNumber},'%')
|
||||
</if>
|
||||
<if test="dto.carType != null and dto.carType != '' ">
|
||||
and a.car_type = #{dto.carType}
|
||||
</if>
|
||||
<if test="dto.enableStatus != null and dto.enableStatus != '' ">
|
||||
and a.enable_status = #{dto.enableStatus}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="scopePageJoin" resultType="com.bsd.pjcloud.admin.api.vo.car.SysUserCarVo">
|
||||
<include refid="selectA"/>
|
||||
from sys_user_car a
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
order by a.create_time desc , a.id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user