企业管理:编辑和添加时添加后端校验企业名称和税号不能为空

beta
路明慧 1 year ago
parent 43bc101d8c
commit 4bbc952f57
  1. 14
      jianshui-admin/src/main/java/com/jianshui/web/controller/system/CompanyserviceController.java
  2. 11
      jianshui-common/src/main/java/com/jianshui/common/core/controller/BaseController.java

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.jianshui.common.core.domain.entity.Companyservice; import com.jianshui.common.core.domain.entity.Companyservice;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -78,6 +79,12 @@ public class CompanyserviceController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Companyservice companyservice) public AjaxResult add(@RequestBody Companyservice companyservice)
{ {
if (StringUtils.isBlank(companyservice.getSellertax())){
return toAjax("企业税号不能为空",false);
}
if (StringUtils.isBlank(companyservice.getSellername())){
return toAjax("企业名称不能为空",false);
}
return toAjax(companyserviceService.insertCompanyservice(companyservice)); return toAjax(companyserviceService.insertCompanyservice(companyservice));
} }
@ -89,6 +96,13 @@ public class CompanyserviceController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Companyservice companyservice) public AjaxResult edit(@RequestBody Companyservice companyservice)
{ {
if (StringUtils.isBlank(companyservice.getSellertax())){
return toAjax("企业税号不能为空",false);
}
if (StringUtils.isBlank(companyservice.getSellername())){
return toAjax("企业名称不能为空",false);
}
return toAjax(companyserviceService.updateCompanyservice(companyservice)); return toAjax(companyserviceService.updateCompanyservice(companyservice));
} }

@ -143,6 +143,17 @@ public class BaseController
return result ? success() : error(); return result ? success() : error();
} }
/**
* 响应返回结果
*
* @param msg 返回信息
* @return 操作结果
*/
protected AjaxResult toAjax(String msg, boolean result)
{
return result ? AjaxResult.success(msg) : AjaxResult.error(msg);
}
/** /**
* 页面跳转 * 页面跳转
*/ */

Loading…
Cancel
Save