liuliang
parent
767a5759ca
commit
58fa293e44
@ -0,0 +1,8 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="hrm-attendance">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/hrm_attendance</output-path>
|
||||
<root id="archive" name="hrm-attendance.jar">
|
||||
<element id="module-output" name="hrm-attendance" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
package com.api.attendance.common;
|
||||
|
||||
import com.engine.common.web.CommonAction;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path("/operate/common")
|
||||
public class CommonActionApi extends CommonAction{
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.api.attendance.persongroup.web;
|
||||
|
||||
import com.engine.attendance.persongroup.web.PersonGroupAction;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path("/attendance/persongroup")
|
||||
@Slf4j
|
||||
public class PersonGroupActionApi extends PersonGroupAction {
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package com.util;
|
||||
|
||||
import com.cloudstore.dev.api.bean.MessageBean;
|
||||
import com.cloudstore.dev.api.bean.MessageType;
|
||||
import com.cloudstore.dev.api.util.Util_Message;
|
||||
import com.engine.dto.BaseResult;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.BaseBean;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 消息中心
|
||||
*/
|
||||
@Slf4j
|
||||
public class SendEmMessage {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userIdsSet 接收人id 必填
|
||||
* @param title 标题
|
||||
* @param context 内容
|
||||
* @param pcLinkUrl PC端链接
|
||||
* @param linkMobileUrl 移动端链接
|
||||
*/
|
||||
public static void sendEmMessage(Set<String> userIdsSet,int messageType,int creater, String title,String context,String pcLinkUrl,String linkMobileUrl){
|
||||
MessageType type = MessageType.newInstance(messageType); // 消息来源(见文档第四点补充 必填)
|
||||
|
||||
try {
|
||||
MessageBean messageBean = Util_Message.createMessage(type, userIdsSet, title, context, pcLinkUrl, linkMobileUrl);
|
||||
messageBean.setCreater(creater);// 创建人id
|
||||
|
||||
Util_Message.store(messageBean);
|
||||
} catch (IOException e) {
|
||||
log.error("sendEmMessage error: [{}]",e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static BaseResult sendWxMessage(String chatId,String messageContent){
|
||||
BaseBean baseBean = new BaseBean();
|
||||
//发送消息接口
|
||||
String sendMessageToWxGroupUrl = baseBean.getPropValue("weComConf","sendMessageToWxGroupUrl");
|
||||
Map<String,Object> sendMessageParamMap = Maps.newHashMap();
|
||||
sendMessageParamMap.put("chatid",chatId);
|
||||
sendMessageParamMap.put("msgtype","markdown");
|
||||
Map<String,String> content = Maps.newHashMap();
|
||||
content.put("content",messageContent);
|
||||
sendMessageParamMap.put("markdown",content);
|
||||
Gson gson = new Gson();
|
||||
BaseResult baseResult = gson.fromJson(TokenUtil.post(sendMessageToWxGroupUrl,gson.toJson(sendMessageParamMap)),(Type) BaseResult.class);
|
||||
return baseResult;
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.util;
|
||||
|
||||
import com.cloudstore.dev.api.util.Util_DataCache;
|
||||
import com.engine.dto.TokenResult;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class TokenUtil {
|
||||
|
||||
private static final int timeOutSecond = 3600;
|
||||
|
||||
/**
|
||||
* 配置文件名称
|
||||
*/
|
||||
private static final String confFileName = "weComConf";
|
||||
|
||||
private static BaseBean baseBean = new BaseBean();
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
public static final String TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
|
||||
|
||||
private static String corpid = "";
|
||||
|
||||
private static String corpsecret = "";
|
||||
|
||||
static {
|
||||
corpid = baseBean.getPropValue(confFileName,"corpid");
|
||||
corpsecret = baseBean.getPropValue(confFileName,"corpsecret");
|
||||
// Util_DataCache.setObjVal("corpid",corpid);
|
||||
// Util_DataCache.setObjVal("corpsecret",corpsecret);
|
||||
}
|
||||
|
||||
public static String post(String url,String paramJson){
|
||||
String token = Util.null2String(Util_DataCache.getObjVal("wx_access_token"));
|
||||
if ("".equals(token)){
|
||||
token = getAccessToken();
|
||||
Util_DataCache.setObjVal("wx_access_token",token);
|
||||
}
|
||||
url = url + "?access_token="+token;
|
||||
return HttpRequestUtil.doPost(url,paramJson);
|
||||
}
|
||||
|
||||
|
||||
public static String getAccessToken(){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("corpid",corpid);
|
||||
map.put("corpsecret",corpsecret);
|
||||
// map.put("corpid","wx22cd58d9bee18c0f");
|
||||
// map.put("corpsecret","n4ueR_AnNWXtmYpwr01dRA6i2v9kephxRKbW23n_ZTM");
|
||||
|
||||
String response = HttpRequestUtil.doGet(TOKEN_URL,map);
|
||||
TokenResult tokenResult = gson.fromJson(response,(Type) TokenResult.class);
|
||||
if ("0".equals(tokenResult.getErrcode())){
|
||||
return tokenResult.getAccess_token();
|
||||
}else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.engine.attendance.persongroup.service;
|
||||
|
||||
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface PersonGroupService {
|
||||
Map<String,Object> getHrmCondition(Map<String,Object> params, User user);
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.engine.attendance.persongroup.service.impl;
|
||||
|
||||
|
||||
import com.engine.attendance.persongroup.service.PersonGroupService;
|
||||
import com.engine.common.util.DbTools;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class PersonGroupServiceImpl extends Service implements PersonGroupService {
|
||||
@Override
|
||||
public Map<String, Object> getHrmCondition(Map<String, Object> params, User user) {
|
||||
//获取字段类型 0:日期类型,1:下拉选择类型,2:手工自由输入类型
|
||||
String type = Util.null2String(params.get("fieldType"));
|
||||
String condition = "";
|
||||
if ("0".equals(type)){
|
||||
condition = " and fieldhtmltype='3' and type=2 ";
|
||||
}else if ("1".equals(type)){
|
||||
condition = " and fieldhtmltype = '5' ";
|
||||
}else if ("2".equals(type)){
|
||||
condition = " and fieldhtmltype <> '3' and fieldhtmltype <> '5' ";
|
||||
}
|
||||
|
||||
Map<String, Object> data = Maps.newHashMap();
|
||||
String sql = "select * from (select t1.fieldid,t2.fieldname,t1.fieldlable,t1.ismand,t2.fielddbtype,t2.fieldhtmltype,t2.type, t1.dmlurl, t1.fieldorder, t1.isuse, t1.isModify,'1' as allowModify, t1.groupid, 1 as allowhide from cus_formfield t1, cus_formdict t2 where t1.fieldid=t2.id and t1.scope='HrmCustomFieldByInfoType' and (t1.scopeid='1' or t1.scopeid='-1' or t1.scopeid='3' ) " +
|
||||
" UNION all " +
|
||||
" select fieldid, fieldname, fieldlabel ,ismand ,fielddbtype ,fieldhtmltype ,type , dmlurl,fieldorder ,isuse ,isModify ,allowModify, groupid, allowhide from hrm_formfield) hrmallfield where groupid in (select id from hrm_fieldgroup where (grouptype = '1' or grouptype = '-1' or grouptype = '3')) ";
|
||||
|
||||
sql = sql +condition+" order by hrmallfield.groupid, hrmallfield.fieldorder ";
|
||||
log.info("sql :[{}]",sql);
|
||||
List<Map<String,Object>> dataList = DbTools.getSqlToList(sql);
|
||||
sql = "select fieldid,selectvalue,selectname from hrm_selectitem";
|
||||
List<Map<String,Object>> selectItemLists = DbTools.getSqlToList(sql);
|
||||
Map<String, List<Map<String,Object>>> selectItemMap = selectItemLists.stream().collect(Collectors.groupingBy(e -> e.get("fieldid").toString()));
|
||||
log.info("selectItemMap : [{}]",selectItemMap);
|
||||
|
||||
sql = "select type,linkurl from wf_browser_config group by type";
|
||||
List<Map<String,Object>> browserTypeLists = DbTools.getSqlToList(sql);
|
||||
Map<String,String> browserTypeMaps = browserTypeLists.stream().collect(Collectors.toMap(e->e.get("type").toString(),e->e.get("linkurl").toString()));
|
||||
log.info("browserTypeMaps : [{}]",browserTypeMaps);
|
||||
|
||||
for (Map<String,Object> map :dataList){
|
||||
Integer fieldlable = Integer.valueOf(map.get("fieldlable").toString());
|
||||
String showName = SystemEnv.getHtmlLabelName(fieldlable, user.getLanguage());
|
||||
map.put("showName",showName);
|
||||
map.put("linkurl",browserTypeMaps.get(map.get("type").toString()));
|
||||
map.put("selectItems",selectItemMap.get(map.get("fieldid").toString()));
|
||||
}
|
||||
|
||||
data.put("data",dataList);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.engine.attendance.persongroup.web;
|
||||
|
||||
import com.engine.attendance.persongroup.service.PersonGroupService;
|
||||
import com.engine.attendance.persongroup.service.impl.PersonGroupServiceImpl;
|
||||
import com.engine.common.util.ApiReturnTools;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class PersonGroupAction {
|
||||
|
||||
private PersonGroupService basicsetService = ServiceUtil.getService(PersonGroupServiceImpl.class);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("/getHrmCondition")
|
||||
@Produces({"text/plain"})
|
||||
public String getHrmCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request,response);
|
||||
Map<String,Object> paramMap = ParamUtil.request2Map(request);
|
||||
Map<String,Object> dataMap = basicsetService.getHrmCondition(paramMap,user);
|
||||
return ApiReturnTools.success(dataMap);
|
||||
}catch (Exception e){
|
||||
log.error("execute fail,catch error: [{}]",e);
|
||||
return ApiReturnTools.error("500","getHrmCondition error");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.engine.common.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface CommonService {
|
||||
|
||||
Map<String,Object> queryCommon(Map<String,Object> param);
|
||||
|
||||
|
||||
Map<String,Object> updateCommon(Map<String,Object> param);
|
||||
|
||||
Map<String,Object> insertCommon(Map<String,Object> param);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.engine.common.service.impl;
|
||||
|
||||
import com.engine.common.cmd.QueryCommonCmd;
|
||||
import com.engine.common.service.CommonService;
|
||||
import com.engine.common.util.CommonUtil;
|
||||
import com.engine.common.util.DbTools;
|
||||
import com.engine.common.util.Utils;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
public class CommonServiceImpl extends Service implements CommonService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryCommon(Map<String, Object> param) {
|
||||
return commandExecutor.execute(new QueryCommonCmd(param));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateCommon(Map<String, Object> param) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
log.info("updateCommon param:[{}]",param);
|
||||
result.put("result", DbTools.update(CommonUtil.makeUpdateSql(Util.null2String(param.get("tableName")),Utils.resolveMap(Util.null2String(param.get("data"))),Utils.resolveMap(Util.null2String(param.get("condition"))))));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> insertCommon(Map<String, Object> param) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
log.info("insertCommon param:[{}]",param);
|
||||
Map<String,Object> params = Utils.resolveMap(Util.null2String(param.get("params")));
|
||||
String tableName = Util.null2String(params.get("tableName"));
|
||||
params.remove("tableName");
|
||||
result.put("result", DbTools.update(CommonUtil.makeInsertSql(tableName,params)));
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.util;
|
||||
package com.engine.common.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.engine.common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class CommonUtil {
|
||||
/**
|
||||
* 组装insert的sql语句
|
||||
* @param tableName 表名
|
||||
* @param map 列名及对应值
|
||||
* @return
|
||||
*/
|
||||
public static String makeInsertSql(String tableName, Map<String,Object> map){
|
||||
String insertSql = "insert into "+tableName;
|
||||
String key = "(";
|
||||
String value = "(";
|
||||
for (Map.Entry<String,Object> e : map.entrySet()){
|
||||
key = key + e.getKey() +",";
|
||||
value = value + "'"+e.getValue()+"'" +",";
|
||||
}
|
||||
key = key.substring(0,key.length()-1) + ")";
|
||||
value = value.substring(0,value.length()-1)+")";
|
||||
insertSql = insertSql + key +" values "+value;
|
||||
log.info("makeInsertSql :[{}]",insertSql);
|
||||
return insertSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装update的sql语句
|
||||
* @param tableName 表名
|
||||
* @param map 列名及对应值
|
||||
* @param condition 条件
|
||||
* @return
|
||||
*/
|
||||
public static String makeUpdateSql(String tableName, Map<String,Object> map,Map<String,Object> condition){
|
||||
String updateSql = "update "+tableName+" set ";
|
||||
for (Map.Entry<String,Object> e : map.entrySet()){
|
||||
if (e.getValue() !=null && !"".equals(e.getValue())){
|
||||
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 updateSql;
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.util;
|
||||
package com.engine.common.util;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
@ -1,6 +1,5 @@
|
||||
package com.util;
|
||||
package com.engine.common.util;
|
||||
|
||||
import com.sun.jersey.core.util.Base64;
|
||||
import okhttp3.*;
|
||||
import weaver.general.BaseBean;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.util;
|
||||
package com.engine.common.util;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
@ -1,4 +1,4 @@
|
||||
package com.util;
|
||||
package com.engine.common.util;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
@ -0,0 +1,82 @@
|
||||
package com.engine.common.web;
|
||||
|
||||
|
||||
import com.engine.common.service.CommonService;
|
||||
import com.engine.common.service.impl.CommonServiceImpl;
|
||||
import com.engine.common.util.ApiReturnTools;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class CommonAction {
|
||||
|
||||
|
||||
private CommonService basicsetService = ServiceUtil.getService(CommonServiceImpl.class);
|
||||
|
||||
/**
|
||||
* tableName 表名
|
||||
* columns 查询的列名
|
||||
* conditions 查询条件
|
||||
* orderby 排序及limit
|
||||
* @return
|
||||
*/
|
||||
// @GET
|
||||
// @Path("/queryCommon")
|
||||
// @Produces({"text/plain"})
|
||||
// public String getBasicSetInformation(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
// try {
|
||||
// Map<String,Object> paramMap = ParamUtil.request2Map(request);
|
||||
// Map<String,Object> dataMap = basicsetService.queryCommon(paramMap);
|
||||
// return ApiReturnTools.success(dataMap);
|
||||
// }catch (Exception e){
|
||||
// log.error("sync fund status fail,catch error: [{}]",e);
|
||||
// return ApiReturnTools.error("200","查询失败");
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @return
|
||||
// */
|
||||
// @POST
|
||||
// @Path("/updateCommon")
|
||||
// @Produces({"text/plain"})
|
||||
// public String updateCommon(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
// try {
|
||||
// Map<String,Object> paramMap = ParamUtil.request2Map(request);
|
||||
// Map<String,Object> dataMap = basicsetService.updateCommon(paramMap);
|
||||
// return ApiReturnTools.success(dataMap);
|
||||
// }catch (Exception e){
|
||||
// log.error("sync fund status fail,catch error: [{}]",e);
|
||||
// return ApiReturnTools.error("500","修改失败");
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/insertCommon")
|
||||
@Produces({"text/plain"})
|
||||
public String insertCommon(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
Map<String,Object> paramMap = ParamUtil.request2Map(request);
|
||||
Map<String,Object> dataMap = basicsetService.insertCommon(paramMap);
|
||||
return ApiReturnTools.success(dataMap);
|
||||
}catch (Exception e){
|
||||
log.error("sync fund status fail,catch error: [{}]",e);
|
||||
return ApiReturnTools.error("500","新增");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue