Commit dcf2838b authored by hanbing's avatar hanbing

系统管理-设备管理-厂商管理-添加或修改

parent a3f6a428
...@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiResponse; ...@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import net.wanji.utc.po.ManufacturerInfoPO; import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.service.systemadmin.ManufacturerService; import net.wanji.utc.service.systemadmin.ManufacturerService;
import net.wanji.utc.vo.systemadmin.ManufacturerInsertOrUpdateInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerListInVO; import net.wanji.utc.vo.systemadmin.ManufacturerListInVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
...@@ -42,6 +43,11 @@ public class ManufacturerAdminController { ...@@ -42,6 +43,11 @@ public class ManufacturerAdminController {
return ResponseEntity.ok(manufacturerInfoPOPageInfo); return ResponseEntity.ok(manufacturerInfoPOPageInfo);
} }
//添加或修改 //添加或修改
@ApiOperation(value = "厂商添加或修改", notes = "厂商添加或修改", consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/insertOrUpdate", consumes = MediaType.APPLICATION_JSON)
public ResponseEntity insertOrUpdate(@RequestBody ManufacturerInsertOrUpdateInVO inVO) {
manufacturerService.insertOrUpdate(inVO);
return ResponseEntity.ok("success");
}
//删除 //删除
} }
...@@ -19,4 +19,8 @@ public interface ManufacturerInfoMapper { ...@@ -19,4 +19,8 @@ public interface ManufacturerInfoMapper {
List<ManufacturerInfoPO> selectAll(); List<ManufacturerInfoPO> selectAll();
List<ManufacturerInfoPO> selectByOptionalName(@Param("name") String name); List<ManufacturerInfoPO> selectByOptionalName(@Param("name") String name);
void insertOne(ManufacturerInfoPO manufacturerInfoPO);
void updateOne(ManufacturerInfoPO manufacturerInfoPO);
} }
...@@ -2,6 +2,7 @@ package net.wanji.utc.service.systemadmin; ...@@ -2,6 +2,7 @@ package net.wanji.utc.service.systemadmin;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import net.wanji.utc.po.ManufacturerInfoPO; import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.vo.systemadmin.ManufacturerInsertOrUpdateInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerListInVO; import net.wanji.utc.vo.systemadmin.ManufacturerListInVO;
/** /**
...@@ -10,4 +11,6 @@ import net.wanji.utc.vo.systemadmin.ManufacturerListInVO; ...@@ -10,4 +11,6 @@ import net.wanji.utc.vo.systemadmin.ManufacturerListInVO;
*/ */
public interface ManufacturerService { public interface ManufacturerService {
PageInfo<ManufacturerInfoPO> list(ManufacturerListInVO manufacturerListInVO); PageInfo<ManufacturerInfoPO> list(ManufacturerListInVO manufacturerListInVO);
void insertOrUpdate(ManufacturerInsertOrUpdateInVO inVO);
} }
...@@ -5,8 +5,11 @@ import com.github.pagehelper.PageInfo; ...@@ -5,8 +5,11 @@ import com.github.pagehelper.PageInfo;
import net.wanji.utc.mapper.ManufacturerInfoMapper; import net.wanji.utc.mapper.ManufacturerInfoMapper;
import net.wanji.utc.po.ManufacturerInfoPO; import net.wanji.utc.po.ManufacturerInfoPO;
import net.wanji.utc.service.systemadmin.ManufacturerService; import net.wanji.utc.service.systemadmin.ManufacturerService;
import net.wanji.utc.vo.systemadmin.ManufacturerInsertOrUpdateInVO;
import net.wanji.utc.vo.systemadmin.ManufacturerListInVO; import net.wanji.utc.vo.systemadmin.ManufacturerListInVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -32,4 +35,18 @@ public class ManufacturerServiceImpl implements ManufacturerService { ...@@ -32,4 +35,18 @@ public class ManufacturerServiceImpl implements ManufacturerService {
return borrowPOPageInfo; return borrowPOPageInfo;
} }
@Override
public void insertOrUpdate(ManufacturerInsertOrUpdateInVO inVO) {
Integer id = inVO.getId();
ManufacturerInfoPO manufacturerInfoPO = new ManufacturerInfoPO();
BeanUtils.copyProperties(inVO, manufacturerInfoPO);
if (id == null || id == 0) {
// 添加
manufacturerInfoMapper.insertOne(manufacturerInfoPO);
} else {
// 修改
manufacturerInfoMapper.updateOne(manufacturerInfoPO);
}
}
} }
package net.wanji.utc.vo.systemadmin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/11/24 9:42
*/
@Data
@ApiModel(value = "ManufacturerInsertOrUpdateInVO",
description = "厂商添加或修改输入参数。如果携带ID,即为修改;如果不携带ID,即为新增")
public class ManufacturerInsertOrUpdateInVO {
/** 厂商ID */
@ApiModelProperty(value = "厂商ID。如果携带ID,即为修改;如果不携带ID,即为新增",notes = "")
private Integer id ;
/** 厂商代码 */
@ApiModelProperty(value = "厂商代码",notes = "")
private String code ;
/** 厂商名称 */
@ApiModelProperty(value = "厂商名称",notes = "")
private String name ;
/** 厂商简称 */
@ApiModelProperty(value = "厂商简称",notes = "")
private String nickName ;
/** 平台地址 */
@ApiModelProperty(value = "平台地址",notes = "")
private String address ;
/** 维护单位 */
@ApiModelProperty(value = "维护单位",notes = "")
private String maintenanceUnit ;
}
...@@ -11,6 +11,32 @@ ...@@ -11,6 +11,32 @@
<result property="gmtCreate" column="gmt_create"/> <result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/> <result property="gmtModified" column="gmt_modified"/>
</resultMap> </resultMap>
<insert id="insertOne">
insert into t_manufacturer_info(code,name,nick_name,address,maintenance_unit)
values (#{code},#{name},#{nickName},#{address},#{maintenanceUnit})
</insert>
<update id="updateOne">
update t_manufacturer_info
<set>
<if test="code != null and code != ''">
code = #{code},
</if>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="nickName != null and nickName != ''">
nick_name = #{nickName},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="maintenanceUnit != null and maintenanceUnit != ''">
maintenance_unit = #{maintenanceUnit},
</if>
</set>
where id = #{id}
</update>
<select id="selectByAbbr" resultMap="BaseResultMap"> <select id="selectByAbbr" resultMap="BaseResultMap">
select select
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment