-- [selectDesignFonts]
select * from $table$;

-- [addDesignFont]
insert into $table$ (id, fontName, fontFamily, fontThumbUrl,
voidFlag, fontFilePath, createBy,
createTime, createTimeLong, updateBy,
updateTime, updateTimeLong ) values ( #{id}, #{fontname}, #{fontfamily}, #{fontthumburl},
#{voidflag}, #{fontfilepath}, #{createby},
#{createtime}, #{createtimelong}, #{updateby},
#{updatetime}, #{updatetimelong} );

-- [voidDesignFont]
update $table$ set
voidFlag = #{voidflag},
updateBy = #{updateby},
updateTime = #{updatetime}
where id = #{id};

-- [selectDesignTemplates]
select *
from $table$
-- trim prefix=WHERE prefixOverrides=AND|OR
  -- isNotEmpty voidFlag
    -- if voidFlag >= 0
        voidFlag = #{voidFlag}
    -- end
  -- end
  -- isNotEmpty keyWord
    and (templateName LIKE #{Like:keyWord})
  -- end
  -- isNotEmpty templateName
    and templateName LIKE #{Like:templateName}
  -- end
-- end
-- isEmpty orderBy
order by createTime desc
-- else
order by #{orderBy}
-- end
;

-- [selectDesignTemplateItems]
select * from $table$ where idTemplate = #{idTemplate};

-- [selectDesignOrders]
select *
from $table$
-- trim prefix=WHERE prefixOverrides=AND|OR
  -- isNotEmpty voidFlag
    -- if voidFlag >= 0
        voidFlag = #{voidFlag}
    -- end
  -- end
  -- isNotEmpty userIdentity
     and userIdentity = #{userIdentity}
  -- end
  -- isNotEmpty keyWord
    and (orderName LIKE #{Like:keyWord})
  -- end
  -- isNotEmpty orderName
    and templateName LIKE #{Like:orderName}
  -- end
-- end
-- isEmpty orderBy
order by createTime desc
-- else
order by #{orderBy}
-- end
;

-- [selectDesignOrderItems]
select * from $table$ where idOrder = #{idOrder};

-- [addDesignTemplate]
insert into $table$ (id, templateName, backgroundPath, viewThumbPath,
canvasHeight, canvasWidth, breedHeight,
breedWidth, productIdentity, voidFlag,
jsonContent, createBy, createTime,
createTimeLong, updateBy, updateTime,
updateTimeLong ) values ( #{id}, #{templatename}, #{backgroundpath}, #{viewthumbpath},
#{canvasheight}, #{canvaswidth}, #{breedheight},
#{breedwidth}, #{productidentity}, #{voidflag},
#{jsoncontent}, #{createby}, #{createtime},
#{createtimelong}, #{updateby}, #{updatetime},
#{updatetimelong} );

-- [updateDesignTemplate]
update $table$ set templateName = #{templatename},
jsonContent = #{jsoncontent},
backgroundPath = #{backgroundpath},
canvasHeight = #{canvasheight},
canvasWidth = #{canvaswidth},
breedHeight = #{breedheight},
breedWidth = #{breedwidth},
updateBy = #{updateby},
updateTime = #{updatetime}
where id = #{id};

-- [updateDesignTemplateThumb]
update $table$ set templateName = #{templatename}, viewThumbPath = #{viewthumbpath},
updateBy = #{updateby},
updateTime = #{updatetime}
where id = #{id};

-- [addDesignTemplateItem]
insert into $table$ (id, idTemplate, itemType, locationX,
locationY, sizeWidth, sizeHeight,
rotation, zIndex, jsonContent,
createBy, createTime, createTimeLong,
updateBy, updateTime, updateTimeLong ) values ( #{id}, #{idtemplate}, #{itemtype}, #{locationx},
#{locationy}, #{sizewidth}, #{sizeheight},
#{rotation}, #{zindex}, #{jsoncontent},
#{createby}, #{createtime}, #{createtimelong},
#{updateby}, #{updatetime}, #{updatetimelong} );

-- [deleteDesignTemplateItem]
delete from $table$ where idTemplate = #{id};

-- [voidDesignTemplate]
update $table$ set
voidFlag = #{voidflag},
updateBy = #{updateby},
updateTime = #{updatetime}
where id = #{id};

-- [addDesignOrder]
insert into $table$ (id, idTemplate, userIdentity, orderName,
backgroundPath, viewThumbPath, canvasHeight,
canvasWidth, breedHeight, breedWidth,
productIdentity, pdfDownloadUrl, voidFlag,
jsonContent, createBy, createTime,
createTimeLong, updateBy, updateTime,
updateTimeLong ) values ( #{id}, #{idtemplate}, #{useridentity}, #{ordername},
#{backgroundpath}, #{viewthumbpath}, #{canvasheight},
#{canvaswidth}, #{breedheight}, #{breedwidth},
#{productidentity}, #{pdfdownloadurl}, #{voidflag},
#{jsoncontent}, #{createby}, #{createtime},
#{createtimelong}, #{updateby}, #{updatetime},
#{updatetimelong} );

-- [addDesignOrderItem]
insert into $table$ (id, idOrder, itemType, locationX,
locationY, sizeWidth, sizeHeight,
rotation, zIndex, jsonContent,
createBy, createTime, createTimeLong,
updateBy, updateTime, updateTimeLong ) values ( #{id}, #{idorder}, #{itemtype}, #{locationx},
#{locationy}, #{sizewidth}, #{sizeheight},
#{rotation}, #{zindex}, #{jsoncontent},
#{createby}, #{createtime}, #{createtimelong},
#{updateby}, #{updatetime}, #{updatetimelong} );

-- [updateDesignOrder]
update $table$ set backgroundPath = #{backgroundpath},
canvasHeight = #{canvasheight},
canvasWidth = #{canvaswidth},
breedHeight = #{breedheight},
breedWidth = #{breedwidth},
jsonContent = #{jsoncontent},
updateBy = #{updateby},
updateTime = #{updatetime}
where id = #{id};

-- [pdfCallbackDesignOrder]
update $table$ set pdfDownloadUrl = #{pdfdownloadurl}
where id = #{id};

-- [deleteDesignOrderItem]
delete from $table$ where idOrder = #{id};