common.go 541 B

12345678910111213141516171819202122232425262728293031
  1. package clause
  2. import "git.sxidc.com/go-tools/utils/strutils"
  3. type CommonClause struct {
  4. clause string
  5. args []any
  6. }
  7. func NewCommonClause(clause string, args ...any) CommonClause {
  8. return CommonClause{
  9. clause: clause,
  10. args: args,
  11. }
  12. }
  13. func (clause CommonClause) Clause() (string, error) {
  14. if strutils.IsStringEmpty(clause.clause) {
  15. return "", nil
  16. }
  17. return clause.clause + "\n", nil
  18. }
  19. func (clause CommonClause) Args() []any {
  20. if strutils.IsStringEmpty(clause.clause) {
  21. return make([]any, 0)
  22. }
  23. return clause.args
  24. }