Commit aad4a845 by huangZW

Merge branch 'developer' of http://115.159.76.241/haoban3.0/haoban-manage3.0.git into developer

parents d2973927 ddc366a4
......@@ -6,5 +6,16 @@ import com.gic.haoban.manage.api.dto.WxApplicationDTO;
* Created by tgs on 2020/2/22.
*/
public interface WxApplicationApiService {
/**
* 绑定通讯录应用
* @param dto
*/
void addSuite(WxApplicationDTO dto);
/**
* 取消应用授权,暂时只是删除wxapplication应用绑定
* @param corpId
* @param suiteId
*/
void cancelSuite(String corpId, String suiteId);
}
......@@ -20,4 +20,6 @@ public interface WxApplicationMapper {
TabHaobanWxApplication selectBySiteIdAndWxEnterpriseId(@Param("siteId")String siteId, @Param("wxEnterpriseId")String wxEnterpriseId);
TabHaobanWxApplication selectByWxEnterpriseIdAndApplicationType(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("applicationType")int applicationType);
int cancelWxApplication(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("suiteId") String suiteId);
}
\ No newline at end of file
......@@ -12,4 +12,5 @@ public interface WxApplicationService {
TabHaobanWxApplication selectByWxEnterpriseIdAndApplicationType(String wxEnterpriseId, int applicationType);
int cancalWxApplication(String wxEnterpriseId, String suiteId);
}
......@@ -45,5 +45,10 @@ public class WxApplicationServiceImpl implements WxApplicationService {
return mapper.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,applicationType);
}
@Override
public int cancalWxApplication(String wxEnterpriseId, String suiteId) {
return this.mapper.cancelWxApplication(wxEnterpriseId, suiteId);
}
}
......@@ -341,6 +341,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
for(com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list){
if(parentId == departmentDTO.getParentid()){
TabHaobanDepartment exist = this.departmentService.getByWxId(departmentDTO.getId() + "", wxEnterpriseId);
logger.info("分组是否存在:{}", JSON.toJSONString(exist));
if(exist == null){
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
dto.setDepartmentName(departmentDTO.getName());
......
......@@ -97,7 +97,7 @@ public class StaffApiServiceImpl implements StaffApiService {
int index = 0;
for (String string : departmentIdArr) {
TabHaobanDepartment tabs = departmentService.selectById(string);
wxDepartmentIdArrIntegers[0] = Integer.parseInt(tabs.getWxDepartmentId());
wxDepartmentIdArrIntegers[index] = Integer.parseInt(tabs.getWxDepartmentId());
index ++;
}
userDTO.setDepartment(wxDepartmentIdArrIntegers);
......@@ -328,13 +328,16 @@ public class StaffApiServiceImpl implements StaffApiService {
if(application != null) {
UserDTO userDTO = new UserDTO();
userDTO.setCorpid(enterpriseDTO.getCorpid());
List<Integer> wxDepartmentIdArrIntegers = new ArrayList<Integer>();
String[] departmentIdArr = departmentIds.split(",");
Integer[] wxDepartmentIdArrIntegers = new Integer[departmentIdArr.length];
int index = 0;
for (String string : departmentIdArr) {
TabHaobanDepartment tabs = departmentService.selectById(string);
wxDepartmentIdArrIntegers.add(Integer.parseInt(tabs.getWxDepartmentId()));
wxDepartmentIdArrIntegers[index] = Integer.parseInt(tabs.getWxDepartmentId());
index ++;
}
userDTO.setDepartment((Integer[]) wxDepartmentIdArrIntegers.toArray());
userDTO.setDepartment(wxDepartmentIdArrIntegers);
userDTO.setGender("女");
userDTO.setMobile(staffDTO.getPhoneNumber());
userDTO.setName(staffDTO.getStaffName());
......
......@@ -2,7 +2,9 @@ package com.gic.haoban.manage.service.service.out.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.service.WxApplicationService;
import org.apache.logging.log4j.LogManager;
......@@ -19,10 +21,22 @@ public class WxApplicationApiServiceImpl implements WxApplicationApiService{
@Autowired
private WxApplicationService wxApplicationService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Override
public void addSuite(WxApplicationDTO dto) {
TabHaobanWxApplication tab = EntityUtil.changeEntityByJSON(TabHaobanWxApplication.class, dto);
this.wxApplicationService.insert(tab);
}
@Override
public void cancelSuite(String corpId, String suiteId) {
WxEnterpriseDTO enterprise = this.wxEnterpriseApiService.getEnterpriseBycorpId(corpId);
if(enterprise != null){
int i = this.wxApplicationService.cancalWxApplication(enterprise.getWxEnterpriseId(), suiteId);
log.info("取消授权结果:{}", i);
}
log.info("企业未绑定过,{}", corpId);
}
}
......@@ -179,4 +179,10 @@
and status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
</select>
<update id="cancelWxApplication">
update tab_haoban_wx_application
set status_flag = 0
where wx_enterprise_id = #{wxEnterpriseId} and suite_id = #{suiteId} and status_flag = 1
</update>
</mapper>
\ No newline at end of file
package com.gic.haoban.manage.web.controller;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.gic.haoban.common.utils.CheckSmsCodeUtil;
import com.gic.haoban.common.utils.GooglePhoneNumberUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.communicate.api.service.valid.ValidationCodeService;
//import com.gic.haoban.manage.api.dto.StaffDTO;
//import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.redis.data.util.RedisUtil;
import com.gic.reponse.SendSmsResponse;
@RestController
public class SendCodeController extends WebBaseController{
private static Logger logger = LoggerFactory.getLogger(SendCodeController.class);
// @Autowired
// private StaffApiService staffApiService;
//
@Autowired
private ValidationCodeService validationCodeService;
/**
* 验证码发送
*
* @param phoneNumber
* @return
*/
@RequestMapping("/send-code")
public HaobanResponse sendCode(String phoneNumber, @RequestParam(defaultValue = "86") String nationcode,
Integer type, @RequestParam(defaultValue = "0") int isTest,String wxEnterpriseId) {
if (StringUtils.isBlank(phoneNumber) || null == type) {
logger.info("没有phoneNumber!");
return resultResponse(HaoBanErrCode.ERR_5);
}
if(!GooglePhoneNumberUtil.checkPhoneNumber(phoneNumber,nationcode )) {
logger.info("区号或者手机号码不合法:{}-{}", nationcode,phoneNumber);
return resultResponse(HaoBanErrCode.ERR_20);
}
String cacheKey = nationcode+phoneNumber+type;
Object value = RedisUtil.getCache(cacheKey);
if (value!=null && (boolean) value){
logger.info("手机号码:{}-{} 验证码只能一分钟请求一次", nationcode,phoneNumber);
return resultResponse(HaoBanErrCode.ERR_22);
}else {
RedisUtil.setCache(cacheKey, true, 60L);
}
//绑定
if (type == 1) {
// StaffDTO staffDTO = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
// if (staffDTO == null) {
// logger.info("用户不存在:{}-{}", nationcode,phoneNumber);
// return resultResponse(HaoBanErrCode.ERR_8);
// }
}
String smsCode = "";
if(CheckSmsCodeUtil.getCacheSmsCode(nationcode+"-"+phoneNumber, type) != null){
smsCode = (String)CheckSmsCodeUtil.getCacheSmsCode(nationcode+"-"+phoneNumber, type);
}else{
smsCode = CheckSmsCodeUtil.createSMSCode();
CheckSmsCodeUtil.cacheSmsCode( nationcode+"-"+phoneNumber, smsCode, type);
}
logger.info("{}-{} 的 验证码:{}",nationcode,phoneNumber, smsCode);
//非测试
if (isTest != 1) {
SendSmsResponse smsResponse = validationCodeService.sendValidationCode(nationcode,phoneNumber, smsCode);
logger.info("{}-{} 的 验证码 发送结果回执:{}",nationcode,phoneNumber, JSON.toJSONString(smsResponse));
if (!smsResponse.isSuccess()) {
HaobanResponse response = new HaobanResponse();
response.setMessage(smsResponse.getMessage());
response.setErrorCode(HaoBanErrCode.ERR_11.getCode());
return response;
}
return resultResponse(HaoBanErrCode.ERR_1);
} else {
return resultResponse(HaoBanErrCode.ERR_1, smsCode);
}
}
/**
* 验证码校验
*
* @param phoneNumber
* @return
*/
@RequestMapping("/validate-code")
public HaobanResponse validateCode(String phoneNumber, @RequestParam(defaultValue = "86") String nationcode,
String code, int type) {
if (StringUtils.isBlank(phoneNumber) || StringUtils.isBlank(code)) {
logger.info("没有phoneNumber!");
return resultResponse(HaoBanErrCode.ERR_5);
}
boolean b = CheckSmsCodeUtil.checkSmsCode(nationcode+"-"+phoneNumber, code, type);
boolean c = CheckSmsCodeUtil.checkSmsCodeIsDelay(nationcode+"-"+phoneNumber, code, type);
if(!c){
logger.info("phoneNumber:{},code:{} 验证失败,验证码失效",nationcode+"-"+phoneNumber, code);
return resultResponse(HaoBanErrCode.ERR_21);
}else if(!b){
logger.info("phoneNumber:{},code:{} 验证失败,验证码失败",nationcode+"-"+phoneNumber, code);
return resultResponse(HaoBanErrCode.ERR_9);
}else{
return resultResponse(HaoBanErrCode.ERR_1);
}
}
}
......@@ -75,8 +75,8 @@ public class StaffController extends WebBaseController{
}
@RequestMapping("staff-list")
public HaobanResponse staffList(String departmentId,Integer activeFlag,String keyword,BasePageInfo pageInfo){
Page<StaffDTO> page = staffApiService.pageStaff(departmentId,activeFlag,keyword,pageInfo);
public HaobanResponse staffList(String departmentId,Integer activeFlag,String keyWord,BasePageInfo pageInfo){
Page<StaffDTO> page = staffApiService.pageStaff(departmentId,activeFlag,keyWord,pageInfo);
List<StaffDTO> list = page.getResult();
if(list != null) {
for (StaffDTO staffDTO : list) {
......
......@@ -60,6 +60,12 @@ public enum HaoBanErrCode {
* 验证码校验失败
*/
ERR_12(12, "验证码校验失败"),
ERR_20(20, "区号或者手机号码不合法"),
ERR_21(21, "验证码已过期或者错误"),
ERR_22(22, "验证码一分钟只能请求一次"),
ERR_10001(10001,"父部门不存在"),
ERR_10002(10002,"门店类型部门不能新增子节点"),
......
......@@ -42,6 +42,6 @@
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxSuiteApiService" id="qywxSuiteApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxApplicationApiService" id="wxApplicationApiService"/>
<dubbo:reference interface="com.gic.haoban.communicate.api.service.valid.ValidationCodeService" id="validationCodeService"/>
</beans>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment