Authored by linlong

Merge branch 'channel' of git.yoho.cn:yoho30/yohobuy-union into channel

# By LiQZ
# Via LiQZ
* 'channel' of git.yoho.cn:yoho30/yohobuy-union:
  登录信息提交
Showing 23 changed files with 940 additions and 28 deletions
package com.yoho.unions.channel.restapi;
import com.alibaba.fastjson.JSONObject;
import com.yoho.message.sdk.common.model.SendMessageRspBo;
import com.yoho.message.sdk.service.crm.ISendCrmMessage;
import com.yoho.message.sdk.service.crm.impl.SendCrmMessageImpl;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.request.ChannelMessageRequestBO;
import com.yoho.service.model.union.request.ChannelUserRequest;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.channel.service.ChannelGroupService;
import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.dal.model.ChannelGroup;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -19,8 +16,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
import java.util.Map;
import static com.yoho.unions.common.utils.YHPreconditions.checkNotNull;
/**
* Created by yoho on 2017/2/15.
*/
... ... @@ -32,6 +32,10 @@ public class ChannelGroupRest {
@Autowired
private ChannelGroupService channelGroupService;
@Autowired
private HttpSession session;
@RequestMapping("/queryChannelGroupList")
@ResponseBody
public ApiResponse queryChannelGroupList( ChannelGroupRequestBO channelGroupRequestBO) {
... ... @@ -80,4 +84,21 @@ public class ChannelGroupRest {
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").data(result).build();
}
/**
* 增加分组
*/
@ResponseBody
@RequestMapping("addGroup")
public ApiResponse addGroup(@RequestBody ChannelUserRequest request) {
// 设置系统管理员 ID
// UserInfoBO userInfo = (UserInfoBO) session.getAttribute("userSession");
// checkNotNull(userInfo, "获取当前用户信息失败,请刷新当前页面");
UserInfoBO userInfo = new UserInfoBO();
userInfo.setPid(1);
channelGroupService.saveGroup(request, userInfo);
return new ApiResponse.ApiResponseBuilder().build();
}
}
... ...
... ... @@ -3,6 +3,8 @@ package com.yoho.unions.channel.service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.request.ChannelMessageRequestBO;
import com.yoho.service.model.union.request.ChannelUserRequest;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.dal.model.ChannelGroup;
... ... @@ -20,5 +22,10 @@ public interface ChannelGroupService {
Map<Integer,String> getCondition(String ids);
/**
* 保存分组
*/
void saveGroup(ChannelUserRequest request, UserInfoBO userInfo);
void addBlackList(String mobiles);
}
... ...
package com.yoho.unions.channel.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
... ... @@ -10,12 +9,16 @@ import com.yoho.message.sdk.common.model.SendMessageRspBo;
import com.yoho.message.sdk.service.crm.ISendCrmMessage;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.request.ChannelMessageRequestBO;
import com.yoho.service.model.union.request.ChannelUserRequest;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.service.model.union.response.ChannelGroupRspBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.channel.service.ChannelGroupService;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.dal.*;
import com.yoho.unions.dal.model.*;
import com.yoho.unions.utils.DateUtils;
import com.yoho.unions.utils.MapUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
... ... @@ -314,4 +317,33 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
}
return list;
}
@Override
public void saveGroup(ChannelUserRequest request, UserInfoBO userInfo) {
Map<String, Object> condition = ChannelUserServiceImpl.getCondition(request);
/** 删除 '' 条件 */
MapUtil.filterStringBlankMap(condition);
ChannelGroup group = new ChannelGroup();
group.setName(request.getGroupName());
group.setCreateTime(DateUtil.getCurrentTimeSecond());
group.setUpdateTime(group.getCreateTime());
group.setCreateUser(userInfo.getPid());
// group.setCreateUserName();
// group.setGroupNumber();
channelGroupDAO.insert(group);
/** 保存条件 */
List<ChannelGroupCondition> conditions = condition.entrySet().stream().map(entry -> {
ChannelGroupCondition c = new ChannelGroupCondition();
c.setGroupId(group.getId());
c.setKey(entry.getKey());
// 因为上面过滤过了,这是就不需要判断 null 了
c.setValue(entry.getValue().toString());
return c;
}).collect(Collectors.toList());
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(conditions)) {
channelGroupConditionDAO.insertBatch(conditions);
}
}
}
... ...
... ... @@ -40,23 +40,7 @@ public class ChannelUserServiceImpl implements IChannelUserService, IBusinessExp
@Override
public PageResponseBO<ChannelUserBO> list(ChannelUserRequest request) {
// 设置查询参数
Map<String, Object> condition = Maps.newHashMap();
condition.put("channelSource", request.getChannelSource());
condition.put("channelOrderCode", request.getChannelOrderCode());
condition.put("beginChannelOrderTime", request.getBeginChannelOrderTime());
condition.put("endChannelOrderTime", request.getEndChannelOrderTime());
condition.put("uid", request.getUid());
condition.put("hasUid", request.getHasUid());
condition.put("hasYHOrder", request.getHasYHOrder());
condition.put("yhOrderCode", request.getYhOrderCode());
condition.put("beginYHOrderTime", request.getBeginYHOrderTime());
condition.put("endYHOrderTime", request.getEndYHOrderTime());
condition.put("unionCode", request.getUnionCode());
condition.put("userChannel", request.getUserChannel());
condition.put("beginRegisterTime", request.getBeginRegisterTime());
condition.put("endRegisterTime", request.getEndRegisterTime());
condition.put("beginSmsTime", request.getBeginSmsTime());
condition.put("endSmsTime", request.getEndSmsTime());
Map<String, Object> condition = getCondition(request);
condition.put("ids", StringUtils.isBlank(request.getIds())? null: request.getIds().split(","));
/** 删除 '' 条件 */
... ... @@ -88,6 +72,27 @@ public class ChannelUserServiceImpl implements IChannelUserService, IBusinessExp
return page;
}
protected static Map<String, Object> getCondition(ChannelUserRequest request) {
Map<String, Object> condition = Maps.newHashMap();
condition.put("channelSource", request.getChannelSource());
condition.put("channelOrderCode", request.getChannelOrderCode());
condition.put("beginChannelOrderTime", request.getBeginChannelOrderTime());
condition.put("endChannelOrderTime", request.getEndChannelOrderTime());
condition.put("uid", request.getUid());
condition.put("hasUid", request.getHasUid());
condition.put("hasYHOrder", request.getHasYHOrder());
condition.put("yhOrderCode", request.getYhOrderCode());
condition.put("beginYHOrderTime", request.getBeginYHOrderTime());
condition.put("endYHOrderTime", request.getEndYHOrderTime());
condition.put("unionCode", request.getUnionCode());
condition.put("userChannel", request.getUserChannel());
condition.put("beginRegisterTime", request.getBeginRegisterTime());
condition.put("endRegisterTime", request.getEndRegisterTime());
condition.put("beginSmsTime", request.getBeginSmsTime());
condition.put("endSmsTime", request.getEndSmsTime());
return condition;
}
@Override
public Class getDataClass() {
return ChannelUserBO.class;
... ... @@ -112,4 +117,7 @@ public class ChannelUserServiceImpl implements IChannelUserService, IBusinessExp
throw new ServiceException(e.getCode(), e.getErrorMessage());
}
}
}
... ...
... ... @@ -84,5 +84,10 @@
<groupId>com.yoho.service.model</groupId>
<artifactId>union-service-model</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>com.yoho.tools</groupId>
<artifactId>yohobuy-tools-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
... ...
... ... @@ -49,4 +49,6 @@ public class Constant {
// 批量导入导出文件后缀名定义
public static final String BATCH_FILE_POSTFIX = ".xlsx";
public static final String USER_SESSION = "userSession";
}
... ...
/**
*
*/
package com.yoho.unions.common.enums;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
* @author ping.huang
* 2016年7月25日
*/
public enum CodeEnum {
SUCCESS(200, "成功"),
ERROR(201, "失败"),
DATABASE_TIME_OUT(900, "数据库查询超时"),
SESSION_TIME_OUT(901, "登录超时")
;
private int code;
private String message;
private CodeEnum(int code, String message) {
this.code = code;
this.message = message;
}
public static String getMessageByCode(int code) {
for (CodeEnum e : values()) {
if (code == e.getCode()) {
return e.getMessage();
}
}
return null;
}
/**
* 返回json格式的数据
* @param value
* @return
*/
public static JSONArray toJSON(int value) {
JSONArray arr = new JSONArray();
JSONObject json = null;
for (CodeEnum e : values()) {
json = new JSONObject();
json.put("value", e.getClass());
json.put("text", e.getMessage());
arr.add(json);
}
return arr;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}
... ...
package com.yoho.unions.common.enums;
/**
*
* @author lingjie.meng
* 2016年8月13日
*/
public enum ErpApiEnum {
GETSTORES("/account/dept/query_all", "查询店铺列表"),
GETROLES("/account/role/query_cascade_by_pid", "查询角色列表"),
ADDUSER("/account/profile/add", "新增用户"),
MODIFYUSER("/account/profile/update", "修改用户"),
SETROLE("/account/profile/assign_role", "分配角色"),
UPDATEUSERSTATUS("/account/profile/update_status", "更新账户状态"),
LOGIN("/account/profile/login", "登录"),
GET_ROLE_BY_DEPTID("/account/role/query_by_deptId", "根据部门id,获取角色"),
GET_USER_LIST("/account/profile/query_page", "获取用户列表"),
GET_USER_BY_PID("/account/profile/query_by_id", "根据pid,查询用户");
private String url;
private String name;
private ErpApiEnum(String url, String name) {
this.url = url;
this.name = name;
}
public String getUrl() {
return url;
}
public String getName() {
return name;
}
}
... ...
/**
*
*/
package com.yoho.unions.common.model;
import com.yoho.tools.common.beans.BaseBean;
import java.util.List;
/**
* @author ping.huang
* 2016年9月24日
*/
public class ERPProfileRequestBO extends BaseBean {
/**
*
*/
private static final long serialVersionUID = -6299334332126635127L;
private String password;
private String account;
private String auth_site;
private String truename;
private String staff_code;
private String email;
private Integer dept_id;
private Integer role_id;
private Integer create_id;
private Integer pid;
private String phone;
private List<Integer> pIds;
private Integer status;
private Integer pageNo;
private Integer pageSize;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getAuth_site() {
return auth_site;
}
public void setAuth_site(String auth_site) {
this.auth_site = auth_site;
}
public String getTruename() {
return truename;
}
public void setTruename(String truename) {
this.truename = truename;
}
public String getStaff_code() {
return staff_code;
}
public void setStaff_code(String staff_code) {
this.staff_code = staff_code;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getDept_id() {
return dept_id;
}
public void setDept_id(Integer dept_id) {
this.dept_id = dept_id;
}
public Integer getRole_id() {
return role_id;
}
public void setRole_id(Integer role_id) {
this.role_id = role_id;
}
public Integer getCreate_id() {
return create_id;
}
public void setCreate_id(Integer create_id) {
this.create_id = create_id;
}
public Integer getPid() {
return pid;
}
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<Integer> getpIds() {
return pIds;
}
public void setpIds(List<Integer> pIds) {
this.pIds = pIds;
}
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
... ...
/**
*
*/
package com.yoho.unions.common.model;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.tools.common.beans.BaseBean;
/**
* @author ping.huang
* 2016年8月31日
*/
public class OperatorBean extends BaseBean {
private static final long serialVersionUID = -5982639168101762749L;
private String clientIp;
private UserInfoBO user;
private boolean superUser;
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public UserInfoBO getUser() {
return user;
}
public void setUser(UserInfoBO user) {
this.user = user;
}
public boolean isSuperUser() {
return superUser;
}
public void setSuperUser(boolean superUser) {
this.superUser = superUser;
}
}
... ...
/**
*
*/
package com.yoho.unions.common.restapi;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.core.common.utils.MD5;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.tools.common.beans.Response;
import com.yoho.unions.common.constant.Constant;
import com.yoho.unions.common.enums.CodeEnum;
import com.yoho.unions.common.service.ILoginService;
import com.yoho.unions.common.utils.SessionUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* 描述:
*
* @author ping.huang 2016年3月31日
*/
@Controller
@RequestMapping("/LoginController")
public class LoginController {
static Logger log = LoggerFactory.getLogger(LoginController.class);
@Resource
private ILoginService loginService;
private static String SALT= DynamicPropertyFactory.getInstance().getStringProperty("platform.login.salt", "").get();
@RequestMapping("/loginForPid.do")
public void loginForPid(String pid, String pidMd5, String callbackUrl , HttpServletRequest request, HttpServletResponse response) throws Exception {
log.info("enter login with pid={},pidAes is {},callbackUrl is {}", pid, pidMd5, callbackUrl);
if (StringUtils.isEmpty(pid) || StringUtils.isEmpty(pidMd5)) {
log.warn("loginForPid error. with pid={}, pidMd5={}", pid, pidMd5);
return;
}
UserInfoBO userInfoResponseBO = (UserInfoBO) request.getSession().getAttribute(Constant.USER_SESSION);
if (null != userInfoResponseBO && pid.equals(userInfoResponseBO.getPid())) {
request.setAttribute("pid", pid);
request.getRequestDispatcher(callbackUrl).forward(request, response);
} else if (pidMd5.equals(MD5.md5(pid + SALT))) {
log.info("loginForPid with session is empty. and login start. with pid={}", pid);
Response<UserInfoBO> responseBO = loginService.loginByPid(pid);
if (responseBO != null && responseBO.getCode() == CodeEnum.SUCCESS.getCode()) {
log.info("loginForPid with session is empty. and login success. with pid={}", pid);
// 登录成功,把用户信息存入redis
SessionUtil.getOpera().setUser(responseBO.getData());
request.setAttribute("pid", pid);
request.getSession().setAttribute(Constant.USER_SESSION, responseBO.getData());
request.getRequestDispatcher(callbackUrl).forward(request, response);
}
}
}
/**
* 注销
* @param session
* @return
* @throws Exception
*/
@RequestMapping("/logout.do")
@ResponseBody
public Response<Object> logout(HttpSession session) throws Exception {
log.info("enter logout ");
session.invalidate();
return new Response<>();
}
}
... ...
package com.yoho.unions.common.restapi.interceptor;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.unions.common.constant.Constant;
import com.yoho.unions.common.enums.CodeEnum;
import com.yoho.unions.common.model.OperatorBean;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
* 描述:
* 做url权限校验
* @author ping.huang
* 2016年4月11日
*/
public class UrlInterceptor implements HandlerInterceptor {
//免过滤列表(不管有没有session都可以访问)
private List<String> firstNoFilterList = new ArrayList<String>();
//第二级免过滤列表(只要有session就都可以访问)
private List<String> secondNoFilterList = new ArrayList<String>();
//超级管理员账号
private List<String> superManagerList = new ArrayList<String>();
Logger log = LoggerFactory.getLogger(UrlInterceptor.class);
private static final ThreadLocal<OperatorBean> localOpera = new ThreadLocal<>();
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
String url = (String) request.getAttribute("javax.servlet.include.request_uri");
if (StringUtils.isEmpty(url)) {
url = request.getRequestURI();
}
log.info("url is {}.",url);
OperatorBean opera = new OperatorBean();
opera.setClientIp(request.getRemoteAddr());
localOpera.set(opera);
String lastName = url.substring(url.lastIndexOf("/") + 1);
log.info("lastName is {}.",lastName);
//只拦截*.do
if (!lastName.endsWith(".do")) {
return true;
}
//第一层免过滤
if (StringUtils.isEmpty(lastName) || firstNoFilterList.contains(lastName)) {
return true;
}
//过滤session失效的
//UserInfoResponseBO user = loginSessionUtil.getLoginSession(request);
UserInfoBO user = (UserInfoBO) request.getSession().getAttribute(Constant.USER_SESSION);
if (user == null) {
log.warn("session 过期,重新登录,lastName is {}.",lastName);
response.setStatus(CodeEnum.SESSION_TIME_OUT.getCode());
return false;
}
//loginSessionUtil.setLoginSession(user, request, Integer.parseInt(user.getPid()));
opera.setUser(user);
/*SysUserResponseBO user = (SysUserResponseBO) request.getSession().getAttribute(ShopsConstant.USER_SESSION);
if (user == null) {
log.warn("session 过期,重新登录");
response.setStatus(CodeEnum.SESSION_TIME_OUT.getCode());
return false;
}
//第二层免过滤
if (secondNoFilterList.contains(lastName)) {
return true;
}*/
// //超级管理员
// if (ConfigFactory.getSysConfig().getSuperManagerList().contains(user.getLoginName())) {
// arg2.doFilter(arg0, arg1);
// return;
// }
// //按照权限过滤
// List<SysMenuBean> userMenu = (List<SysMenuBean>) request.getSession().getAttribute(Constant.USER_MENU_LIST);
// String[] arr = null;
// for (SysMenuBean menu : userMenu) {
// if (!StringUtils.isEmpty(menu.getMenuUrl()) && menu.getMenuUrl().indexOf(lastName) >= 0) {
// arg2.doFilter(arg0, arg1);
// return;
// }
// if (!StringUtils.isEmpty(menu.getExtraUrl())) {
// arr = menu.getExtraUrl().split(",");
// for (String s : arr) {
// if (s.equals(lastName)) {
// arg2.doFilter(arg0, arg1);
// return;
// }
// }
// }
// }
// log.warn("你没有权限访问【"+ url +"】");
// response.sendRedirect(request.getContextPath() + "/login.html");
return true;
}
public static OperatorBean getLocalOpera(){
return localOpera.get();
}
@Override
public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3) throws Exception {
localOpera.remove();
}
@Override
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception {
// TODO Auto-generated method stub
}
public void setFirstNoFilterList(List<String> firstNoFilterList) {
this.firstNoFilterList = firstNoFilterList;
}
public void setSecondNoFilterList(List<String> secondNoFilterList) {
this.secondNoFilterList = secondNoFilterList;
}
public void setSuperManagerList(List<String> superManagerList) {
this.superManagerList = superManagerList;
}
public List<String> getSuperManagerList() {
return superManagerList;
}
}
... ...
/**
*
*/
package com.yoho.unions.common.service;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.tools.common.beans.Response;
/**
* @author ping.huang
* 2016年8月1日
*/
public interface ILoginService {
Response<UserInfoBO> loginByPid(String pid);
}
... ...
/**
*
*/
package com.yoho.unions.common.service.impl;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.tools.common.beans.Response;
import com.yoho.unions.common.service.ILoginService;
import com.yoho.unions.common.utils.ErpApiServiceHelper;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Map;
/**
* @author ping.huang
* 2016年8月1日
*/
@Service
public class LoginServiceImpl implements ILoginService {
private static final String erpURL = "http://serve.yohobuy.com";
private static Logger log = LoggerFactory.getLogger(LoginServiceImpl.class);
@Value("${admin.login.url}")
private String adminLoginUrl;
@Resource
private ErpApiServiceHelper erpApiServiceHelper;
@SuppressWarnings("unchecked")
private void setUser(Map<String, Object> map, UserInfoBO user) {
if (MapUtils.isEmpty(map)) {
return;
}
Map<String, Object> data = (Map<String, Object>) map.get("data");
Map<String, Object> auth = (Map<String, Object>) data.get("auth");
user.setAccount((String) auth.get("account"));
user.setAuth_site((String) auth.get("auth_site"));
user.setCreate_date((String) auth.get("create_date"));
user.setCreate_id((String) auth.get("create_id"));
user.setCreate_time((String) auth.get("create_time"));
user.setDept_id((String) auth.get("dept_id"));
user.setEmail((String) auth.get("email"));
user.setExpires((String) auth.get("expires"));
user.setIdentity((String) auth.get("identity"));
user.setLogin_time((String) auth.get("login_time"));
user.setLogout_time((String) auth.get("logout_time"));
user.setPhone((String) auth.get("phone"));
user.setPid((Integer) auth.get("pid"));
user.setRole_id((String) auth.get("role_id"));
user.setStaff_code((String) auth.get("staff_code"));
user.setStatus((String) auth.get("status"));
user.setSupplier_id(Integer.parseInt(auth.get("supplier_id").toString()) );
user.setTruename((String) auth.get("truename"));
}
@Override
public Response<UserInfoBO> loginByPid(String pid) {
log.info("loginByPid with pid is {}.", pid);
UserInfoBO user = erpApiServiceHelper.getUserByPid(pid);
if(user == null){
return new Response<>();
}
log.info("loginByPid userInfoResponseBO is {}.", user);
return new Response<>(user);
}
}
... ...
package com.yoho.unions.common.utils;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.tools.common.beans.Response;
import com.yoho.unions.common.enums.CodeEnum;
import com.yoho.unions.common.enums.ErpApiEnum;
import com.yoho.unions.common.model.ERPProfileRequestBO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class ErpApiServiceHelper {
static Logger log = LoggerFactory.getLogger(ErpApiServiceHelper.class);
@Resource
private RestTemplate restTemplate;
private static String ERP_DOMAIN = DynamicPropertyFactory.getInstance().getStringProperty("erp.domain", "").get();
/**
* 根据pid,查询用户
* @param pid
* @return
*/
@SuppressWarnings("unchecked")
public UserInfoBO getUserByPid(String pid) {
log.info("getUserByPid with pid={}", pid);
ERPProfileRequestBO profile = new ERPProfileRequestBO();
profile.setPid(Integer.parseInt(pid));
Response<Map<String, Object>> resp = restTemplate.postForObject(ERP_DOMAIN + ErpApiEnum.GET_USER_BY_PID.getUrl(), profile, Response.class);
if (resp == null || resp.getCode() != CodeEnum.SUCCESS.getCode()) {
log.warn("getUserByPid error with pid={}", pid);
return null;
}
UserInfoBO user = toSysUserResponse(resp.getData());
return user;
}
/**
* 查询用户列表
* @param request
* @return
*/
@SuppressWarnings("unchecked")
public List<UserInfoBO> getUsersByPids(List<Integer> pids) {
log.info("getUsers with pids={}", pids == null ? 0 : pids.size());
if (CollectionUtils.isEmpty(pids)) {
log.warn("getUsersByPids error. pids is empty");
return null;
}
ERPProfileRequestBO profile = new ERPProfileRequestBO();
profile.setpIds(pids);
profile.setPageNo(1);
profile.setPageSize(pids.size());
Response<Map<String, Object>> resp = restTemplate.postForObject(ERP_DOMAIN + ErpApiEnum.GET_USER_LIST.getUrl(), profile, Response.class);
if (resp == null || resp.getCode() != CodeEnum.SUCCESS.getCode()) {
log.warn("getUsers error with pids={}", pids.size());
return null;
}
Map<String, Object> map = resp.getData();
if (MapUtils.isEmpty(map)) {
log.warn("getUsersList error. result is empty. with pids={}", pids.size());
return null;
}
List<Map<String, Object>> records = (List<Map<String, Object>>) map.get("records");
if (CollectionUtils.isEmpty(records)) {
return null;
}
List<UserInfoBO> list = new ArrayList<>();
for (Map<String, Object> m : records) {
list.add(toSysUserResponse(m));
}
return list;
}
/**
* 对象转换
*
* @param map
* @return
*/
private UserInfoBO toSysUserResponse(Map<String, Object> map) {
if (MapUtils.isEmpty(map)) {
return null;
}
UserInfoBO bo = new UserInfoBO();
bo.setCreate_time(MapUtils.getString(map, "create_time"));
bo.setEmail(MapUtils.getString(map, "email"));
bo.setAccount(MapUtils.getString(map, "account"));
bo.setPhone(MapUtils.getString(map, "phone"));
bo.setPid(MapUtils.getInteger(map, "pid"));
bo.setRole_id(MapUtils.getString(map, "role_id"));
bo.setStatus(MapUtils.getString(map, "status"));
bo.setTruename(MapUtils.getString(map, "truename"));
bo.setAuth_site(MapUtils.getString(map, "auth_site"));
bo.setCreate_date(MapUtils.getString(map, "create_date"));
bo.setCreate_id(MapUtils.getString(map, "create_id"));
bo.setDept_id(MapUtils.getString(map, "dept_id"));
bo.setExpires(MapUtils.getString(map, "expires"));
bo.setIdentity(MapUtils.getString(map, "identity"));
bo.setLogin_time(MapUtils.getString(map, "login_time"));
bo.setLogout_time(MapUtils.getString(map, "logout_time"));
bo.setStaff_code(MapUtils.getString(map, "staff_code"));
return bo;
}
}
... ...
package com.yoho.unions.common.utils;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.tools.common.utils.SpringContextUtil;
import com.yoho.unions.common.model.OperatorBean;
import com.yoho.unions.common.restapi.interceptor.UrlInterceptor;
/**
* @author hp
* 2014-03-11
*/
public class SessionUtil {
/**
* 判断用户是否是超级管理员
* @param loginName
* @return
*/
public static boolean isSuperManager(String loginName) {
UrlInterceptor urlInterceptor = SpringContextUtil.getBean("urlInterceptor", UrlInterceptor.class);
return urlInterceptor.getSuperManagerList().contains(loginName);
}
/**
* 获取登录的用户信息
*
*/
public static UserInfoBO getSessionUser() {
return getOpera().getUser();
}
/**
* 获取当前操作者信息
*
*/
public static OperatorBean getOpera() {
return UrlInterceptor.getLocalOpera();
}
}
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.ChannelGroupCondition;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface IChannelGroupConditionDAO {
... ... @@ -11,6 +13,8 @@ public interface IChannelGroupConditionDAO {
int insertSelective(ChannelGroupCondition record);
int insertBatch(@Param("records") Collection<ChannelGroupCondition> records);
ChannelGroupCondition selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ChannelGroupCondition record);
... ...
... ... @@ -39,6 +39,13 @@
values (#{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{key,jdbcType=VARCHAR},
#{value,jdbcType=VARCHAR})
</insert>
<insert id="insertBatch">
insert into channel_group_condition (group_id, `key`, `value`) values
<foreach collection="records" item="item" index="index" separator=",">
(#{item.groupId,jdbcType=INTEGER}, #{item.key,jdbcType=VARCHAR}, #{item.value,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelGroupCondition" >
insert into channel_group_condition
<trim prefix="(" suffix=")" suffixOverrides="," >
... ...
... ... @@ -29,7 +29,7 @@
delete from channel_group
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroup" >
<insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true" >
insert into channel_group (id, name, group_number,
create_time, create_user, create_userName,
sms_number, send_time, send_user,
... ...
... ... @@ -87,4 +87,10 @@ rabbit_message_center_password = yoho
rabbit_message_center_vhost = yoho
################## Import Export #####################
file.saveDir=D:\\Data
\ No newline at end of file
file.saveDir=D:\\Data
platform.login.salt=yoho9646yoho9646
erp.domain=http://192.168.102.47:9098/erp-gateway-web
admin.login.url=http://192.168.102.211:30012
\ No newline at end of file
... ...
... ... @@ -89,4 +89,8 @@ rabbit_message_center_password = ${rabbit_message_center_password}
rabbit_message_center_vhost = ${rabbit_message_center_vhost}
################## Import Export #####################
file.saveDir=${file.saveDir}
\ No newline at end of file
file.saveDir=${file.saveDir}
platform.login.salt=${platform.login.salt}
erp.domain=${erp.domain}
admin.login.url=${admin.login.url}
\ No newline at end of file
... ...
... ... @@ -90,7 +90,6 @@
<table id="consultTable"></table>
</div>
</div>
<script type="text/javascript">
var checkedItems = [];
$(function () {
... ... @@ -251,6 +250,56 @@
}
});
$("#createGroupButton").linkbutton({
onClick: function () {
var div = $("<div>").appendTo($(window.self.document.body));
window.self.$(div).myDialog({
modal : true,
collapsible : true,
cache : false,
title : "创建分组",
width: 400,
height: 200,
href: contextPath + "/html/channel/createGroup.html",
buttons : [{
text : "保存",
id : "saveUserBtn",
iconCls : "icon-save",
handler : function() {
var param = getParams();
var groupName = $.trim($("#groupName").val());
if (groupName.length == 0) {
window.self.$.messager.alert("提示消息", "请输入分组名称");
return;
}
param['groupName'] = groupName;
$.ajax({
type: "POST",
contentType: "application/json",
url: contextPath + '/channel/addGroup',
data: JSON.stringify(param),
dataType: 'json',
success: function(result) {
window.self.$.messager.alert("提示消息",result.message, "", function () {
window.location.href = contextPath + "/html/channel/channelGroupList.html";
});
window.self.$(div).dialog('close');
}
});
}
}, {
id : "closeBtn",
text : "关闭",
iconCls : "icon-cancel",
handler : function() {
window.self.$(div).dialog('close');
}
}],
});
}
});
});
... ...
<div id="groupDialog">
<form id="createGroupForm" method="post" style="padding-left: 20px; padding-top: 20px;">
<div class="fitem">
<label for="number">人数统计: </label>
<input type="hidden" id="number" name="number" data-options="required:true" />
1000 人
</div>
<div class="fitem" style="padding-top: 10px;">
<label for="groupName">分组名称:</label>
<input class="easyui-validatebox" type="text" id="groupName" name="groupName" data-options="required:true" />
</div>
</form>
</div>
\ No newline at end of file
... ...