package com.yihu.jk.dao; import java.sql.SQLException; import java.sql.Timestamp; import java.util.List; import com.common.json.JSONObject; import com.coreframework.db.DB; import com.coreframework.db.Sql; import com.coreframework.remoting.standard.DateOper; import com.yihu.jk.enums.*; import com.yihu.jk.utils.StringUtil; import com.yihu.jk.vo.ArticleQR; import com.yihu.jk.vo.ArticleStatistic; import com.yihu.jk.vo.OperationLogVo; import org.springframework.stereotype.Component; /** * 二维码管理表操作 * @author chenzhibin
2017-9-6 下午15:42:30 */ @Component public class ArticleQRCodeDao { /** * 查询二维码管理 * @author chenzhibin
2017-9-6 下午15:44:30 * @throws SQLException */ public JSONObject queryArticleQRCodeDao() throws SQLException { Sql sql = DB.me().createSql(ConfigSysSqlNameEnum.getArticleORCode); JSONObject jo = DB.me().queryForJson(MyDatabaseEnum.JkEduDB, sql); return jo; } /** * 新增二维码管理 * @author chenzhi
2017-9-6 下午15:45:30 * @param bean * @throws SQLException */ public int saveArticleQRCode(ArticleQR bean) throws SQLException { Timestamp nowTime = DateOper.getNowDateTime(); bean.setInsertTime(nowTime.toString()); bean.setUpdateTime(nowTime.toString()); Sql sql = DB.me().createInsertSql(bean, MyTableEnum.Config_ArticleQRCode); int key = DB.me().insert(MyDatabaseEnum.JkEduDB, sql); //保存操作日志 OperationLogVo logBean = new OperationLogVo(); logBean.setUserID(bean.getOperatorId()); logBean.setUserName(bean.getOperatorName()); logBean.setOperationType(OperationLogVo.Constant.OPERATIONLOG_TYPE_ADD); logBean.setOperationKey(String.valueOf(key)); logBean.setOperationTable(OperationLogVo.Constant.CONFIG_ARTICLEQRCODE); logBean.setOperationContent(net.sf.json.JSONObject.fromObject(bean).toString()); OperatorLogDao.addLog(logBean); return 1; } /** * 修改二维码管理 * @author chenzhibin
2017-9-6 下午15:50:30 * @param bean * @param userId 修改人ID * @param userName 修改人 * @throws SQLException */ public int updateArticleQRCode(ArticleQR bean, String userId, String userName) throws SQLException { Timestamp nowTime = DateOper.getNowDateTime(); bean.setUpdateTime(nowTime.toString()); Sql sql = DB.me().createUpdateSql(bean, MyTableEnum.Config_ArticleQRCode, "Id = ?"); sql.addParamValue(bean.getId()); int code = DB.me().update(MyDatabaseEnum.JkEduDB, sql); return code; } /************************************************** new ***********************************************************/ /** * * @param vo * @return * @throws SQLException */ public ArticleQR getArticleQRDetail(ArticleQR vo) throws SQLException { Sql sql = DB.me().createSql(ArticleQRSqlNameEnum.getArticleQRDetail); StringBuilder param = new StringBuilder(); param.append(" and OperatorRoleCode = ? "); sql.addParamValue(vo.getOperatorRoleCode() ); param.append(" and OperatorRoleLevel = ? "); sql.addParamValue(vo.getOperatorRoleLevel() ); sql.addVar("@Condition", param.toString()); System.out.printf("getArticleQRDetail:"+sql.toString()); ArticleQR articleQRCode = DB.me().queryForBean(MyDatabaseEnum.JkEduDB, sql,ArticleQR.class); return articleQRCode; } /** * 修改二维码管理 * @author chenzhibin
2017-9-6 下午15:50:30 * @param bean * @throws SQLException */ public int updateArticleQRCode(ArticleQR bean) throws SQLException { Timestamp nowTime = DateOper.getNowDateTime(); bean.setUpdateTime(nowTime.toString()); Sql sql = DB.me().createUpdateSql(bean, MyTableEnum.Config_ArticleQRCode, " id = ? "); sql.addParamValue(bean.getId()); // sql.addParamValue(bean.getOperatorRoleCode()); // sql.addParamValue(bean.getOperatorRoleLevel()); int code = DB.me().update(MyDatabaseEnum.JkEduDB, sql); return code; } public ArticleQR getArticleQRCodeById(ArticleQR vo) throws SQLException { Sql sql = DB.me().createSql(ArticleQRSqlNameEnum.getArticleQRDetail); StringBuffer param = new StringBuffer(); if (StringUtil.isNotEmpty(vo.getId())) { param.append(" and Id = ").append(vo.getId()); } sql.addVar("@Condition", param.toString()); ArticleQR articleQR = DB.me().queryForBean(MyDatabaseEnum.JkEduDB, sql, ArticleQR.class); return articleQR; } }