|
|
@@ -2,11 +2,16 @@ package com.usoftchina.saas.commons.service.impl;
|
|
|
|
|
|
import com.usoftchina.saas.commons.dto.InitStatusDTO;
|
|
|
import com.usoftchina.saas.commons.mapper.CommonMapper;
|
|
|
+import com.usoftchina.saas.commons.po.Status;
|
|
|
import com.usoftchina.saas.commons.service.CommonService;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
+import com.usoftchina.saas.utils.DateUtils;
|
|
|
+import com.usoftchina.saas.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
@Service
|
|
|
public class CommonServiceImpl implements CommonService {
|
|
|
|
|
|
@@ -43,4 +48,39 @@ public class CommonServiceImpl implements CommonService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String commonAudit(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman) {
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ if (StringUtils.isEmpty(table) || StringUtils.isEmpty(keyvalue)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String sql = praseSql(table, keyvalue, status, statuscode, auditdate, auditman, companyId);
|
|
|
+ if (null != sql) {
|
|
|
+ commonMapper.commonAudit(sql);
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+
|
|
|
+ private String praseSql(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman, Long companyId) {
|
|
|
+ String sql = "update " + table + " set ";
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ if (!StringUtils.isEmpty(status)) {
|
|
|
+ sb.append(" " + status + " = '" + Status.AUDITED.getDisplay() + "',");
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(statuscode)) {
|
|
|
+ sb.append(" " + statuscode + "='" + Status.AUDITED.name() + "',");
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(auditdate)) {
|
|
|
+ sb.append(" " + auditdate + "='" + DateUtils.format(new Date(), "yyyy-MM-dd") + "',");
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(auditman)) {
|
|
|
+ sb.append(" " + auditman + "='" + BaseContextHolder.getUserName() + "',");
|
|
|
+ }
|
|
|
+ if (sb.length() > 0) {
|
|
|
+ sql = sql + sb.substring(0, sb.length() - 1) + " where " + keyvalue + " and companyId=" + companyId;
|
|
|
+ return sql;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|