|
@@ -5,6 +5,10 @@ import com.dgtly.common.annotation.ApiPassToken;
|
|
|
import com.dgtly.common.core.controller.ApiBaseController;
|
|
|
import com.dgtly.common.core.domain.AjaxResult;
|
|
|
import com.dgtly.common.core.domain.ParameterObject;
|
|
|
+import com.dgtly.common.utils.http.HttpUtils;
|
|
|
+import com.dgtly.common.utils.security.EncryptPassWordClass;
|
|
|
+import com.dgtly.wxportal.domain.WxBanner;
|
|
|
+import com.dgtly.wxportal.domain.WxMagnet;
|
|
|
import com.dgtly.wxportal.utils.qywxutils.QyWxSendMessageUtil;
|
|
|
import com.dgtly.wxportal.utils.qywxutils.QyWxUserUtil;
|
|
|
import com.dgtly.common.utils.RedisUtil;
|
|
@@ -20,10 +24,13 @@ import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
|
|
|
@Api(tags = "企业微信相关API", description = "提供企业微信相关的AP")
|
|
|
@RequestMapping("wx")
|
|
@@ -46,6 +53,8 @@ public class WxController extends ApiBaseController {
|
|
|
@Autowired
|
|
|
private QyWxSendMessageUtil qyWxSendMessageUtil;
|
|
|
|
|
|
+ @Value(value = "${libang.getUserByTicket}")
|
|
|
+ private String getUserByTicketUrl;
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取微信授权跳转url",notes = "参数:{url:www.baidu.com}")
|
|
@@ -63,7 +72,7 @@ public class WxController extends ApiBaseController {
|
|
|
@ApiOperation(value = "根据微信coed获取用户信息",
|
|
|
notes = "参数:{code:123} code微信跳转回来的携带的用户code" +
|
|
|
"错误:301 当前用户不是当前企业用户成员" +
|
|
|
- "错误:302 当前用户没有绑定")
|
|
|
+ "错误:302 当前用户不属于DIY用户或经销商用户")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
})
|
|
@@ -78,30 +87,12 @@ public class WxController extends ApiBaseController {
|
|
|
return AjaxResult.error(301,"当前用户不是企业成员");
|
|
|
}
|
|
|
userId = json.getString("UserId");
|
|
|
- WxQyUser wxQyUser = qyWxUserUtil.gerUserDetail(userId);
|
|
|
- WxQyUser resWxQyUser = wxQyUserService.selectWxQyUserById(wxQyUser.getUserid());
|
|
|
- if(resWxQyUser==null){
|
|
|
- int i = wxQyUserService.insertWxQyUser(wxQyUser);
|
|
|
- if(i>0){
|
|
|
- return AjaxResult.error(302,"当前用户没有绑定").putKV("wxUserInfo",wxQyUser);
|
|
|
- }else{
|
|
|
- return AjaxResult.error();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(resWxQyUser.getSysUserId()==null){
|
|
|
- return AjaxResult.error(302,"当前用户没有绑定").putKV("wxUserInfo",wxQyUser);
|
|
|
- }
|
|
|
- try{
|
|
|
- wxQyUser.setSysUserId(resWxQyUser.getSysUserId());
|
|
|
-
|
|
|
- wxQyUserService.updateWxQyUser(wxQyUser);
|
|
|
- }catch(Exception e){
|
|
|
- logger.error("更新微信用户信息时出错",e);
|
|
|
- e.printStackTrace();
|
|
|
+ SysUser user = sysUserService.selectUserByLoginName(userId);
|
|
|
+ if(user==null){
|
|
|
+ return AjaxResult.error(302,"当前用户不属于DIY用户或经销商用户");
|
|
|
+ }else{
|
|
|
+ return AjaxResult.success().putKV("sysUser",user);
|
|
|
}
|
|
|
- SysUser user=sysUserService.selectUserById(resWxQyUser.getSysUserId());
|
|
|
- return AjaxResult.success().putKV("wxUser",resWxQyUser).putKV("sysUser",user);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -162,7 +153,64 @@ public class WxController extends ApiBaseController {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "根据立邦微信基建返回的Ticket获取用户信息",notes = "参数:{'Ticket':1}=" +
|
|
|
+ " 错误:301 根据Ticket获取用户信息失败" +
|
|
|
+ "错误:302 当前用户可能不属于此企业" +
|
|
|
+ "错误:303 当前用户可能不属于DIY人员")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
+ })
|
|
|
+ @PostMapping("/getUserByTicket")
|
|
|
+ public Object getUserByTicket(){
|
|
|
+ ParameterObject obj = getParameterObject();
|
|
|
+ obj.checkParameterNotNull("Ticket");
|
|
|
+ JSONObject json =new JSONObject();
|
|
|
+ json.put("Ticket",obj.getString("Ticket"));
|
|
|
+ String res = HttpUtils.sendJsonPost(getUserByTicketUrl,json);
|
|
|
+ logger.info("根据Ticket获取的用户信息为{}",res);
|
|
|
+ json = JSONObject.parseObject(res);
|
|
|
+ if(json.containsKey("Code")&&json.getInteger("Code")==0){
|
|
|
+ if(json.containsKey("Data")&&json.getJSONObject("Data")!=null){
|
|
|
+ json = json.getJSONObject("Data");
|
|
|
+ if(json.containsKey("Number")&&json.getString("Number")!=null&&!json.getString("Number").trim().equals("")){
|
|
|
+ String emplyeeId = json.getString("Number");
|
|
|
+ SysUser user = sysUserService.selectUserByEmplyeeId(emplyeeId);
|
|
|
+ if(user!=null){
|
|
|
+ return AjaxResult.success().putKV("sysUser",user);
|
|
|
+ }else{
|
|
|
+ return AjaxResult.error(303,"当前用户可能不是DIY人员");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return AjaxResult.error(302,"当前用户可能不属于此企业");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.error(301,"根据Ticket获取用户信息失败");
|
|
|
+ }
|
|
|
|
|
|
+ @ApiOperation(value = "根据账户密码获取用户权限",notes = "参数:{'username':'1','password':'xxx'}" +
|
|
|
+ " 错误:301 密码错误" +
|
|
|
+ "错误:302 查无此人")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
+ })
|
|
|
+ @PostMapping("/getUserByPassWord")
|
|
|
+ public Object getUserByPassWord(){
|
|
|
+ ParameterObject obj = getParameterObject();
|
|
|
+ obj.checkParameterNotNull("username,password");
|
|
|
+ String username = obj.getString("username");
|
|
|
+ String password = obj.getString("password");
|
|
|
+ SysUser user = sysUserService.selectUserByLoginName(username);
|
|
|
+ if(user==null){
|
|
|
+ return AjaxResult.error(302,"查无此人");
|
|
|
+ }
|
|
|
+ String pass = EncryptPassWordClass.encryptPassword(user.getLoginName(),password,user.getSalt());
|
|
|
+ if(pass.equals(user.getPassword())){
|
|
|
+ return AjaxResult.success().putKV("sysUser",user);
|
|
|
+ }else{
|
|
|
+ return AjaxResult.error(301,"密码错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|