+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.controller;
+
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.commons.tools.validator.ValidatorUtils;
+import com.epmet.dto.form.StaffWechatFormDTO;
+import com.epmet.service.StaffWechatService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+
+/**
+ * 工作人员微信关系表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-04-18
+ */
+@RestController
+@RequestMapping("staffwechat")
+public class StaffWechatController {
+
+ @Autowired
+ private StaffWechatService staffWechatService;
+
+ /**
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @Author yinzuomei
+ * @Description 手机验证码登录时记录微信openId与当前用户的关系
+ * @Date 2020/4/18 22:33
+ **/
+ @PostMapping(value = "savestaffwechat")
+ public Result saveStaffWechat(@RequestBody StaffWechatFormDTO formDTO) {
+ ValidatorUtils.validateEntity(formDTO);
+ return staffWechatService.savesaveStaffWechat(formDTO);
+ }
+}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffWechatDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffWechatDao.java
new file mode 100644
index 0000000000..b65f262f94
--- /dev/null
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffWechatDao.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.dto.StaffWechatDTO;
+import com.epmet.entity.StaffWechatEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 工作人员微信关系表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-04-18
+ */
+@Mapper
+public interface StaffWechatDao extends BaseDao {
+ /**
+ * @param userId
+ * @param wxOpenId
+ * @return com.epmet.dto.StaffWechatDTO
+ * @Author yinzuomei
+ * @Description 根据userId+wxOpenId查询记录
+ * @Date 2020/4/18 22:37
+ **/
+ StaffWechatDTO selectByUserIdAndOpenId(@Param("userId") String userId, @Param("wxOpenId") String wxOpenId);
+}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffWechatEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffWechatEntity.java
new file mode 100644
index 0000000000..d2ebd5c411
--- /dev/null
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffWechatEntity.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service;
+
+import com.epmet.commons.mybatis.service.BaseService;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.dto.StaffWechatDTO;
+import com.epmet.dto.form.StaffWechatFormDTO;
+import com.epmet.entity.StaffWechatEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 工作人员微信关系表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-04-18
+ */
+public interface StaffWechatService extends BaseService {
+
+ /**
+ * 默认分页
+ *
+ * @param params
+ * @return PageData
+ * @author generator
+ * @date 2020-04-18
+ */
+ PageData page(Map params);
+
+ /**
+ * 默认查询
+ *
+ * @param params
+ * @return java.util.List
+ * @author generator
+ * @date 2020-04-18
+ */
+ List list(Map params);
+
+ /**
+ * 单条查询
+ *
+ * @param id
+ * @return StaffWechatDTO
+ * @author generator
+ * @date 2020-04-18
+ */
+ StaffWechatDTO get(String id);
+
+ /**
+ * 默认保存
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2020-04-18
+ */
+ void save(StaffWechatDTO dto);
+
+ /**
+ * 默认更新
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2020-04-18
+ */
+ void update(StaffWechatDTO dto);
+
+ /**
+ * 批量删除
+ *
+ * @param ids
+ * @return void
+ * @author generator
+ * @date 2020-04-18
+ */
+ void delete(String[] ids);
+
+ /**
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @Author yinzuomei
+ * @Description 手机验证码登录时记录微信openId与当前用户的关系
+ * @Date 2020/4/18 22:34
+ **/
+ Result savesaveStaffWechat(StaffWechatFormDTO formDTO);
+}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
index a3f8883655..7470edc96d 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
@@ -107,7 +107,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl getCustsomerStaffByPhone(String phone) {
//判断用户是否存在
QueryWrapper wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(phone), FieldConstant.MOBILE, phone);
@@ -122,7 +122,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.FieldConstant;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.dao.StaffWechatDao;
+import com.epmet.dto.StaffWechatDTO;
+import com.epmet.dto.form.StaffWechatFormDTO;
+import com.epmet.entity.StaffWechatEntity;
+import com.epmet.service.StaffWechatService;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 工作人员微信关系表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-04-18
+ */
+@Service
+public class StaffWechatServiceImpl extends BaseServiceImpl implements StaffWechatService {
+ private Logger logger = LogManager.getLogger(getClass());
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, StaffWechatDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, StaffWechatDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String id = (String)params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
+
+ return wrapper;
+ }
+
+ @Override
+ public StaffWechatDTO get(String id) {
+ StaffWechatEntity entity = baseDao.selectById(id);
+ return ConvertUtils.sourceToTarget(entity, StaffWechatDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(StaffWechatDTO dto) {
+ StaffWechatEntity entity = ConvertUtils.sourceToTarget(dto, StaffWechatEntity.class);
+ insert(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(StaffWechatDTO dto) {
+ StaffWechatEntity entity = ConvertUtils.sourceToTarget(dto, StaffWechatEntity.class);
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String[] ids) {
+ // 逻辑删除(@TableLogic 注解)
+ baseDao.deleteBatchIds(Arrays.asList(ids));
+ }
+
+ /**
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @Author yinzuomei
+ * @Description 手机验证码登录时记录微信openId与当前用户的关系
+ * @Date 2020/4/18 22:34
+ **/
+ @Override
+ public Result savesaveStaffWechat(StaffWechatFormDTO formDTO) {
+ StaffWechatDTO staffWechatDTO = baseDao.selectByUserIdAndOpenId(formDTO.getUserId(), formDTO.getWxOpenId());
+ if (null == staffWechatDTO) {
+ StaffWechatDTO staffWechat = ConvertUtils.sourceToTarget(formDTO, StaffWechatDTO.class);
+ this.save(staffWechat);
+ logger.info(String.format("staff_Wechat保存成功,userId[%s],wxOpenId[%s]", formDTO.getUserId(), formDTO.getWxOpenId()));
+ } else {
+ logger.info(String.format("staff_Wechat记录已存在,userId[%s],wxOpenId[%s]", formDTO.getUserId(), formDTO.getWxOpenId()));
+ this.update(staffWechatDTO);
+ }
+ return new Result();
+ }
+
+}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql
index fc7bb25e13..76ffc92239 100644
--- a/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql
+++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql
@@ -10,4 +10,27 @@ alter table customer_staff add column ENABLE_FLAG VARCHAR(20) not null COMMENT
alter table customer_staff add column WORK_TYPE VARCHAR(20) not null comment 'fulltime专职parttime兼职';
-- --2020-04-18
-alter table customer_staff add column CUSTOMER_ID varchar(64) NOT NULL COMMENT '客户Id CUSTOMER.id';
\ No newline at end of file
+alter table customer_staff add column CUSTOMER_ID varchar(64) NOT NULL COMMENT '客户Id CUSTOMER.id';
+
+-- --2020-04-18v2
+CREATE TABLE `staff_wechat` (
+ `ID` varchar(64) NOT NULL COMMENT '唯一标识',
+ `USER_ID` varchar(64) NOT NULL COMMENT '用户Id user.id',
+ `WX_OPEN_ID` varchar(64) NOT NULL COMMENT 'openId',
+ `WX_UNION_ID` varchar(64) DEFAULT NULL COMMENT '微信unionId',
+ `MOBILE` varchar(11) DEFAULT NULL COMMENT '手机号',
+ `NICKNAME` varchar(32) DEFAULT NULL COMMENT '昵称',
+ `SEX` int(11) DEFAULT NULL COMMENT '性别',
+ `HEAD_IMG_URL` varchar(1024) DEFAULT NULL COMMENT '头像',
+ `COUNTRY` varchar(32) DEFAULT NULL COMMENT '国家',
+ `PROVINCE` varchar(32) DEFAULT NULL COMMENT '省份',
+ `CITY` varchar(32) DEFAULT NULL COMMENT '城市',
+ `LANGUAGE` varchar(32) DEFAULT NULL COMMENT '语言',
+ `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除',
+ `REVISION` int(11) NOT NULL COMMENT '乐观锁',
+ `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
+ `CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
+ `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
+ `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='工作人员微信关系表 ';
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffWechatDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffWechatDao.xml
new file mode 100644
index 0000000000..96364611eb
--- /dev/null
+++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffWechatDao.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file