| | |
| | | package cn.gistack.system.user.sync.controller; |
| | | |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.service.IUserService; |
| | | import cn.gistack.system.user.sync.dto.AccountBean; |
| | | import cn.gistack.system.user.sync.dto.ApiPushDTO; |
| | | import cn.gistack.system.user.sync.util.GenerateUtil; |
| | | import cn.gistack.system.user.sync.util.SecurityUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.IResultCode; |
| | | import org.springblade.core.tool.api.R; |
| | |
| | | @AllArgsConstructor |
| | | public class UserPushController { |
| | | |
| | | private final IUserService userService; |
| | | |
| | | @PostMapping("/userpush") |
| | | public R userPush(ApiPushDTO apiPushDTO) { |
| | | String syncData = SecurityUtil.decryptAES(apiPushDTO.getSyncData(),apiPushDTO.getSign()); |
| | | List<AccountBean> accountBeanList = JSONArray.parseArray(syncData, AccountBean.class); |
| | | |
| | | // List<AccountBean> accountBeanList = JSONArray.parseArray(GenerateUtil.generateSyncData(), AccountBean.class); |
| | | |
| | | //循环list |
| | | accountBeanList.forEach(accountBean -> { |
| | | //判断手机号是否在库中 |
| | | User params = new User(); |
| | | params.setPhone(accountBean.getPrincipalId()); |
| | | User one = userService.getOne(Condition.getQueryWrapper(params)); |
| | | |
| | | if (one == null){ |
| | | //不在,看status状态,若为1则不操作。0添加进库 |
| | | if (accountBean.getStatus().equals("0")){ |
| | | |
| | | User saveUser = new User(); |
| | | //设置id为手机号 |
| | | saveUser.setId(Long.parseLong(accountBean.getPrincipalId())); |
| | | //账号为手机号 |
| | | saveUser.setAccount(accountBean.getPrincipalId()); |
| | | saveUser.setPhone(accountBean.getPrincipalId()); |
| | | //设置姓名 |
| | | saveUser.setRealName(accountBean.getAttributes().get("realName")); |
| | | //设置部门(默认给省) |
| | | saveUser.setDeptId("420000000000"); |
| | | //设置角色(权限与市州水库管理业务人员一致) |
| | | saveUser.setRoleId("1688732764750766082"); |
| | | //设置租户id |
| | | saveUser.setTenantId("000000"); |
| | | userService.save(saveUser); |
| | | } |
| | | }else { |
| | | //在,看status状态,若为1则删除用户。0更新? |
| | | if (accountBean.getStatus().equals("1")){ |
| | | userService.removeUser(accountBean.getPrincipalId()); |
| | | } |
| | | } |
| | | }); |
| | | return R.data(apiPushDTO.getTimestamp()); |
| | | } |
| | | |