入职接口
parent
b4a1915aaf
commit
3783ad2dc7
@ -0,0 +1,9 @@
|
||||
package com.weaver.seconddev.jcl.common.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface CommonService {
|
||||
Map<String, Object> updateCommon(Map<String,Object> param);
|
||||
|
||||
Map<String, Object> insertCommon(Map<String,Object> param);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.weaver.seconddev.jcl.common.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.weaver.seconddev.jcl.common.service.CommonService;
|
||||
import com.weaver.seconddev.jcl.organization.util.CommonUtils;
|
||||
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CommonServiceImpl implements CommonService {
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateCommon(Map<String, Object> param) {
|
||||
String tableName = CommonUtils.null2String(param.get("tableName"));
|
||||
Map<String,Object> dataMap = (Map<String,Object>)param.get("dataMap");
|
||||
Map<String,Object> condition = (Map<String,Object>)param.get("condition");
|
||||
String updateSql = "update "+tableName+" set ";
|
||||
for (Map.Entry<String,Object> e : dataMap.entrySet()){
|
||||
if (e.getValue() !=null && !"".equals(e.getValue()) && !e.getKey().equals("id")){
|
||||
updateSql = updateSql + e.getKey()+"='"+e.getValue().toString()+"',";
|
||||
}
|
||||
}
|
||||
updateSql = updateSql.substring(0,updateSql.length()-1) + " where 1=1";
|
||||
for (Map.Entry<String,Object> e : condition.entrySet()){
|
||||
updateSql = updateSql + " and "+ e.getKey()+"='"+e.getValue()+"'";
|
||||
}
|
||||
log.info("makeUpdateSql : [{}]",updateSql);
|
||||
return databaseUtils.execute(updateSql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> insertCommon(Map<String, Object> param) {
|
||||
|
||||
Map<String,String> dataMap = (Map<String,String>)param.get("dataMap");
|
||||
String tableName = CommonUtils.null2String(param.get("tableName"));
|
||||
|
||||
String insertSql = "insert into "+tableName;
|
||||
String key = "(";
|
||||
String value = "(";
|
||||
List<String> dataList = Lists.newArrayList();
|
||||
for (Map.Entry<String,String> e : dataMap.entrySet()){
|
||||
if (e.getValue() != null && !"".equals(e.getValue())){
|
||||
key = key + e.getKey() +",";
|
||||
value = value + "?" +",";
|
||||
dataList.add(e.getValue());
|
||||
}
|
||||
}
|
||||
key = key.substring(0,key.length()-1) + ")";
|
||||
value = value.substring(0,value.length()-1)+")";
|
||||
insertSql = insertSql + key +" values "+value;
|
||||
log.debug("makeInsertSql : [{}]",insertSql);
|
||||
log.debug("needInsertDate: [{}]",dataList);
|
||||
return databaseUtils.execute(insertSql,dataList);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.weaver.seconddev.jcl.organization.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* uf_jcl_rzgl
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PendingEmployee {
|
||||
|
||||
private String id;
|
||||
|
||||
private String glyg;
|
||||
}
|
Loading…
Reference in New Issue