Эх сурвалжийг харах

添加车辆表增删查改

loovi 1 жил өмнө
parent
commit
f980297222

+ 151 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicle.java

@@ -0,0 +1,151 @@
+package com.pj.project.tb_vehicle;
+
+import java.io.Serializable;
+import java.util.*;
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.EqualsAndHashCode;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * Model: tb_vehicle -- 车辆
+ * @author loovi 
+ */
+@Data
+@Accessors(chain = true)
+@TableName(TbVehicle.TABLE_NAME)
+@EqualsAndHashCode(callSuper = false)
+public class TbVehicle extends Model<TbVehicle> implements Serializable {
+
+	// ---------- 模块常量 ----------
+	/**
+	 * 序列化版本id 
+	 */
+	private static final long serialVersionUID = 1L;	
+	/**
+	 * 此模块对应的表名 
+	 */
+	public static final String TABLE_NAME = "tb_vehicle";	
+	/**
+	 * 此模块对应的权限码 
+	 */
+	public static final String PERMISSION_CODE = "tb-vehicle";
+	public static final String PERMISSION_CODE_ADD = "tb-vehicle-add";
+	public static final String PERMISSION_CODE_EDIT = "tb-vehicle-edit";
+	public static final String PERMISSION_CODE_DEL = "tb-vehicle-del";
+
+
+
+
+	// ---------- 表中字段 ----------
+	/**
+	 * 主键 
+	 */
+	@TableId(type = IdType.AUTO)
+	private Long id;	
+
+	/**
+	 * 车牌 
+	 */
+	private String vehiclePlate;	
+
+	/**
+	 * 所有人 
+	 */
+	private String owner;	
+
+	/**
+	 * 车辆类型 
+	 */
+	private Integer vehicleType;	
+
+	/**
+	 * 类型父id 
+	 */
+	private Integer parentId;	
+
+	/**
+	 * 车辆尺寸 
+	 */
+	private String vehicleSize;	
+
+	/**
+	 * 车辆品牌型号 
+	 */
+	private String vehicleModel;	
+
+	/**
+	 * 核定载质量 
+	 */
+	private String vehicleLoad;	
+
+	/**
+	 * 车辆自重 
+	 */
+	private String vehicleWeight;	
+
+	/**
+	 * 创建者id 
+	 */
+	private String createBy;	
+
+	/**
+	 * 创建者姓名 
+	 */
+	private String createName;	
+
+	/**
+	 * 创建时间 
+	 */
+	private Date createTime;	
+
+	/**
+	 * 更新者id 
+	 */
+	private String updateBy;	
+
+	/**
+	 * 更新者名称 
+	 */
+	private String updateName;	
+
+	/**
+	 * 更新时间 
+	 */
+	private Date updateTime;	
+
+	/**
+	 * 删除状态 
+	 */
+	private String deleteStatus;	
+
+	/**
+	 * 审核状态(0=待审核,1=已通过,2=不通过) 
+	 */
+	private Integer auditStatus;	
+
+	/**
+	 * 审核人 
+	 */
+	private String auditBy;	
+
+	/**
+	 * 审核不通过原因 
+	 */
+	private String nopassReason;	
+
+	/**
+	 * 审核时间 
+	 */
+	private String auditTime;	
+
+
+
+
+
+	
+
+
+}

+ 88 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleController.java

@@ -0,0 +1,88 @@
+package com.pj.project.tb_vehicle;
+
+import java.util.List;
+import com.pj.utils.so.SoMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import com.pj.utils.sg.*;
+import com.pj.project4sp.SP;
+
+import com.pj.current.satoken.StpUserUtil;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+
+
+/**
+ * Controller: tb_vehicle -- 车辆
+ * @author loovi 
+ */
+@RestController
+@RequestMapping("/TbVehicle/")
+public class TbVehicleController {
+
+	/** 底层 Service 对象 */
+	@Autowired
+	TbVehicleService tbVehicleService;
+
+	/** 增 */  
+	@RequestMapping("add")
+	@SaCheckPermission(TbVehicle.PERMISSION_CODE_ADD)
+	public AjaxJson add(TbVehicle t){
+		tbVehicleService.add(t);
+		t = tbVehicleService.getById(SP.publicMapper.getPrimarykey());
+		return AjaxJson.getSuccessData(t);
+	}
+
+	/** 删 */  
+	@RequestMapping("delete")
+	@SaCheckPermission(TbVehicle.PERMISSION_CODE_DEL)
+	public AjaxJson delete(Long id){
+		 tbVehicleService.delete(id);
+		return AjaxJson.getSuccess();
+	}
+	
+	/** 删 - 根据id列表 */  
+	@RequestMapping("deleteByIds")
+	@SaCheckPermission(TbVehicle.PERMISSION_CODE_DEL)
+	public AjaxJson deleteByIds(){
+		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
+		int line = SP.publicMapper.deleteByIds(TbVehicle.TABLE_NAME, ids);
+		return AjaxJson.getByLine(line);
+	}
+	
+	/** 改 */  
+	@RequestMapping("update")
+	@SaCheckPermission(TbVehicle.PERMISSION_CODE_EDIT)
+	public AjaxJson update(TbVehicle t){
+		tbVehicleService.update(t);
+		return AjaxJson.getSuccess();
+	}
+
+	/** 查 - 根据id */  
+	@RequestMapping("getById")
+		@SaCheckPermission(TbVehicle.PERMISSION_CODE)
+	public AjaxJson getById(Long id){
+		TbVehicle t = tbVehicleService.getById(id);
+		return AjaxJson.getSuccessData(t);
+	}
+
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
+	@RequestMapping("getList")
+		@SaCheckPermission(TbVehicle.PERMISSION_CODE)
+	public AjaxJson getList() { 
+		SoMap so = SoMap.getRequestSoMap();
+		so.set("deleteStatus", 1);
+		List<TbVehicle> list = tbVehicleService.getList(so.startPage());
+		return AjaxJson.getPageData(so.getDataCount(), list);
+	}
+	
+	
+	
+	
+
+	
+	
+	
+
+}

+ 30 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleMapper.java

@@ -0,0 +1,30 @@
+package com.pj.project.tb_vehicle;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.pj.utils.so.*;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Mapper: tb_vehicle -- 车辆
+ * @author loovi 
+ */
+
+@Mapper
+@Repository
+public interface TbVehicleMapper extends BaseMapper <TbVehicle> {
+
+
+
+	/**
+	 * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+	 * @param so 参数集合 
+	 * @return 数据列表 
+	 */
+	List<TbVehicle> getList(SoMap so);
+
+
+}

+ 78 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleMapper.xml

@@ -0,0 +1,78 @@
+<?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.pj.project.tb_vehicle.TbVehicleMapper">
+
+
+
+
+	<!-- ================================== 查询相关 ================================== -->
+	<!-- select id, vehicle_plate, owner, vehicle_type, parent_id, vehicle_size, vehicle_model, vehicle_load, vehicle_weight, create_by, create_name, create_time, update_by, update_name, update_time, delete_status, audit_status, audit_by, nopass_reason, audit_time from tb_vehicle  -->
+	
+	<!-- 通用映射:自动模式 -->
+	<resultMap id="model" autoMapping="true" type="com.pj.project.tb_vehicle.TbVehicle"></resultMap>
+	
+	<!-- 公共查询sql片段 -->
+	<sql id="select_sql">
+		select * 
+		from tb_vehicle 
+	</sql>
+
+	
+	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
+	<select id="getList" resultMap="model">
+		<include refid="select_sql"></include>
+		<where>
+			<if test=' this.has("id") '> and id = #{id} </if>
+			<if test=' this.has("vehiclePlate") '> and vehicle_plate = #{vehiclePlate} </if>
+			<if test=' this.has("owner") '> and owner = #{owner} </if>
+			<if test=' this.has("vehicleType") '> and vehicle_type = #{vehicleType} </if>
+			<if test=' this.has("parentId") '> and parent_id = #{parentId} </if>
+			<if test=' this.has("vehicleSize") '> and vehicle_size = #{vehicleSize} </if>
+			<if test=' this.has("vehicleModel") '> and vehicle_model = #{vehicleModel} </if>
+			<if test=' this.has("vehicleLoad") '> and vehicle_load = #{vehicleLoad} </if>
+			<if test=' this.has("vehicleWeight") '> and vehicle_weight = #{vehicleWeight} </if>
+			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>
+			<if test=' this.has("createName") '> and create_name = #{createName} </if>
+			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
+			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
+			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
+			<if test=' this.has("auditStatus") '> and audit_status = #{auditStatus} </if>
+			<if test=' this.has("auditBy") '> and audit_by = #{auditBy} </if>
+			<if test=' this.has("nopassReason") '> and nopass_reason = #{nopassReason} </if>
+			<if test=' this.has("auditTime") '> and audit_time = #{auditTime} </if>
+		</where>
+		order by
+		<choose>
+			<when test='sortType == 1'> id desc </when>
+			<when test='sortType == 2'> vehicle_plate desc </when>
+			<when test='sortType == 3'> owner desc </when>
+			<when test='sortType == 4'> vehicle_type desc </when>
+			<when test='sortType == 5'> parent_id desc </when>
+			<when test='sortType == 6'> vehicle_size desc </when>
+			<when test='sortType == 7'> vehicle_model desc </when>
+			<when test='sortType == 8'> vehicle_load desc </when>
+			<when test='sortType == 9'> vehicle_weight desc </when>
+			<when test='sortType == 10'> create_by desc </when>
+			<when test='sortType == 11'> create_name desc </when>
+			<when test='sortType == 12'> create_time desc </when>
+			<when test='sortType == 13'> update_by desc </when>
+			<when test='sortType == 14'> update_name desc </when>
+			<when test='sortType == 15'> update_time desc </when>
+			<when test='sortType == 16'> audit_status desc </when>
+			<when test='sortType == 17'> audit_by desc </when>
+			<when test='sortType == 18'> nopass_reason desc </when>
+			<when test='sortType == 19'> audit_time desc </when>
+			<otherwise> id desc </otherwise>
+		</choose>
+	</select>
+	
+	
+	
+	
+	
+	
+	
+	
+	
+
+</mapper>

+ 51 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleService.java

@@ -0,0 +1,51 @@
+package com.pj.project.tb_vehicle;
+
+import java.util.List;
+import com.pj.utils.so.SoMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
+import com.pj.utils.sg.*;
+
+/**
+ * Service: tb_vehicle -- 车辆
+ * @author loovi 
+ */
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class TbVehicleService extends ServiceImpl<TbVehicleMapper, TbVehicle> implements IService<TbVehicle>{
+
+	/** 底层 Mapper 对象 */
+	@Autowired
+	TbVehicleMapper tbVehicleMapper;
+
+	/** 增 */
+	void add(TbVehicle t){
+		save(t);
+	}
+
+	/** 删 */
+	void delete(Long id){
+		removeById(id);
+	}
+
+	/** 改 */
+	void update(TbVehicle t){
+		updateById(t);
+
+	}
+
+	/** 查 */
+	TbVehicle getById(Long id){
+		return super.getById(id);
+	}
+
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
+	List<TbVehicle> getList(SoMap so) { 
+		return tbVehicleMapper.getList(so);	
+	}
+	
+
+}

+ 82 - 0
sp-service/transport-server/src/main/java/com/pj/project/tb_vehicle/TbVehicleUtil.java

@@ -0,0 +1,82 @@
+package com.pj.project.tb_vehicle;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.pj.utils.sg.*;
+import java.util.*;
+
+/**
+ * 工具类:tb_vehicle -- 车辆
+ * @author loovi 
+ *
+ */
+@Component
+public class TbVehicleUtil {
+
+	
+	/** 底层 Mapper 对象 */
+	public static TbVehicleMapper tbVehicleMapper;
+	@Autowired
+	private void setTbVehicleMapper(TbVehicleMapper tbVehicleMapper) {
+		TbVehicleUtil.tbVehicleMapper = tbVehicleMapper;
+	}
+	
+	
+	/** 
+	 * 将一个 TbVehicle 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
+	 */
+	static void check(TbVehicle t) {
+		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键 
+		AjaxError.throwByIsNull(t.getVehiclePlate(), "[车牌] 不能为空");		// 验证: 车牌 
+		AjaxError.throwByIsNull(t.getOwner(), "[所有人] 不能为空");		// 验证: 所有人 
+		AjaxError.throwByIsNull(t.getVehicleType(), "[车辆类型] 不能为空");		// 验证: 车辆类型 
+		AjaxError.throwByIsNull(t.getParentId(), "[类型父id] 不能为空");		// 验证: 类型父id 
+		AjaxError.throwByIsNull(t.getVehicleSize(), "[车辆尺寸] 不能为空");		// 验证: 车辆尺寸 
+		AjaxError.throwByIsNull(t.getVehicleModel(), "[车辆品牌型号] 不能为空");		// 验证: 车辆品牌型号 
+		AjaxError.throwByIsNull(t.getVehicleLoad(), "[核定载质量] 不能为空");		// 验证: 核定载质量 
+		AjaxError.throwByIsNull(t.getVehicleWeight(), "[车辆自重] 不能为空");		// 验证: 车辆自重 
+		AjaxError.throwByIsNull(t.getCreateBy(), "[创建者id] 不能为空");		// 验证: 创建者id 
+		AjaxError.throwByIsNull(t.getCreateName(), "[创建者姓名] 不能为空");		// 验证: 创建者姓名 
+		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间 
+		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新者id] 不能为空");		// 验证: 更新者id 
+		AjaxError.throwByIsNull(t.getUpdateName(), "[更新者名称] 不能为空");		// 验证: 更新者名称 
+		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间 
+		AjaxError.throwByIsNull(t.getAuditStatus(), "[审核状态] 不能为空");		// 验证: 审核状态(0=待审核,1=已通过,2=不通过) 
+		AjaxError.throwByIsNull(t.getAuditBy(), "[审核人] 不能为空");		// 验证: 审核人 
+		AjaxError.throwByIsNull(t.getNopassReason(), "[审核不通过原因] 不能为空");		// 验证: 审核不通过原因 
+		AjaxError.throwByIsNull(t.getAuditTime(), "[审核时间] 不能为空");		// 验证: 审核时间 
+	}
+
+	/** 
+	 * 获取一个TbVehicle (方便复制代码用) [G] 
+	 */ 
+	static TbVehicle getTbVehicle() {
+		TbVehicle t = new TbVehicle();	// 声明对象 
+		t.setId(0L);		// 主键 
+		t.setVehiclePlate("");		// 车牌 
+		t.setOwner("");		// 所有人 
+		t.setVehicleType(0);		// 车辆类型 
+		t.setParentId(0);		// 类型父id 
+		t.setVehicleSize("");		// 车辆尺寸 
+		t.setVehicleModel("");		// 车辆品牌型号 
+		t.setVehicleLoad("");		// 核定载质量 
+		t.setVehicleWeight("");		// 车辆自重 
+		t.setCreateBy("");		// 创建者id 
+		t.setCreateName("");		// 创建者姓名 
+		t.setCreateTime(new Date());		// 创建时间 
+		t.setUpdateBy("");		// 更新者id 
+		t.setUpdateName("");		// 更新者名称 
+		t.setUpdateTime(new Date());		// 更新时间 
+		t.setAuditStatus(0);		// 审核状态(0=待审核,1=已通过,2=不通过) 
+		t.setAuditBy("");		// 审核人 
+		t.setNopassReason("");		// 审核不通过原因 
+		t.setAuditTime("");		// 审核时间 
+		return t;
+	}
+	
+	
+	
+	
+	
+}