使用BeanUtils简化代码

master
toesbieya 6 years ago
parent f450f31300
commit 6d821998c1
  1. 12
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/entity/BizDoc.java
  2. 5
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/entity/BizPurchaseInbound.java
  3. 9
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/entity/BizPurchaseOrder.java
  4. 9
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/entity/BizSellOrder.java
  5. 5
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/entity/BizSellOutbound.java
  6. 6
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/vo/DepartmentVo.java
  7. 7
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/vo/ResourceVo.java
  8. 10
      java/cloud/common/src/main/java/cn/toesbieya/jxc/common/model/vo/UserVo.java
  9. 3
      java/cloud/web/web-modules/document/src/main/java/cn/toesbieya/jxc/document/model/vo/PurchaseInboundVo.java
  10. 3
      java/cloud/web/web-modules/document/src/main/java/cn/toesbieya/jxc/document/model/vo/PurchaseOrderVo.java
  11. 3
      java/cloud/web/web-modules/document/src/main/java/cn/toesbieya/jxc/document/model/vo/SellOrderVo.java
  12. 3
      java/cloud/web/web-modules/document/src/main/java/cn/toesbieya/jxc/document/model/vo/SellOutboundVo.java
  13. 3
      java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/controller/SysDepartmentController.java
  14. 11
      java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/model/vo/CustomerVo.java
  15. 11
      java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/model/vo/SupplierVo.java
  16. 2
      java/cloud/web/web-modules/system/src/main/java/cn/toesbieya/jxc/system/service/SysCategoryService.java
  17. 6
      java/local/src/main/java/cn/toesbieya/jxc/model/vo/DepartmentVo.java
  18. 10
      java/local/src/main/java/cn/toesbieya/jxc/model/vo/UserVo.java
  19. 6
      java/local/src/main/java/cn/toesbieya/jxc/service/SysCategoryService.java

@ -18,16 +18,4 @@ public class BizDoc implements Serializable {
private Long vtime;
private Integer status;
private String remark;
public BizDoc(BizDoc doc) {
this.id = doc.getId();
this.cid = doc.getCid();
this.cname = doc.getCname();
this.ctime = doc.getCtime();
this.vid = doc.getVid();
this.vname = doc.getVname();
this.vtime = doc.getVtime();
this.status = doc.getStatus();
this.remark = doc.getRemark();
}
}

@ -11,9 +11,4 @@ import lombok.ToString;
@NoArgsConstructor
public class BizPurchaseInbound extends BizDoc {
private String pid;
public BizPurchaseInbound(BizPurchaseInbound obj) {
super(obj);
this.pid = obj.getPid();
}
}

@ -17,13 +17,4 @@ public class BizPurchaseOrder extends BizDoc {
private Integer finish;
private Long ftime;
private BigDecimal total;
public BizPurchaseOrder(BizPurchaseOrder obj) {
super(obj);
this.sid = obj.getSid();
this.sname = obj.getSname();
this.finish = obj.getFinish();
this.ftime = obj.getFtime();
this.total = obj.getTotal();
}
}

@ -17,13 +17,4 @@ public class BizSellOrder extends BizDoc {
private Integer finish;
private Long ftime;
private BigDecimal total;
public BizSellOrder(BizSellOrder obj) {
super(obj);
this.customerId = obj.getCustomerId();
this.customerName = obj.getCustomerName();
this.finish = obj.getFinish();
this.ftime = obj.getFtime();
this.total = obj.getTotal();
}
}

@ -11,9 +11,4 @@ import lombok.ToString;
@NoArgsConstructor
public class BizSellOutbound extends BizDoc {
private String pid;
public BizSellOutbound(BizSellOutbound obj) {
super(obj);
this.pid = obj.getPid();
}
}

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
@Data
@NoArgsConstructor
@ -14,9 +15,6 @@ public class DepartmentVo extends SysDepartment {
String fullname;
public DepartmentVo(SysDepartment parent) {
this.setId(parent.getId());
this.setPid(parent.getPid());
this.setName(parent.getName());
this.setStatus(parent.getStatus());
BeanUtils.copyProperties(parent, this);
}
}

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
@Data
@NoArgsConstructor
@ -14,10 +15,6 @@ public class ResourceVo extends SysResource {
private String fullname;
public ResourceVo(SysResource parent) {
this.setId(parent.getId());
this.setPid(parent.getPid());
this.setName(parent.getName());
this.setUrl(parent.getUrl());
this.setAdmin(parent.isAdmin());
BeanUtils.copyProperties(parent, this);
}
}

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
import java.util.Set;
@ -21,13 +22,6 @@ public class UserVo extends SysUser {
private Set<Integer> resourceIds;
public UserVo(SysUser parent) {
this.setId(parent.getId());
this.setName(parent.getName());
this.setPwd(parent.getPwd());
this.setRole(parent.getRole());
this.setAvatar(parent.getAvatar());
this.setCtime(parent.getCtime());
this.setAdmin(parent.isAdmin());
this.setStatus(parent.getStatus());
BeanUtils.copyProperties(parent, this);
}
}

@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
import java.util.List;
@ -21,6 +22,6 @@ public class PurchaseInboundVo extends BizPurchaseInbound {
private List<String> deleteImageList;
public PurchaseInboundVo(BizPurchaseInbound parent) {
super(parent);
BeanUtils.copyProperties(parent, this);
}
}

@ -4,6 +4,7 @@ import cn.toesbieya.jxc.common.model.entity.BizPurchaseOrder;
import cn.toesbieya.jxc.common.model.entity.BizPurchaseOrderSub;
import cn.toesbieya.jxc.common.model.entity.RecAttachment;
import lombok.*;
import org.springframework.beans.BeanUtils;
import java.util.List;
@ -18,6 +19,6 @@ public class PurchaseOrderVo extends BizPurchaseOrder {
private List<String> deleteImageList;
public PurchaseOrderVo(BizPurchaseOrder parent) {
super(parent);
BeanUtils.copyProperties(parent, this);
}
}

@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
import java.util.List;
@ -21,6 +22,6 @@ public class SellOrderVo extends BizSellOrder {
private List<String> deleteImageList;
public SellOrderVo(BizSellOrder parent) {
super(parent);
BeanUtils.copyProperties(parent, this);
}
}

@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
import java.util.List;
@ -21,6 +22,6 @@ public class SellOutboundVo extends BizSellOutbound {
private List<String> deleteImageList;
public SellOutboundVo(BizSellOutbound parent) {
super(parent);
BeanUtils.copyProperties(parent, this);
}
}

@ -2,6 +2,7 @@ package cn.toesbieya.jxc.system.controller;
import cn.toesbieya.jxc.common.enumeration.GeneralStatusEnum;
import cn.toesbieya.jxc.common.model.entity.SysDepartment;
import cn.toesbieya.jxc.common.model.vo.DepartmentVo;
import cn.toesbieya.jxc.common.model.vo.Result;
import cn.toesbieya.jxc.system.service.SysDepartmentService;
import org.springframework.util.StringUtils;
@ -19,7 +20,7 @@ public class SysDepartmentController {
@GetMapping("get")
public Result get(boolean all) {
List<SysDepartment> list = departmentService.getAll();
List<DepartmentVo> list = departmentService.getAll();
if (!all) {
list = list
.stream()

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
@Data
@NoArgsConstructor
@ -14,14 +15,6 @@ public class CustomerVo extends SysCustomer {
private String regionName;
public CustomerVo(SysCustomer parent) {
this.setId(parent.getId());
this.setName(parent.getName());
this.setAddress(parent.getAddress());
this.setLinkman(parent.getLinkman());
this.setLinkphone(parent.getLinkphone());
this.setRegion(parent.getRegion());
this.setStatus(parent.getStatus());
this.setCtime(parent.getCtime());
this.setRemark(parent.getRemark());
BeanUtils.copyProperties(parent, this);
}
}

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
@Data
@NoArgsConstructor
@ -14,14 +15,6 @@ public class SupplierVo extends SysSupplier {
private String regionName;
public SupplierVo(SysSupplier parent) {
this.setId(parent.getId());
this.setName(parent.getName());
this.setAddress(parent.getAddress());
this.setLinkman(parent.getLinkman());
this.setLinkphone(parent.getLinkphone());
this.setRegion(parent.getRegion());
this.setStatus(parent.getStatus());
this.setCtime(parent.getCtime());
this.setRemark(parent.getRemark());
BeanUtils.copyProperties(parent, this);
}
}

@ -109,7 +109,7 @@ public class SysCategoryService {
.ne(id != null, SysCategory::getId, id)
);
if (exist != null && exist > 0) {
return "分类【" + category.getName() + "】已存在";
return String.format("分类【%s】已存在", category.getName());
}
Integer cid = category.getId();

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
@Data
@NoArgsConstructor
@ -14,9 +15,6 @@ public class DepartmentVo extends SysDepartment {
String fullname;
public DepartmentVo(SysDepartment parent) {
this.setId(parent.getId());
this.setPid(parent.getPid());
this.setName(parent.getName());
this.setStatus(parent.getStatus());
BeanUtils.copyProperties(parent, this);
}
}

@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;
import java.util.Set;
@ -21,13 +22,6 @@ public class UserVo extends SysUser {
private Set<Integer> resourceIds;
public UserVo(SysUser parent) {
this.setId(parent.getId());
this.setName(parent.getName());
this.setPwd(parent.getPwd());
this.setRole(parent.getRole());
this.setAvatar(parent.getAvatar());
this.setCtime(parent.getCtime());
this.setAdmin(parent.isAdmin());
this.setStatus(parent.getStatus());
BeanUtils.copyProperties(parent,this);
}
}

@ -61,10 +61,12 @@ public class SysCategoryService {
private String check(SysCategory category) {
if (category.getPid() != 0) {
SysCategory parent = categoryMapper.getById(category.getPid());
if (parent == null || parent.getType() == 1) return "父节点状态变更,请刷新后重试";
if (parent == null || parent.getType() == 1) {
return "父节点状态变更,请刷新后重试";
}
}
if (categoryMapper.isNameExist(category.getName(), category.getId())) {
return "分类【" + category.getName() + "】已存在";
return String.format("分类【%s】已存在",category.getName());
}
if (category.getId() != null && category.getType() == 1) {

Loading…
Cancel
Save