ArticleQRCodeDao.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package com.yihu.jk.dao;
  2. import java.sql.SQLException;
  3. import java.sql.Timestamp;
  4. import java.util.List;
  5. import com.common.json.JSONObject;
  6. import com.coreframework.db.DB;
  7. import com.coreframework.db.Sql;
  8. import com.coreframework.remoting.standard.DateOper;
  9. import com.yihu.jk.enums.*;
  10. import com.yihu.jk.utils.StringUtil;
  11. import com.yihu.jk.vo.ArticleQR;
  12. import com.yihu.jk.vo.ArticleStatistic;
  13. import com.yihu.jk.vo.OperationLogVo;
  14. import org.springframework.stereotype.Component;
  15. /**
  16. * 二维码管理表操作
  17. * @author chenzhibin <br> 2017-9-6 下午15:42:30
  18. */
  19. @Component
  20. public class ArticleQRCodeDao {
  21. /**
  22. * 查询二维码管理
  23. * @author chenzhibin <br> 2017-9-6 下午15:44:30
  24. * @throws SQLException
  25. */
  26. public JSONObject queryArticleQRCodeDao() throws SQLException {
  27. Sql sql = DB.me().createSql(ConfigSysSqlNameEnum.getArticleORCode);
  28. JSONObject jo = DB.me().queryForJson(MyDatabaseEnum.JkEduDB, sql);
  29. return jo;
  30. }
  31. /**
  32. * 新增二维码管理
  33. * @author chenzhi <br> 2017-9-6 下午15:45:30
  34. * @param bean
  35. * @throws SQLException
  36. */
  37. public int saveArticleQRCode(ArticleQR bean) throws SQLException {
  38. Timestamp nowTime = DateOper.getNowDateTime();
  39. bean.setInsertTime(nowTime.toString());
  40. bean.setUpdateTime(nowTime.toString());
  41. Sql sql = DB.me().createInsertSql(bean, MyTableEnum.Config_ArticleQRCode);
  42. int key = DB.me().insert(MyDatabaseEnum.JkEduDB, sql);
  43. //保存操作日志
  44. OperationLogVo logBean = new OperationLogVo();
  45. logBean.setUserID(bean.getOperatorId());
  46. logBean.setUserName(bean.getOperatorName());
  47. logBean.setOperationType(OperationLogVo.Constant.OPERATIONLOG_TYPE_ADD);
  48. logBean.setOperationKey(String.valueOf(key));
  49. logBean.setOperationTable(OperationLogVo.Constant.CONFIG_ARTICLEQRCODE);
  50. logBean.setOperationContent(net.sf.json.JSONObject.fromObject(bean).toString());
  51. OperatorLogDao.addLog(logBean);
  52. return 1;
  53. }
  54. /**
  55. * 修改二维码管理
  56. * @author chenzhibin <br> 2017-9-6 下午15:50:30
  57. * @param bean
  58. * @param userId 修改人ID
  59. * @param userName 修改人
  60. * @throws SQLException
  61. */
  62. public int updateArticleQRCode(ArticleQR bean, String userId, String userName) throws SQLException {
  63. Timestamp nowTime = DateOper.getNowDateTime();
  64. bean.setUpdateTime(nowTime.toString());
  65. Sql sql = DB.me().createUpdateSql(bean, MyTableEnum.Config_ArticleQRCode,
  66. "Id = ?");
  67. sql.addParamValue(bean.getId());
  68. int code = DB.me().update(MyDatabaseEnum.JkEduDB, sql);
  69. return code;
  70. }
  71. /************************************************** new ***********************************************************/
  72. /**
  73. *
  74. * @param vo
  75. * @return
  76. * @throws SQLException
  77. */
  78. public ArticleQR getArticleQRDetail(ArticleQR vo) throws SQLException {
  79. Sql sql = DB.me().createSql(ArticleQRSqlNameEnum.getArticleQRDetail);
  80. StringBuilder param = new StringBuilder();
  81. param.append(" and OperatorRoleCode = ? ");
  82. sql.addParamValue(vo.getOperatorRoleCode() );
  83. param.append(" and OperatorRoleLevel = ? ");
  84. sql.addParamValue(vo.getOperatorRoleLevel() );
  85. sql.addVar("@Condition", param.toString());
  86. System.out.printf("getArticleQRDetail:"+sql.toString());
  87. ArticleQR articleQRCode = DB.me().queryForBean(MyDatabaseEnum.JkEduDB, sql,ArticleQR.class);
  88. return articleQRCode;
  89. }
  90. /**
  91. * 修改二维码管理
  92. * @author chenzhibin <br> 2017-9-6 下午15:50:30
  93. * @param bean
  94. * @throws SQLException
  95. */
  96. public int updateArticleQRCode(ArticleQR bean) throws SQLException {
  97. Timestamp nowTime = DateOper.getNowDateTime();
  98. bean.setUpdateTime(nowTime.toString());
  99. Sql sql = DB.me().createUpdateSql(bean, MyTableEnum.Config_ArticleQRCode,
  100. " id = ? ");
  101. sql.addParamValue(bean.getId());
  102. // sql.addParamValue(bean.getOperatorRoleCode());
  103. // sql.addParamValue(bean.getOperatorRoleLevel());
  104. int code = DB.me().update(MyDatabaseEnum.JkEduDB, sql);
  105. return code;
  106. }
  107. public ArticleQR getArticleQRCodeById(ArticleQR vo) throws SQLException {
  108. Sql sql = DB.me().createSql(ArticleQRSqlNameEnum.getArticleQRDetail);
  109. StringBuffer param = new StringBuffer();
  110. if (StringUtil.isNotEmpty(vo.getId())) {
  111. param.append(" and Id = ").append(vo.getId());
  112. }
  113. sql.addVar("@Condition", param.toString());
  114. ArticleQR articleQR = DB.me().queryForBean(MyDatabaseEnum.JkEduDB, sql, ArticleQR.class);
  115. return articleQR;
  116. }
  117. }