From 40ce81b7287fa577b71022ef9a1c0eaed2f9b2f7 Mon Sep 17 00:00:00 2001 From: guo Date: Fri, 1 Dec 2023 14:37:41 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SmartGroutDevController.java | 5 +- .../service/ISmartGroutDevService.java | 4 ++ .../impl/SmartGroutDevServiceImpl.java | 30 ++++++++++ .../controller/SmartTensionDevController.java | 5 +- .../service/ISmartTensionDevService.java | 5 ++ .../impl/SmartTensionDevServiceImpl.java | 31 ++++++++++ .../zhgd/xmgl/security/WebSecurityConfig.java | 2 + .../controller/${entityName}Controller.javai | 5 +- .../service/I${entityName}Service.javai | 4 ++ .../impl/${entityName}ServiceImpl.javai | 57 ++++++++++++------- 10 files changed, 117 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/zhgd/xmgl/modules/smartgrout/controller/SmartGroutDevController.java b/src/main/java/com/zhgd/xmgl/modules/smartgrout/controller/SmartGroutDevController.java index fbaefb621..253745853 100644 --- a/src/main/java/com/zhgd/xmgl/modules/smartgrout/controller/SmartGroutDevController.java +++ b/src/main/java/com/zhgd/xmgl/modules/smartgrout/controller/SmartGroutDevController.java @@ -86,8 +86,7 @@ public class SmartGroutDevController { @ApiOperation(value = "添加智能压浆-设备信息", notes = "添加智能压浆-设备信息", httpMethod = "POST") @PostMapping(value = "/add") public Result add(@RequestBody SmartGroutDev smartGroutDev) { - smartGroutDev.setId(null); - smartGroutDevService.save(smartGroutDev); + smartGroutDevService.add(smartGroutDev); return Result.ok(); } @@ -100,7 +99,7 @@ public class SmartGroutDevController { @ApiOperation(value = "编辑智能压浆-设备信息", notes = "编辑智能压浆-设备信息", httpMethod = "POST") @PostMapping(value = "/edit") public Result edit(@RequestBody SmartGroutDev smartGroutDev) { - smartGroutDevService.updateById(smartGroutDev); + smartGroutDevService.edit(smartGroutDev); return Result.ok(); } diff --git a/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/ISmartGroutDevService.java b/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/ISmartGroutDevService.java index b0809b81f..0c45449e4 100644 --- a/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/ISmartGroutDevService.java +++ b/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/ISmartGroutDevService.java @@ -18,4 +18,8 @@ public interface ISmartGroutDevService extends IService { IPage queryPageList(HashMap paramMap); List queryList(HashMap paramMap); + + void add(SmartGroutDev smartGroutDev); + + void edit(SmartGroutDev smartGroutDev); } diff --git a/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/impl/SmartGroutDevServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/impl/SmartGroutDevServiceImpl.java index c055180ce..20fc9a914 100644 --- a/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/impl/SmartGroutDevServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/smartgrout/service/impl/SmartGroutDevServiceImpl.java @@ -1,15 +1,18 @@ package com.zhgd.xmgl.modules.smartgrout.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.jeecg.common.system.query.QueryGenerator; import com.zhgd.xmgl.modules.smartgrout.entity.SmartGroutDev; import com.zhgd.xmgl.modules.smartgrout.mapper.SmartGroutDevMapper; import com.zhgd.xmgl.modules.smartgrout.service.ISmartGroutDevService; import com.zhgd.xmgl.util.PageUtil; import com.zhgd.xmgl.util.RefUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -25,6 +28,9 @@ import java.util.List; @Service @Transactional(rollbackFor = Exception.class) public class SmartGroutDevServiceImpl extends ServiceImpl implements ISmartGroutDevService { + @Autowired + private SmartGroutDevMapper smartGroutDevMapper; + @Override public IPage queryPageList(HashMap paramMap) { QueryWrapper queryWrapper = getQueryWrapper(paramMap); @@ -40,6 +46,30 @@ public class SmartGroutDevServiceImpl extends ServiceImpl() + .eq(SmartGroutDev::getDevSn, devSn)); + if (dev != null) { + throw new OpenAlertException("设备编号已存在"); + } + smartGroutDev.setId(null); + baseMapper.insert(smartGroutDev); + } + + @Override + public void edit(SmartGroutDev smartGroutDev) { + SmartGroutDev dev = smartGroutDevMapper.selectOne(new LambdaQueryWrapper() + .eq(SmartGroutDev::getDevSn, smartGroutDev.getDevSn()) + .ne(SmartGroutDev::getId, smartGroutDev.getId()) + ); + if (dev != null) { + throw new OpenAlertException("设备编号已存在"); + } + baseMapper.updateById(smartGroutDev); + } + private QueryWrapper getQueryWrapper(HashMap paramMap) { String alias = "sgd."; QueryWrapper queryWrapper = QueryGenerator.initPageQueryWrapper(SmartGroutDev.class, paramMap, alias); diff --git a/src/main/java/com/zhgd/xmgl/modules/smarttension/controller/SmartTensionDevController.java b/src/main/java/com/zhgd/xmgl/modules/smarttension/controller/SmartTensionDevController.java index 49ae89486..f090e51a3 100644 --- a/src/main/java/com/zhgd/xmgl/modules/smarttension/controller/SmartTensionDevController.java +++ b/src/main/java/com/zhgd/xmgl/modules/smarttension/controller/SmartTensionDevController.java @@ -86,8 +86,7 @@ public class SmartTensionDevController { @ApiOperation(value = "添加智能张拉-设备信息", notes = "添加智能张拉-设备信息", httpMethod = "POST") @PostMapping(value = "/add") public Result add(@RequestBody SmartTensionDev smartTensionDev) { - smartTensionDev.setId(null); - smartTensionDevService.save(smartTensionDev); + smartTensionDevService.add(smartTensionDev); return Result.ok(); } @@ -100,7 +99,7 @@ public class SmartTensionDevController { @ApiOperation(value = "编辑智能张拉-设备信息", notes = "编辑智能张拉-设备信息", httpMethod = "POST") @PostMapping(value = "/edit") public Result edit(@RequestBody SmartTensionDev smartTensionDev) { - smartTensionDevService.updateById(smartTensionDev); + smartTensionDevService.edit(smartTensionDev); return Result.ok(); } diff --git a/src/main/java/com/zhgd/xmgl/modules/smarttension/service/ISmartTensionDevService.java b/src/main/java/com/zhgd/xmgl/modules/smarttension/service/ISmartTensionDevService.java index f43808bb6..02764c58b 100644 --- a/src/main/java/com/zhgd/xmgl/modules/smarttension/service/ISmartTensionDevService.java +++ b/src/main/java/com/zhgd/xmgl/modules/smarttension/service/ISmartTensionDevService.java @@ -18,4 +18,9 @@ public interface ISmartTensionDevService extends IService { IPage queryPageList(HashMap paramMap); List queryList(HashMap paramMap); + + void add(SmartTensionDev smartTensionDev); + + void edit(SmartTensionDev smartTensionDev); + } diff --git a/src/main/java/com/zhgd/xmgl/modules/smarttension/service/impl/SmartTensionDevServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/smarttension/service/impl/SmartTensionDevServiceImpl.java index ba919f636..4f6b054b2 100644 --- a/src/main/java/com/zhgd/xmgl/modules/smarttension/service/impl/SmartTensionDevServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/smarttension/service/impl/SmartTensionDevServiceImpl.java @@ -1,8 +1,12 @@ package com.zhgd.xmgl.modules.smarttension.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zhgd.jeecg.common.execption.OpenAlertException; +import com.zhgd.xmgl.modules.smartgrout.entity.SmartGroutDev; import com.zhgd.xmgl.modules.smarttension.entity.SmartTensionDev; import com.zhgd.xmgl.modules.smarttension.mapper.SmartTensionDevMapper; import com.zhgd.xmgl.modules.smarttension.service.ISmartTensionDevService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -26,6 +30,9 @@ import org.springframework.transaction.annotation.Transactional; @Service @Transactional(rollbackFor = Exception.class) public class SmartTensionDevServiceImpl extends ServiceImpl implements ISmartTensionDevService { + @Autowired + private SmartTensionDevMapper smartTensionDevMapper; + @Override public IPage queryPageList(HashMap paramMap) { QueryWrapper queryWrapper = getQueryWrapper(paramMap); @@ -41,6 +48,30 @@ public class SmartTensionDevServiceImpl extends ServiceImpl() + .eq(SmartTensionDev::getDevSn, devSn)); + if (dev != null) { + throw new OpenAlertException("设备编号已存在"); + } + smartTensionDev.setId(null); + baseMapper.insert(smartTensionDev); + } + + @Override + public void edit(SmartTensionDev smartTensionDev) { + SmartTensionDev dev = smartTensionDevMapper.selectOne(new LambdaQueryWrapper() + .eq(SmartTensionDev::getDevSn, smartTensionDev.getDevSn()) + .ne(SmartTensionDev::getId, smartTensionDev.getId()) + ); + if (dev != null) { + throw new OpenAlertException("设备编号已存在"); + } + baseMapper.updateById(smartTensionDev); + } + private QueryWrapper getQueryWrapper(HashMap paramMap) { QueryWrapper queryWrapper = QueryGenerator.initPageQueryWrapper(SmartTensionDev.class, paramMap); queryWrapper.orderByDesc(RefUtil.fieldNameUlc(SmartTensionDev::getId)); diff --git a/src/main/java/com/zhgd/xmgl/security/WebSecurityConfig.java b/src/main/java/com/zhgd/xmgl/security/WebSecurityConfig.java index 7a4a3c9e9..f8eb6d16d 100644 --- a/src/main/java/com/zhgd/xmgl/security/WebSecurityConfig.java +++ b/src/main/java/com/zhgd/xmgl/security/WebSecurityConfig.java @@ -250,6 +250,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers("/xmgl/vehiclePositionData/add").permitAll() .antMatchers("/xmgl/vehiclePositionAlarm/add").permitAll() .antMatchers("/xmgl/vehiclePositionDayRecord/add").permitAll() + .antMatchers("/xmgl/smartTensionData/add").permitAll() + .antMatchers("/xmgl/smartGroutData/add").permitAll() .antMatchers(HttpMethod.OPTIONS, "/**").anonymous() .anyRequest().authenticated() // 剩下所有的验证都需要验证 .and() diff --git a/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai b/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai index 5e7dd34c2..7d6dffd6b 100644 --- a/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai +++ b/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/controller/${entityName}Controller.javai @@ -88,8 +88,7 @@ public class ${entityName}Controller { @ApiOperation(value = "添加${tableVo.ftlDescription}信息", notes = "添加${tableVo.ftlDescription}信息" , httpMethod="POST") @PostMapping(value = "/add") public Result<${entityName}> add(@RequestBody ${entityName} ${entityName?uncap_first}) { - ${entityName?uncap_first}.setId(null); - ${entityName?uncap_first}Service.save(${entityName?uncap_first}); + ${entityName?uncap_first}Service.add(${entityName?uncap_first}); return Result.ok(); } @@ -101,7 +100,7 @@ public class ${entityName}Controller { @ApiOperation(value = "编辑${tableVo.ftlDescription}信息", notes = "编辑${tableVo.ftlDescription}信息" , httpMethod="POST") @PostMapping(value = "/edit") public Result<${entityName}> edit(@RequestBody ${entityName} ${entityName?uncap_first}) { - ${entityName?uncap_first}Service.updateById(${entityName?uncap_first}); + ${entityName?uncap_first}Service.edit(${entityName?uncap_first}); return Result.ok(); } diff --git a/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai b/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai index 49c713d4a..856af3808 100644 --- a/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai +++ b/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/I${entityName}Service.javai @@ -17,4 +17,8 @@ public interface I${entityName}Service extends IService<${entityName}> { IPage<${entityName}> queryPageList(HashMap paramMap); List<${entityName}> queryList(HashMap paramMap); + + void add(${entityName} ${entityName?uncap_first}); + + void edit(${entityName} ${entityName?uncap_first}); } diff --git a/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai b/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai index c3d27353b..b4ccb0892 100644 --- a/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai +++ b/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai @@ -24,29 +24,42 @@ import org.springframework.transaction.annotation.Transactional; @Service @Transactional(rollbackFor = Exception.class) public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service { - @Override - public IPage<${entityName}> queryPageList(HashMap paramMap) { - QueryWrapper<${entityName}> queryWrapper = getQueryWrapper(paramMap); - Page<${entityName}> page = PageUtil.getPage(paramMap); - IPage<${entityName}> pageList = this.page(page, queryWrapper); - pageList.setRecords(dealList(pageList.getRecords())); - return pageList; - } + @Autowired + private ${entityName}Mapper ${entityName?uncap_first}Mapper; + @Override + public IPage<${entityName}> queryPageList(HashMap paramMap) { + QueryWrapper<${entityName}> queryWrapper = getQueryWrapper(paramMap); + Page<${entityName}> page = PageUtil.getPage(paramMap); + IPage<${entityName}> pageList = this.page(page, queryWrapper); + pageList.setRecords(dealList(pageList.getRecords())); + return pageList; + } - @Override - public List<${entityName}> queryList(HashMap paramMap) { - QueryWrapper<${entityName}> queryWrapper = getQueryWrapper(paramMap); - return dealList(this.list(queryWrapper)); - } + @Override + public List<${entityName}> queryList(HashMap paramMap) { + QueryWrapper<${entityName}> queryWrapper = getQueryWrapper(paramMap); + return dealList(this.list(queryWrapper)); + } - private QueryWrapper<${entityName}> getQueryWrapper(HashMap paramMap) { - String alias = ""; - QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initPageQueryWrapper(${entityName}.class, paramMap, alias); - queryWrapper.orderByDesc(alias + RefUtil.fieldNameUlc(${entityName}::getId)); - return queryWrapper; - } + private QueryWrapper<${entityName}> getQueryWrapper(HashMap paramMap) { + String alias = ""; + QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initPageQueryWrapper(${entityName}.class, paramMap, alias); + queryWrapper.orderByDesc(alias + RefUtil.fieldNameUlc(${entityName}::getId)); + return queryWrapper; + } - private List<${entityName}> dealList(List<${entityName}> list) { - return list; - } + private List<${entityName}> dealList(List<${entityName}> list) { + return list; + } + + @Override + public void add(${entityName} ${entityName?uncap_first}) { + ${entityName?uncap_first}.setId(null); + baseMapper.insert(${entityName?uncap_first}); + } + + @Override + public void edit(${entityName} ${entityName?uncap_first}) { + baseMapper.updateById(${entityName?uncap_first}); + } }