test:(添加车辆)

dev
zhang xu 2024-05-27 18:42:15 +08:00
parent 1e4f78bc2b
commit 75a29531b4
23 changed files with 1206 additions and 4 deletions

View File

@ -132,6 +132,19 @@ public class SysUser extends BaseEntity {
*/
private Long[] postIds;
/**
*
* */
private String userType;
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
/**
* ID
*/
@ -323,6 +336,7 @@ public class SysUser extends BaseEntity {
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("dept", getDept())
.append("userType", getUserType())
.toString();
}
}

View File

@ -0,0 +1,160 @@
package com.muyu.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
*
*
* @author ruoyi
* @date 2024-05-27
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class Information extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 车辆vin */
@Excel(name = "车辆vin")
private String number;
/** 车辆类型 */
@Excel(name = "车辆类型")
private Long typeId;
/** 电子围栏id */
@Excel(name = "电子围栏id")
private Long electronicId;
/** 电机厂商 */
@Excel(name = "电机厂商")
private String motor;
/** 电池厂商 */
@Excel(name = "电池厂商")
private String battery;
/** 电机编号 */
@Excel(name = "电机编号")
private String motorNumber;
/** 电池编号 */
@Excel(name = "电池编号")
private String batteryNumber;
/** 企业id */
@Excel(name = "企业id")
private Long enterpriseId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setNumber(String number)
{
this.number = number;
}
public String getNumber()
{
return number;
}
public void setTypeId(Long typeId)
{
this.typeId = typeId;
}
public Long getTypeId()
{
return typeId;
}
public void setElectronicId(Long electronicId)
{
this.electronicId = electronicId;
}
public Long getElectronicId()
{
return electronicId;
}
public void setMotor(String motor)
{
this.motor = motor;
}
public String getMotor()
{
return motor;
}
public void setBattery(String battery)
{
this.battery = battery;
}
public String getBattery()
{
return battery;
}
public void setMotorNumber(String motorNumber)
{
this.motorNumber = motorNumber;
}
public String getMotorNumber()
{
return motorNumber;
}
public void setBatteryNumber(String batteryNumber)
{
this.batteryNumber = batteryNumber;
}
public String getBatteryNumber()
{
return batteryNumber;
}
public void setEnterpriseId(Long enterpriseId)
{
this.enterpriseId = enterpriseId;
}
public Long getEnterpriseId()
{
return enterpriseId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("number", getNumber())
.append("typeId", getTypeId())
.append("electronicId", getElectronicId())
.append("motor", getMotor())
.append("battery", getBattery())
.append("motorNumber", getMotorNumber())
.append("batteryNumber", getBatteryNumber())
.append("enterpriseId", getEnterpriseId())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,64 @@
package com.muyu.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
*
*
* @author ruoyi
* @date 2024-05-27
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class Type extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 车辆类型 */
@Excel(name = "车辆类型")
private String typeName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTypeName(String typeName)
{
this.typeName = typeName;
}
public String getTypeName()
{
return typeName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("typeName", getTypeName())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.toString();
}
}

View File

@ -0,0 +1,31 @@
package com.muyu.domain;
import com.muyu.common.core.web.domain.BaseEntity;
import java.util.Date;
/**
* @ClassDescription:
* @JdkVersion: 17
* @Author: zhangxu
* @Created: 2024/5/26 20:31
*/
public class Vehicle extends BaseEntity {
private Long id; // 车辆唯一标识
private String vin; // 车辆识别号码VIN
private String brand; // 品牌
private String model; // 型号
private int manufactureYear; // 生产年份
private String bodyType; // 车身类型,例如"Sedan", "SUV"
private String color; // 车身颜色
private double engineCapacity; // 发动机排量,单位升
private String fuelType; // 燃油类型,例如"Petrol", "Diesel", "Electric"
private String transmission; // 变速器类型,例如"Automatic", "Manual"
private String driveType; // 驱动方式,例如"FWD", "RWD", "AWD"
private long mileage; // 行驶里程,单位公里
private Date registrationDate; // 注册日期
private String registrationNumber; // 车牌号码
private String ownerId; // 所有者
}

View File

@ -58,8 +58,6 @@
<version>3.6.3</version>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>

View File

@ -5,6 +5,7 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @ClassDescription:

View File

@ -94,6 +94,8 @@ public class EnterpriseController extends BaseController
return toAjax(enterpriseService.updateEnterprise(enterprise));
}
/**
*
*/

View File

@ -0,0 +1,109 @@
package com.muyu.networking.controller;
import javax.servlet.http.HttpServletResponse;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.domain.Information;
import com.muyu.networking.service.IInformationService;
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.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import java.util.List;
/**
* Controller
*
* @author ruoyi
* @date 2024-05-27
*/
@RestController
@RequestMapping("/information")
public class InformationController extends BaseController
{
@Autowired
private IInformationService informationService;
/**
*
*/
@RequiresPermissions("system:information:list")
@GetMapping("/list")
public Result<TableDataInfo<Information>> list(Information information)
{
startPage();
List<Information> list = informationService.selectInformationList(information);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:information:export")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Information information)
{
List<Information> list = informationService.selectInformationList(information);
ExcelUtil<Information> util = new ExcelUtil<Information>(Information.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
*
*/
@RequiresPermissions("system:information:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(informationService.selectInformationById(id));
}
/**
*
*/
@RequiresPermissions("system:information:add")
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody Information information)
{
return toAjax(informationService.insertInformation(information));
}
/**
*
*/
@RequiresPermissions("system:information:edit")
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody Information information)
{
return toAjax(informationService.updateInformation(information));
}
/**
*
*/
@RequiresPermissions("system:information:remove")
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(informationService.deleteInformationByIds(ids));
}
}

View File

@ -0,0 +1,109 @@
package com.muyu.networking.controller;
import javax.servlet.http.HttpServletResponse;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.domain.Type;
import com.muyu.networking.service.ITypeService;
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.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import java.util.List;
/**
* Controller
*
* @author ruoyi
* @date 2024-05-27
*/
@RestController
@RequestMapping("/type")
public class TypeController extends BaseController
{
@Autowired
private ITypeService typeService;
/**
*
*/
@RequiresPermissions("system:type:list")
@GetMapping("/list")
public Result<TableDataInfo<Type>> list(Type type)
{
startPage();
List<Type> list = typeService.selectTypeList(type);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:type:export")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Type type)
{
List<Type> list = typeService.selectTypeList(type);
ExcelUtil<Type> util = new ExcelUtil<Type>(Type.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
*
*/
@RequiresPermissions("system:type:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(typeService.selectTypeById(id));
}
/**
*
*/
@RequiresPermissions("system:type:add")
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody Type type)
{
return toAjax(typeService.insertType(type));
}
/**
*
*/
@RequiresPermissions("system:type:edit")
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody Type type)
{
return toAjax(typeService.updateType(type));
}
/**
*
*/
@RequiresPermissions("system:type:remove")
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(typeService.deleteTypeByIds(ids));
}
}

View File

@ -59,4 +59,12 @@ public interface EnterpriseMapper
* @return
*/
public int deleteEnterpriseByIds(Long[] ids);
/**
*
* */
public int updateEnterpriseStatus(Long id,String openAdd);
}

View File

@ -0,0 +1,63 @@
package com.muyu.networking.mapper;
import com.muyu.domain.Information;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2024-05-27
*/
public interface InformationMapper
{
/**
*
*
* @param id
* @return
*/
public Information selectInformationById(Long id);
/**
*
*
* @param information
* @return
*/
public List<Information> selectInformationList(Information information);
/**
*
*
* @param information
* @return
*/
public int insertInformation(Information information);
/**
*
*
* @param information
* @return
*/
public int updateInformation(Information information);
/**
*
*
* @param id
* @return
*/
public int deleteInformationById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteInformationByIds(Long[] ids);
}

View File

@ -0,0 +1,62 @@
package com.muyu.networking.mapper;
import com.muyu.domain.Type;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2024-05-27
*/
public interface TypeMapper
{
/**
*
*
* @param id
* @return
*/
public Type selectTypeById(Long id);
/**
*
*
* @param type
* @return
*/
public List<Type> selectTypeList(Type type);
/**
*
*
* @param type
* @return
*/
public int insertType(Type type);
/**
*
*
* @param type
* @return
*/
public int updateType(Type type);
/**
*
*
* @param id
* @return
*/
public int deleteTypeById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteTypeByIds(Long[] ids);
}

View File

@ -0,0 +1,21 @@
package com.muyu.networking.opFen;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @ClassDescription:
* @JdkVersion: 17
* @Author: zhangxu
* @Created: 2024/5/27 15:11
*/
@FeignClient("muyu-system")
public interface SysUserNet {
@PostMapping
public Result add (@Validated @RequestBody SysUser user);
}

View File

@ -58,4 +58,13 @@ public interface EnterpriseService
* @return
*/
public int deleteEnterpriseById(Long id);
/**
*
* **/
public int updateEnterpriseStatus(Long id,String openAdd);
}

View File

@ -0,0 +1,63 @@
package com.muyu.networking.service;
import com.muyu.domain.Information;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2024-05-27
*/
public interface IInformationService
{
/**
*
*
* @param id
* @return
*/
public Information selectInformationById(Long id);
/**
*
*
* @param information
* @return
*/
public List<Information> selectInformationList(Information information);
/**
*
*
* @param information
* @return
*/
public int insertInformation(Information information);
/**
*
*
* @param information
* @return
*/
public int updateInformation(Information information);
/**
*
*
* @param ids
* @return
*/
public int deleteInformationByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteInformationById(Long id);
}

View File

@ -0,0 +1,63 @@
package com.muyu.networking.service;
import com.muyu.domain.Type;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2024-05-27
*/
public interface ITypeService
{
/**
*
*
* @param id
* @return
*/
public Type selectTypeById(Long id);
/**
*
*
* @param type
* @return
*/
public List<Type> selectTypeList(Type type);
/**
*
*
* @param type
* @return
*/
public int insertType(Type type);
/**
*
*
* @param type
* @return
*/
public int updateType(Type type);
/**
*
*
* @param ids
* @return
*/
public int deleteTypeByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteTypeById(Long id);
}

View File

@ -3,12 +3,17 @@ package com.muyu.networking.service.impl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysUser;
import com.muyu.domain.Enterprise;
import com.muyu.networking.mapper.EnterpriseMapper;
import com.muyu.networking.opFen.SysUserNet;
import com.muyu.networking.service.EnterpriseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.security.SecureRandom;
import java.util.List;
import java.util.UUID;
@ -60,10 +65,39 @@ public class EnterpriseServiceImpl implements EnterpriseService
{
enterprise.setCreateBy(SecurityUtils.getUsername());
enterprise.setCreateTime(DateUtils.getNowDate());
enterprise.setBusinessLicenseNumber(UUID.randomUUID().toString());
enterprise.setBusinessLicenseNumber(UUID.randomUUID().toString().replaceAll("-",""));
SysUser sysUser = new SysUser();
insertUser(sysUser);
return enterpriseMapper.insertEnterprise(enterprise);
}
@Autowired
private SysUserNet sysUserNet;
public void insertUser(SysUser user){
String alphabet = "abcdefghijklmnopqrstuvwxyz"; // Only lowercase letters
SecureRandom random = new SecureRandom();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < 6; i++) {
int index = random.nextInt(alphabet.length());
stringBuilder.append(alphabet.charAt(index));
}
user.setUserName(stringBuilder.toString());
String pwd = "1234567890"; // Only lowercase letters
SecureRandom randomPwd = new SecureRandom();
StringBuilder stringPwd = new StringBuilder();
for (int i = 0; i < 6; i++) {
int index = randomPwd.nextInt(pwd.length());
stringPwd.append(pwd.charAt(index));
}
user.setPassword(stringPwd.toString());
user.setUserType("enterprise");
sysUserNet.add(user);
}
/**
*
*
@ -100,4 +134,12 @@ public class EnterpriseServiceImpl implements EnterpriseService
{
return enterpriseMapper.deleteEnterpriseById(id);
}
@Override
public int updateEnterpriseStatus(Long id, String openAdd) {
if (enterpriseMapper.updateEnterpriseStatus(id, openAdd) > 0) {
return 1;
}
return 0;
}
}

View File

@ -0,0 +1,97 @@
package com.muyu.networking.service.impl;
import java.util.List;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.domain.Information;
import com.muyu.networking.mapper.InformationMapper;
import com.muyu.networking.service.IInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service
*
* @author ruoyi
* @date 2024-05-27
*/
@Service
public class InformationServiceImpl implements IInformationService
{
@Autowired
private InformationMapper informationMapper;
/**
*
*
* @param id
* @return
*/
@Override
public Information selectInformationById(Long id)
{
return informationMapper.selectInformationById(id);
}
/**
*
*
* @param information
* @return
*/
@Override
public List<Information> selectInformationList(Information information)
{
return informationMapper.selectInformationList(information);
}
/**
*
*
* @param information
* @return
*/
@Override
public int insertInformation(Information information)
{
information.setCreateTime(DateUtils.getNowDate());
return informationMapper.insertInformation(information);
}
/**
*
*
* @param information
* @return
*/
@Override
public int updateInformation(Information information)
{
information.setUpdateTime(DateUtils.getNowDate());
return informationMapper.updateInformation(information);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteInformationByIds(Long[] ids)
{
return informationMapper.deleteInformationByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteInformationById(Long id)
{
return informationMapper.deleteInformationById(id);
}
}

View File

@ -0,0 +1,99 @@
package com.muyu.networking.service.impl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.domain.Type;
import com.muyu.networking.mapper.TypeMapper;
import com.muyu.networking.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2024-05-27
*/
@Service
public class TypeServiceImpl implements ITypeService
{
@Autowired
private TypeMapper typeMapper;
/**
*
*
* @param id
* @return
*/
@Override
public Type selectTypeById(Long id)
{
return typeMapper.selectTypeById(id);
}
/**
*
*
* @param type
* @return
*/
@Override
public List<Type> selectTypeList(Type type)
{
return typeMapper.selectTypeList(type);
}
/**
*
*
* @param type
* @return
*/
@Override
public int insertType(Type type)
{
type.setCreateTime(DateUtils.getNowDate());
return typeMapper.insertType(type);
}
/**
*
*
* @param type
* @return
*/
@Override
public int updateType(Type type)
{
type.setUpdateTime(DateUtils.getNowDate());
return typeMapper.updateType(type);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteTypeByIds(Long[] ids)
{
return typeMapper.deleteTypeByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteTypeById(Long id)
{
return typeMapper.deleteTypeById(id);
}
}

View File

@ -25,6 +25,5 @@ spring:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
config: classpath:logback-spring.xml
level:
com.muyu.networking.mapper: DEBUG

View File

@ -127,6 +127,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update id="updateEnterpriseStatus">
update enterprise set open_add = #{openAdd} where id = #{id}
</update>
<delete id="deleteEnterpriseById" parameterType="Long">
delete from enterprise where id = #{id}

View File

@ -0,0 +1,107 @@
<?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.muyu.networking.mapper.InformationMapper">
<resultMap type="com.muyu.domain.Information" id="InformationResult">
<result property="id" column="id" />
<result property="number" column="number" />
<result property="typeId" column="type_id" />
<result property="electronicId" column="electronic_id" />
<result property="motor" column="motor" />
<result property="battery" column="battery" />
<result property="motorNumber" column="motor_number" />
<result property="batteryNumber" column="battery_number" />
<result property="enterpriseId" column="enterprise_id" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectInformationVo">
select id, number, type_id, electronic_id, motor, battery, motor_number, battery_number, enterprise_id, remark, create_by, create_time, update_time from information
</sql>
<select id="selectInformationList" parameterType="com.muyu.domain.Information" resultMap="InformationResult">
<include refid="selectInformationVo"/>
<where>
<if test="number != null and number != ''"> and number = #{number}</if>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="electronicId != null "> and electronic_id = #{electronicId}</if>
<if test="motor != null and motor != ''"> and motor = #{motor}</if>
<if test="battery != null and battery != ''"> and battery = #{battery}</if>
<if test="motorNumber != null and motorNumber != ''"> and motor_number = #{motorNumber}</if>
<if test="batteryNumber != null and batteryNumber != ''"> and battery_number = #{batteryNumber}</if>
<if test="enterpriseId != null "> and enterprise_id = #{enterpriseId}</if>
</where>
</select>
<select id="selectInformationById" parameterType="Long" resultMap="InformationResult">
<include refid="selectInformationVo"/>
where id = #{id}
</select>
<insert id="insertInformation" parameterType="com.muyu.domain.Information" useGeneratedKeys="true" keyProperty="id">
insert into information
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="number != null">number,</if>
<if test="typeId != null">type_id,</if>
<if test="electronicId != null">electronic_id,</if>
<if test="motor != null">motor,</if>
<if test="battery != null">battery,</if>
<if test="motorNumber != null">motor_number,</if>
<if test="batteryNumber != null">battery_number,</if>
<if test="enterpriseId != null">enterprise_id,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="number != null">#{number},</if>
<if test="typeId != null">#{typeId},</if>
<if test="electronicId != null">#{electronicId},</if>
<if test="motor != null">#{motor},</if>
<if test="battery != null">#{battery},</if>
<if test="motorNumber != null">#{motorNumber},</if>
<if test="batteryNumber != null">#{batteryNumber},</if>
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateInformation" parameterType="com.muyu.domain.Information">
update information
<trim prefix="SET" suffixOverrides=",">
<if test="number != null">number = #{number},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="electronicId != null">electronic_id = #{electronicId},</if>
<if test="motor != null">motor = #{motor},</if>
<if test="battery != null">battery = #{battery},</if>
<if test="motorNumber != null">motor_number = #{motorNumber},</if>
<if test="batteryNumber != null">battery_number = #{batteryNumber},</if>
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInformationById" parameterType="Long">
delete from information where id = #{id}
</delete>
<delete id="deleteInformationByIds" parameterType="String">
delete from information where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -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.muyu.networking.mapper.TypeMapper">
<resultMap type="com.muyu.domain.Type" id="TypeResult">
<result property="id" column="id" />
<result property="typeName" column="type_name" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectTypeVo">
select id, type_name, remark, create_by, create_time, update_time, update_by from type
</sql>
<select id="selectTypeList" parameterType="com.muyu.domain.Type" resultMap="TypeResult">
<include refid="selectTypeVo"/>
<where>
<if test="typeName != null and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
</where>
</select>
<select id="selectTypeById" parameterType="Long" resultMap="TypeResult">
<include refid="selectTypeVo"/>
where id = #{id}
</select>
<insert id="insertType" parameterType="com.muyu.domain.Type">
insert into type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="typeName != null">type_name,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="typeName != null">#{typeName},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateType" parameterType="com.muyu.domain.Type">
update type
<trim prefix="SET" suffixOverrides=",">
<if test="typeName != null">type_name = #{typeName},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTypeById" parameterType="Long">
delete from type where id = #{id}
</delete>
<delete id="deleteTypeByIds" parameterType="String">
delete from type where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>