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

-- [addBusinessScript]
insert into $table$
(id, businessName, businessCode,
voidFlag, businessModule, systemFlag, commonFlag,
createBy, createTime,
updateBy, updateTime)
values (
#{id}, #{businessname}, #{businesscode},
#{voidflag}, #{businessmodule}, #{systemflag}, #{commonflag},
#{createby}, #{createtime}, #{updateby},
#{updatetime}
);

-- [updateBusinessScript]
update $table$ set
businessName = #{businessname},
commonFlag = #{commonflag},
updateBy = #{updateby},
updateTime = #{updatetime}
where id = #{id};

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


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

-- [addInquireMainInfo]
       insert into $table$ (id, inquireName, inquireFuncName, inquireType, canExport, queryInPage,
       voidFlag, createBy, createTime,
       updateBy, updateTime ) values ( #{id}, #{inquirename}, #{inquirefuncname}, #{inquiretype}, #{canexport}, #{queryinpage},
#{voidflag}, #{createby}, #{createtime},
#{updateby}, #{updatetime} );

-- [updateInquireMainInfo]
       update $table$ set inquireName = #{inquirename},inquireType = #{inquiretype}, canExport = #{canexport}, queryInPage = #{queryinpage},
       updateBy = #{updateby},
       updateTime = #{updatetime} where id = #{id};

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


-- [selectInquireResultColumn]
select * from $table$
-- trim prefix=WHERE prefixOverrides=AND|OR
   -- if idInquire > 0
       idInquire = #{idInquire}
   -- end
-- end
;

-- [addInquireResultColumn]
insert into $table$ (id, idInquire, idParentColumn, columnName,
                     columnField, columnWidth, visible,
                     hasStatistics, statisticsFormat, linkUrl,
                     sortAsc, createBy, createTime,
                     updateBy, updateTime ) values ( #{id}, #{idinquire}, #{idparentcolumn}, #{columnname},
                                               #{columnfield}, #{columnwidth}, #{visible},
                                               #{hasstatistics}, #{statisticsformat}, #{linkurl},
                                               #{sortasc}, #{createby}, #{createtime},
                                               #{updateby}, #{updatetime} );

-- [updateInquireResultColumn]
       update $table$ set columnName = #{columnname},columnField = #{columnfield},columnWidth = #{columnwidth},
       visible = #{visible},hasStatistics = #{hasstatistics},statisticsFormat = #{statisticsformat}, linkUrl = #{linkurl}, sortAsc = #{sortasc},
       updateBy = #{updateby},
       updateTime = #{updatetime} where id = #{id};

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


-- [selectInquireCondition]
select * from $table$
-- trim prefix=WHERE prefixOverrides=AND|OR
   -- if idInquire > 0
       idInquire = #{idInquire}
   -- end
-- end
;

-- [addInquireCondition]
       insert into $table$ (id, idInquire, conditionName, conditionField,
       dataType, defaultValue, visible,
       selectDicType, sortAsc, createBy,
       createTime,  updateBy,
       updateTime ) values ( #{id}, #{idinquire}, #{conditionname}, #{conditionfield},
#{datatype}, #{defaultvalue}, #{visible},
#{selectdictype}, #{sortasc}, #{createby},
#{createtime},  #{updateby},
#{updatetime} );

-- [updateInquireCondition]
       update $table$ set conditionName = #{conditionname},conditionField = #{conditionfield},dataType = #{datatype},
       defaultValue = #{defaultvalue},visible = #{visible},selectDicType = #{selectdictype},sortAsc = #{sortasc},
       updateBy = #{updateby},
       updateTime = #{updatetime} where id = #{id};

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

-- [deleteInquireResultColumnByMain]
    delete from $table$ where idInquire = #{id};

-- [deleteInquireConditionByMain]
       delete from $table$ where idInquire = #{id};


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

-- [addCompanyInfo]
insert into $table$ (
id, companyName, address, linkMan,
linkPhone, voidFlag, createBy,
createTime, createTimeLong, updateBy,
updateTime, updateTimeLong )
values (
#{id}, #{companyname}, #{address}, #{linkman},
#{linkphone}, #{voidflag}, #{createby},
#{createtime}, #{createtimelong}, #{updateby},
#{updatetime}, #{updatetimelong}
);

-- [updateCompanyInfo]
update $table$ set
companyName = #{companyname},
address = #{address},
linkMan = #{linkman},
linkPhone = #{linkphone},
updateBy = #{updateby},
updateTime = #{updatetime},
updateTimeLong = #{updatetimelong}
where id = #{id};

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