Browse Source

【CHG】ID是否为空校验

ZhaoMn 4 năm trước cách đây
mục cha
commit
c485e9ab02

+ 12 - 7
railway-admin/src/main/java/com/railway/web/controller/business/catenary/BusJlgzController.java

@@ -9,12 +9,17 @@ import com.railway.common.core.domain.AjaxResult;
 import com.railway.common.core.page.TableDataInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
 import java.util.List;
+import javax.validation.Valid;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * @author fenghao
@@ -39,7 +44,7 @@ public class BusJlgzController extends BaseController {
 
     @ApiOperation(value = "删除")
     @DeleteMapping("/{ids}")
-    public AjaxResult delete(@PathVariable(value = "ids") String[] ids) {
+    public AjaxResult delete(@PathVariable(value = "ids") Long[] ids) {
         return toAjax(budJlgzService.delete(ids));
     }
 
@@ -51,7 +56,7 @@ public class BusJlgzController extends BaseController {
 
     @ApiOperation(value = "单个")
     @GetMapping(value = {"/", "/{id}"})
-    public AjaxResult getInfo(@PathVariable(value = "id") String id) {
+    public AjaxResult getInfo(@PathVariable(value = "id") Long id) {
         BusJlgz info = budJlgzService.getInfo(id);
         AjaxResult ajax = AjaxResult.success();
         ajax.put("info",info);

+ 0 - 3
railway-business/src/main/java/com/railway/business/catenary/domain/BusJcebGjsfx.java

@@ -14,9 +14,6 @@ import org.hibernate.validator.constraints.Length;
 @EqualsAndHashCode(callSuper = true)
 public class BusJcebGjsfx extends BusJceb{
 
-    @ApiModelProperty(value = "主键", hidden = true)
-    private String id;
-
     @ApiModelProperty(value = "支柱号起点")
     @Length(min = 1, max = 50, message = "【支柱号起点】长度必须介于 {min} 和 {max} 之间")
     private String pillarStart;

+ 2 - 2
railway-business/src/main/java/com/railway/business/catenary/domain/BusJlgzPic.java

@@ -14,10 +14,10 @@ import org.hibernate.validator.constraints.Length;
 public class BusJlgzPic {
 
     @ApiModelProperty(value = "主键")
-    private String id;
+    private Long id;
 
     @ApiModelProperty(value = "base_jlgz表的id")
-    private String jlgzId;
+    private Long jlgzId;
 
     @ApiModelProperty(value = "上传照片url")
     @Length(min = 1, max = 500, message = "【上传照片url】长度必须介于 {min} 和 {max} 之间")

+ 2 - 2
railway-business/src/main/java/com/railway/business/catenary/mapper/BusJlgzMapper.java

@@ -27,7 +27,7 @@ public interface BusJlgzMapper {
     /**
     * 删除
     */
-    int delete(@Param("id") String id);
+    int delete(@Param("id") Long id);
 
     /**
     * 更新
@@ -37,7 +37,7 @@ public interface BusJlgzMapper {
     /**
     * 获取单个
     */
-    BusJlgz getInfo(@Param("id") String id);
+    BusJlgz getInfo(@Param("id") Long id);
 
     /**
     * 查询列表

+ 1 - 1
railway-business/src/main/java/com/railway/business/catenary/mapper/BusJlgzPicMapper.java

@@ -30,7 +30,7 @@ public interface BusJlgzPicMapper {
      * @param jlgzId
      * @return
      */
-    int deleteByJlgzId(@Param("jlgzId") String jlgzId);
+    int deleteByJlgzId(@Param("jlgzId") Long jlgzId);
 
     /**
     * 更新

+ 2 - 2
railway-business/src/main/java/com/railway/business/catenary/service/IBusJlgzService.java

@@ -20,7 +20,7 @@ public interface IBusJlgzService {
     /**
     * 删除
     */
-    int delete(String[] ids);
+    int delete(Long[] ids);
 
     /**
     * 更新
@@ -30,7 +30,7 @@ public interface IBusJlgzService {
     /**
     * 获取单个
     */
-    BusJlgz getInfo(String id);
+    BusJlgz getInfo(Long id);
 
     /**
     * 查询列表

+ 1 - 1
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebLbjghjlServiceImpl.java

@@ -6,9 +6,9 @@ import com.railway.business.catenary.mapper.BusJcebLbjghjlMapper;
 import com.railway.business.catenary.service.IBusJcebLbjghjlService;
 import com.railway.common.enums.DelFlagEnum;
 import com.railway.common.utils.SecurityUtils;
+import com.railway.common.utils.StringUtils;
 import java.util.Date;
 import java.util.List;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 /**

+ 5 - 5
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJlgzServiceImpl.java

@@ -44,7 +44,7 @@ public class BusJlgzServiceImpl implements IBusJlgzService {
         busJlgz.setCreateBy(SecurityUtils.getUsername());
 		busJlgz.setDelFlag(DelFlagEnum.NOT_DELETE.getCode());
 		busJlgzMapper.insert(busJlgz);
-		String jlgzId = busJlgz.getId();
+		Long jlgzId = busJlgz.getId();
 
 		List<BusJlgzPic> pics = busJlgz.getPics();
 		if (CollectionUtils.isNotEmpty(pics)) {
@@ -61,9 +61,9 @@ public class BusJlgzServiceImpl implements IBusJlgzService {
 	*/
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public int delete(String[] ids) {
+	public int delete(Long[] ids) {
 		int r =0;
-		for (String id : ids) {
+		for (Long id : ids) {
 			int j= busJlgzMapper.delete(id);
 			busJlgzPicMapper.deleteByJlgzId(id);
 			r = r + j;
@@ -79,7 +79,7 @@ public class BusJlgzServiceImpl implements IBusJlgzService {
 	public int update(BusJlgz busJlgz) {
 		busJlgz.setUpdateTime(new Date());
     	busJlgz.setUpdateBy(SecurityUtils.getUsername());
-		String jlgzId = busJlgz.getId();
+		Long jlgzId = busJlgz.getId();
 
 		List<BusJlgzPic> pics = busJlgz.getPics();
 		if (CollectionUtils.isNotEmpty(pics)) {
@@ -96,7 +96,7 @@ public class BusJlgzServiceImpl implements IBusJlgzService {
 	* 获取单个
 	*/
 	@Override
-	public BusJlgz getInfo(String id) {
+	public BusJlgz getInfo(Long id) {
 		BusJlgz busJlgz = busJlgzMapper.getInfo(id);
 		if (busJlgz != null) {
 			BusJlgzPic busJlgzPic = new BusJlgzPic();

+ 10 - 0
railway-common/src/main/java/com/railway/common/utils/StringUtils.java

@@ -119,6 +119,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
     return isNull(str) || NULLSTR.equals(str.trim());
   }
 
+  /**
+   * * 判断一个字符串是否为空串
+   *
+   * @param str String
+   * @return true:为空 false:非空
+   */
+  public static boolean isEmpty(Long str) {
+    return isNull(str);
+  }
+
   /**
    * * 判断一个字符串是否为非空串
    *