...
|
...
|
@@ -8,14 +8,14 @@ import com.google.code.kaptcha.impl.DefaultKaptcha; |
|
|
|
|
|
import com.thoughtworks.xstream.core.util.Base64Encoder;
|
|
|
import com.tianbo.warehouse.controller.response.ResultJson;
|
|
|
import com.tianbo.warehouse.model.ROLE;
|
|
|
import com.tianbo.warehouse.model.Token;
|
|
|
import com.tianbo.warehouse.model.USERS;
|
|
|
import com.tianbo.warehouse.dao.UserRoleMapper;
|
|
|
import com.tianbo.warehouse.model.*;
|
|
|
import com.tianbo.warehouse.security.filter.JwtTokenUtil;
|
|
|
import com.tianbo.warehouse.service.PermissionService;
|
|
|
import com.tianbo.warehouse.service.RoleService;
|
|
|
|
|
|
import com.tianbo.warehouse.service.UserService;
|
|
|
import com.tianbo.warehouse.util.MapToJsonUtil;
|
|
|
import com.tianbo.warehouse.util.RedisUtils;
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
...
|
...
|
@@ -24,12 +24,10 @@ import org.apache.commons.lang.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
|
import java.awt.image.BufferedImage;
|
...
|
...
|
@@ -66,6 +64,9 @@ public class AnonymousController { |
|
|
@Autowired
|
|
|
UserService userService;
|
|
|
|
|
|
@Resource
|
|
|
UserRoleMapper userRoleMapper;
|
|
|
|
|
|
/**
|
|
|
* SSO验证服务票据响应属性名
|
|
|
*/
|
...
|
...
|
@@ -185,7 +186,8 @@ public class AnonymousController { |
|
|
user.setUserStatus(loginUser.getUserStatus());
|
|
|
user.setState(loginUser.getState());
|
|
|
}else {
|
|
|
user.setPassword("sso");
|
|
|
assert loginUser != null;
|
|
|
user.setPassword(loginUser.getPassword());
|
|
|
user.setUserStatus(2);
|
|
|
user.setState(true);
|
|
|
userService.insertSelective(user);
|
...
|
...
|
@@ -235,12 +237,73 @@ public class AnonymousController { |
|
|
String loginName = attributes.getString(LOGIN_NAME);
|
|
|
String userId = attributes.getString(USER_ID);
|
|
|
String realName = attributes.getString("USER_NAME");
|
|
|
String password = attributes.getString("PWD");
|
|
|
log.info("[SSO-AUTH-TICKET-INFO]-用户:{}/{}",loginName,realName);
|
|
|
|
|
|
user.setUsername(loginName);
|
|
|
user.setPassword(password);
|
|
|
// user.setUserId(userId);
|
|
|
}
|
|
|
}
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 资源同步
|
|
|
* @param map
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping(value = "/userSynchronization")
|
|
|
@ResponseBody
|
|
|
public ResultMessage userSynchronization(@RequestBody Map<String, Object> map){
|
|
|
//获取action的值,判断是push数据还是删除数据
|
|
|
String action = map.get("action").toString();
|
|
|
if ("user".equals(map.get("resType").toString())){
|
|
|
MapToJsonUtil jsonUtil = new MapToJsonUtil();
|
|
|
List<SSOUserData> list = jsonUtil.mapToList(map, SSOUserData.class, "data");
|
|
|
// 判断该用户是否存在
|
|
|
int i = 0;
|
|
|
for (SSOUserData userData : list){
|
|
|
log.info("用户信息:{}", userData);
|
|
|
USERS loginUser = userService.loadByUsername(userData.getLOGIN_NAME());
|
|
|
USERS users = new USERS();
|
|
|
users.setUsername(userData.getLOGIN_NAME());
|
|
|
users.setPassword(userData.getPWD());
|
|
|
//todo:统一认证的用户ID与我们的数据类型不匹配 暂时不同步
|
|
|
users.setMobilephone(userData.getMOBILE());
|
|
|
users.setEmail(userData.getEMAIL());
|
|
|
users.setRealname(userData.getUSER_NAME());
|
|
|
users.setCompanyId(73);
|
|
|
users.setUpdatetime(new Date());
|
|
|
if (StringUtils.isEmpty(users.getUsername())){
|
|
|
return new ResultMessage("402","缺少lognin_name字段信息");
|
|
|
}
|
|
|
if ("push".equals(action)) {
|
|
|
if (loginUser != null){
|
|
|
log.info("通过账号为条件更新");
|
|
|
i = userService.updateByUsernameSelective(users);
|
|
|
}else {
|
|
|
if ( StringUtils.isEmpty(users.getPassword())){
|
|
|
return new ResultMessage("402","缺少pwd字段信息");
|
|
|
}
|
|
|
users.setCreattime(new Date());
|
|
|
log.info("账号统一认证用户信息不存在可以 [新增]");
|
|
|
//接口返回userid,roleid73 等于转关运抵管理员
|
|
|
int userId = userService.insertSelective(users);
|
|
|
UserRole userRole = new UserRole(userId,73);
|
|
|
userRoleMapper.insertSelective(userRole);
|
|
|
//todo: 默认权限分配
|
|
|
i= userId;
|
|
|
}
|
|
|
}else if ("recycle".equals(action)){
|
|
|
userService.deleteByUsername(users.getUsername());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return i > 0 ? new ResultMessage("200","资源同步成功"):new ResultMessage("202", "资源同步失败");
|
|
|
}
|
|
|
return new ResultMessage("201","不是用户信息");
|
|
|
}
|
|
|
} |
...
|
...
|
|