代码提交

This commit is contained in:
liang.chao 2025-11-11 16:39:36 +08:00
parent 7f66ebb176
commit 3d45c677f4
13 changed files with 91 additions and 41 deletions

View File

@ -7,10 +7,7 @@ import com.bonus.waterdesign.domain.OwnerDto;
import com.bonus.waterdesign.service.OwnerService; import com.bonus.waterdesign.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -37,17 +34,17 @@ public class OwnerController extends BaseController {
} }
@PreAuthorize("@ss.hasPermi('owner:add')") @PreAuthorize("@ss.hasPermi('owner:add')")
@PostMapping("/add") @PostMapping("/add")
public AjaxResult add(OwnerDto dto) { public AjaxResult add(@RequestBody OwnerDto dto) {
return ownerService.add(dto); return ownerService.add(dto);
} }
@PreAuthorize("@ss.hasPermi('owner:update')") @PreAuthorize("@ss.hasPermi('owner:update')")
@GetMapping("/update") @PostMapping("/update")
public AjaxResult update(OwnerDto dto) { public AjaxResult update(@RequestBody OwnerDto dto) {
return ownerService.update(dto); return ownerService.update(dto);
} }
@PreAuthorize("@ss.hasPermi('owner:del')") @PreAuthorize("@ss.hasPermi('owner:del')")
@GetMapping("/del") @PostMapping("/del")
public AjaxResult del(OwnerDto dto) { public AjaxResult del(@RequestBody OwnerDto dto) {
return ownerService.delete(dto); return ownerService.delete(dto);
} }
} }

View File

@ -27,7 +27,7 @@ public class ProTypeController extends BaseController {
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(ProTypeDto dto) { public TableDataInfo list(ProTypeDto dto) {
startPage(); startPage();
List<ProTypeDto> list = proTypeService.getDeviceType(dto); List<ProTypeDto> list = proTypeService.getProType(dto);
return getDataTable(list); return getDataTable(list);
} }
@PreAuthorize("@ss.hasPermi('pro:type:add')") @PreAuthorize("@ss.hasPermi('pro:type:add')")

View File

@ -24,4 +24,6 @@ public interface DeviceMapper {
DeviceRecord getLastUse(); DeviceRecord getLastUse();
List<DeviceRecord> getRecordList(); List<DeviceRecord> getRecordList();
int getCount(DeviceDto model);
} }

View File

@ -14,4 +14,5 @@ public interface OwnerMapper {
int deleteById(OwnerDto model); int deleteById(OwnerDto model);
int update(OwnerDto model); int update(OwnerDto model);
Integer getCount(OwnerDto model);
} }

View File

@ -13,4 +13,6 @@ public interface ProTypeMapper {
Integer update(ProTypeDto model); Integer update(ProTypeDto model);
Integer getCount(ProTypeDto model); Integer getCount(ProTypeDto model);
List<ProTypeDto> getProType(ProTypeDto model);
} }

View File

@ -11,7 +11,7 @@ import java.util.List;
* @Date2025/11/10 - 10:34 * @Date2025/11/10 - 10:34
*/ */
public interface ProTypeService { public interface ProTypeService {
List<ProTypeDto> getDeviceType(ProTypeDto model); List<ProTypeDto> getProType(ProTypeDto model);
AjaxResult add(ProTypeDto model); AjaxResult add(ProTypeDto model);
AjaxResult delete(ProTypeDto dto); AjaxResult delete(ProTypeDto dto);
AjaxResult update(ProTypeDto model); AjaxResult update(ProTypeDto model);

View File

@ -24,6 +24,11 @@ public class DeviceServiceImpl implements DeviceService {
@Override @Override
public AjaxResult add(DeviceDto model) { public AjaxResult add(DeviceDto model) {
// 查询设备编号是否存在
int count = deviceMapper.getCount(model);
if (count > 0) {
return AjaxResult.error("设备编号已存在");
}
int add = deviceMapper.add(model); int add = deviceMapper.add(model);
if (add > 0) { if (add > 0) {
return AjaxResult.success("新增成功"); return AjaxResult.success("新增成功");
@ -44,6 +49,11 @@ public class DeviceServiceImpl implements DeviceService {
@Override @Override
public AjaxResult update(DeviceDto model) { public AjaxResult update(DeviceDto model) {
// 查询设备编号是否存在
int count = deviceMapper.getCount(model);
if (count > 0) {
return AjaxResult.error("设备编号已存在");
}
int add = deviceMapper.update(model); int add = deviceMapper.update(model);
if (add > 0) { if (add > 0) {
return AjaxResult.success("修改成功"); return AjaxResult.success("修改成功");

View File

@ -26,6 +26,11 @@ public class OwnerServiceImpl implements OwnerService {
@Override @Override
public AjaxResult add(OwnerDto model) { public AjaxResult add(OwnerDto model) {
// 验证名称是否重复
Integer count = ownerMapper.getCount(model);
if (count > 0) {
return AjaxResult.error("名称已重复,请重新修改");
}
int add = ownerMapper.add(model); int add = ownerMapper.add(model);
if (add > 0) { if (add > 0) {
return AjaxResult.success("新增成功"); return AjaxResult.success("新增成功");
@ -46,6 +51,11 @@ public class OwnerServiceImpl implements OwnerService {
@Override @Override
public AjaxResult update(OwnerDto model) { public AjaxResult update(OwnerDto model) {
// 验证名称是否重复
Integer count = ownerMapper.getCount(model);
if (count > 0) {
return AjaxResult.error("名称已重复,请重新修改");
}
int update = ownerMapper.update(model); int update = ownerMapper.update(model);
if (update > 0) { if (update > 0) {
return AjaxResult.success("修改成功"); return AjaxResult.success("修改成功");

View File

@ -23,8 +23,8 @@ public class ProTypeServiceImpl implements ProTypeService {
private ProTypeMapper proTypeMapper; private ProTypeMapper proTypeMapper;
@Override @Override
public List<ProTypeDto> getDeviceType(ProTypeDto model) { public List<ProTypeDto> getProType(ProTypeDto model) {
return proTypeMapper.getDeviceType(model); return proTypeMapper.getProType(model);
} }
@Override @Override

View File

@ -50,22 +50,37 @@
</delete> </delete>
<select id="get" resultType="com.bonus.waterdesign.domain.DeviceDto"> <select id="get" resultType="com.bonus.waterdesign.domain.DeviceDto">
select * from tb_device where id = #{id} select
</select> device_name as deviceName,
device_type as deviceType,
device_code as deviceCode,
user_id as userId,
status,
remark
from tb_device
where id = #{id}
</select>
<select id="list" resultType="com.bonus.waterdesign.domain.DeviceDto"> <select id="list" resultType="com.bonus.waterdesign.domain.DeviceDto">
select * from tb_device select
where del_flag = 0 device_name as deviceName,
<if test="deviceCode != null and deviceCode != ''"> device_type as deviceType,
and device_code like concat ('%',#{deviceCode},'%') device_code as deviceCode,
</if> user_id as userId,
<if test="status != null and status != ''"> status,
and status = #{status} remark
</if> from tb_device
<if test="deviceType != null and deviceType != ''"> where del_flag = 0
and device_type = #{deviceType} <if test="deviceCode != null and deviceCode != ''">
</if> and device_code like concat ('%',#{deviceCode},'%')
</select> </if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="deviceType != null and deviceType != ''">
and device_type = #{deviceType}
</if>
</select>
<select id="getDeviceType" resultType="com.bonus.waterdesign.domain.SelectDto"> <select id="getDeviceType" resultType="com.bonus.waterdesign.domain.SelectDto">
select id, select id,
@ -107,4 +122,11 @@
</if> </if>
order by id desc order by id desc
</select> </select>
<select id="getCount" resultType="java.lang.Integer">
select count(1) from tb_device
where del_flag = 0 and device_code = #{deviceCode}
<if test="id != null and id != ''">
and id != #{id}
</if>
</select>
</mapper> </mapper>

View File

@ -26,7 +26,7 @@
from tb_device_type from tb_device_type
<where> <where>
<if test="typeName != null and typeName != ''"> <if test="typeName != null and typeName != ''">
and type_name like concat('%', #{typeName}, '%') type_name like concat('%', #{typeName}, '%')
</if> </if>
</where> </where>
</select> </select>

View File

@ -36,11 +36,17 @@
</delete> </delete>
<select id="list" resultType="com.bonus.waterdesign.domain.OwnerDto"> <select id="list" resultType="com.bonus.waterdesign.domain.OwnerDto">
select * from tb_owner select id,unit_name as unitName,unit_man as unitMan,phone,address,remark from tb_owner
<where> <where>
<if test="unitName != null and unitName != ''" > <if test="unitName != null and unitName != ''" >
and unit_Name like concat('%', #{unitName}, '%') and unit_Name like concat('%', #{unitName}, '%')
</if> </if>
</where> </where>
</select> </select>
<select id="getCount" resultType="java.lang.Integer">
select count(1) from tb_owner where unit_name = #{unitName}
<if test="id != null and id != ''">
and id != #{id}
</if>
</select>
</mapper> </mapper>

View File

@ -5,32 +5,32 @@
<mapper namespace="com.bonus.waterdesign.mapper.ProTypeMapper"> <mapper namespace="com.bonus.waterdesign.mapper.ProTypeMapper">
<insert id="add"> <insert id="add">
insert into tb_device_type(type_name,remark) values(#{typeName},#{remark}) insert into tb_pro_type(type_name,remark) values(#{typeName},#{remark})
</insert> </insert>
<update id="update"> <update id="update">
update tb_device_type update tb_pro_type
set type_name=#{typeName}, set type_name=#{typeName},
remark=#{remark} remark=#{remark}
where id = #{id} where id = #{id}
</update> </update>
<delete id="delete"> <delete id="delete">
delete from tb_device_type where id=#{id} delete from tb_pro_type where id=#{id}
</delete> </delete>
<select id="getDeviceType" resultType="com.bonus.waterdesign.domain.ProTypeDto">
select * from tb_device_type
<where>
<if test="typeName != null and typeName != ''">
and type_name like concat('%', #{typeName}, '%')
</if>
</where>
</select>
<select id="getCount" resultType="java.lang.Integer"> <select id="getCount" resultType="java.lang.Integer">
select count(1) from tb_device_type where type_name = #{typeName} select count(1) from tb_pro_type where type_name = #{typeName}
<if test="id != null and id != ''"> <if test="id != null and id != ''">
and id != #{id} and id != #{id}
</if> </if>
</select> </select>
<select id="getProType" resultType="com.bonus.waterdesign.domain.ProTypeDto">
select id,type_name as typeName,remark from tb_pro_type
<where>
<if test="typeName != null and typeName != ''">
type_name like concat('%', #{typeName}, '%')
</if>
</where>
</select>
</mapper> </mapper>