NutzCN Logo
问答 一对多插入问题insertWith insertLinks
发布于 122天前 作者 Hamming 227 次浏览 复制 上一个帖子 下一个帖子
标签:
/**
 * 服务费配置表 app_service_fees
 *
 * @author haiming
 * @date 2019-07-18
 */
@Table("app_service_fees")
public class ServiceFees extends BaseModel implements Serializable {
    private static final long serialVersionUID = 1L;

    @Name
    @Column("id")
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    @Prev(els = {@EL("uuid()")})
    private String id;

    /**
     * 名称
     */
    @Column("name")
    @Comment("名称")
    private String name;

    /**
     * 房东收益比例
     */
    @Column("landlord_earnings")
    @Comment("房东收益比例")
    private Double landlordEarnings;

    /**
     * 租客租金比例
     */
    @Column("tenants_rent")
    @Comment("租客租金比例")
    private Double tenantsRent;

    /**
     * 经纪人佣金
     */
    @Column("brokerage_fee")
    @Comment("经纪人佣金")
    private Double brokerageFee;

    /**
     * 默认值
     */
    @Column("defaults")
    @Comment("默认值")
    private boolean defaults;

    @Many(field = "serviceFeesId")
    private List<ServiceFeeItem> serviceFeeItemList;

@Table("app_service_fee_item")
public class ServiceFeeItem extends BaseModel implements Serializable {
    private static final long serialVersionUID = 1L;

    @Name
    @Column("id")
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    @Prev(els = {@EL("uuid()")})
    private String id;

    /**
     * 关联费率id
     */
    @Column("service_fees_id")
    @Comment("关联费率id")
    private String serviceFeesId;

    /**
     * 名称
     */
    @Column("name")
    @Comment("名称")
    private String name;

    /**
     * 值
     */
    @Column("value")
    @Comment("值")
    private Integer value;

    /**
     * 费率
     */
    @Column("rate")
    @Comment("费率")
    private Double rate;

    @One(field = "serviceFeesId")
    private ServiceFees serviceFees;

保存方法是用insertWith,insertLinks 吗
insertWith 的第二个参数是什么呢

			if(Lang.isNotEmpty(items) && Lang.isNotEmpty(serviceFees)) {
				serviceFees.setServiceFeeItemList(Arrays.asList(items));
				serviceFeesService.dao().insertWith(serviceFees,null);
				serviceFeesService.dao().insertLinks(serviceFees.getServiceFeeItemList(), "serviceFeesId");
			}else if(Lang.isNotEmpty(serviceFees)){
				serviceFeesService.insert(serviceFees);
			}
3 回复

正则表达式,匹配@One/@Many的属性名,不是字段,就是标注上诉注解的那个实例属性的名字

添加回复
请先登陆
回到顶部