Apply.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.lsw.model;
  2. import com.jfinal.kit.StrKit;
  3. import com.jfinal.plugin.activerecord.Page;
  4. import com.lsw.model.base.BaseApply;
  5. import java.util.List;
  6. /**
  7. * Generated by JFinal.
  8. */
  9. @SuppressWarnings("serial")
  10. public class Apply extends BaseApply<Apply> {
  11. public static final Apply dao = new Apply().dao();
  12. public Page<Apply> jsonList(int page, int row, String name, String sidx, String sord) {
  13. String select = "SELECT a.*,p.name AS processName,u.realName";
  14. StringBuilder sb = new StringBuilder();
  15. sb.append(" FROM tb_apply a");
  16. sb.append(" LEFT JOIN tb_process p ON p.id=a.processId");
  17. sb.append(" LEFT JOIN sys_user u ON u.id=a.userId");
  18. sb.append(" WHERE 1=1");
  19. if (StrKit.notBlank(name)) {
  20. sb.append(" AND a.name like '%" + name + "%'");
  21. }
  22. sb.append(" ORDER BY a." + sidx + " " + sord);
  23. return dao.paginate(page, row, select, sb.toString());
  24. }
  25. public List<Apply> jsonList(int userId,String name) {
  26. StringBuilder sb = new StringBuilder();
  27. sb.append(" SELECT a.*,p.name AS processName,u.realName");
  28. sb.append(" FROM tb_apply a");
  29. sb.append(" LEFT JOIN tb_process p ON p.id=a.processId");
  30. sb.append(" LEFT JOIN sys_user u ON u.id=a.userId");
  31. sb.append(" WHERE 1=1");
  32. if (StrKit.notBlank(name)) {
  33. sb.append(" AND a.name like '%" + name + "%'");
  34. }
  35. sb.append(" AND u.id="+userId);
  36. sb.append(" ORDER BY a.mDate desc");
  37. return dao.find(sb.toString());
  38. }
  39. public List<Apply> jsonList() {
  40. StringBuilder sb = new StringBuilder();
  41. sb.append(" SELECT a.*,p.name AS processName,u.realName");
  42. sb.append(" FROM tb_apply a");
  43. sb.append(" LEFT JOIN tb_process p ON p.id=a.processId");
  44. sb.append(" LEFT JOIN sys_user u ON u.id=a.userId");
  45. sb.append(" ORDER BY a.id DESC");
  46. return dao.find(sb.toString());
  47. }
  48. public Apply selectById(int id) {
  49. StringBuilder sb = new StringBuilder();
  50. sb.append(" SELECT a.*,p.name AS processName,u.realName");
  51. sb.append(" FROM tb_apply a");
  52. sb.append(" LEFT JOIN tb_process p ON p.id=a.processId");
  53. sb.append(" LEFT JOIN sys_user u ON u.id=a.userId");
  54. sb.append(" WHERE a.id=?");
  55. return dao.findFirst(sb.toString(), id);
  56. }
  57. }