Commit 67f372b3 authored by 赵啸非's avatar 赵啸非

用户列表更新

parent 481b18b9
package com.mortals.xhx.feign.user;
import com.mortals.xhx.common.pdu.UserPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 用户服务
*
* @author: zxfei
* @date: 2022/5/30 10:40
*/
@FeignClient(name = "base-manager", path = "/base", fallback = UserFeignFallbackFactory.class)
public interface IApiUserFeign extends IFeign {
/**
* 门户登录
*
* @param req
* @return
*/
@PostMapping("/login/login")
String portalLogin(@RequestBody UserPdu req);
}
@Slf4j
@Component
class UserFeignFallbackFactory implements FallbackFactory<IApiUserFeign> {
@Override
public IApiUserFeign create(Throwable t) {
return new IApiUserFeign() {
@Override
public String portalLogin(UserPdu req) {
return null;
}
};
}
}
\ No newline at end of file
package com.mortals.xhx.feign.user;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
/**
* 用户信息业务 Feign接口
* @author zxfei
* @date 2022-07-06
*/
@FeignClient(name = "portal-manager ", path = "/zwfw", fallback = UserFeignFallbackFactory.class)
public interface IUserFeign extends IFeign {
/**
* 查看用户信息业务列表
*
* @param userPdu
* @return
*/
@PostMapping(value = "/user/list")
String list(@RequestBody UserPdu userPdu);
/**
* 查看用户信息业务
*
* @param id
* @return
*/
@GetMapping(value = "/user/info")
String info(@RequestParam(value = "id") Long id);
/**
* 删除用户信息业务
*
* @param ids
* @return
*/
@GetMapping(value = "/user/delete")
String delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/**
* 用户信息业务保存更新
*
* @param userPdu
* @return
*/
@PostMapping(value = "/user/save")
String save(@RequestBody UserPdu userPdu,@RequestHeader("Authorization") String authorization);
@PostMapping(value = "/login/login")
String portalLogin(@RequestBody UserPdu userPdu);
}
@Slf4j
@Component
class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
@Override
public IUserFeign create(Throwable t) {
return new IUserFeign() {
@Override
public String list(UserPdu userPdu) {
return JSON.toJSONString(Rest.fail("暂时无法获取用户信息业务列表,请稍后再试!"));
}
@Override
public String info(Long id) {
return JSON.toJSONString(Rest.fail("暂时无法获取用户信息业务详细,请稍后再试!"));
}
@Override
public String delete(Long[] ids, String authorization) {
return JSON.toJSONString(Rest.fail("暂时无法删除用户信息业务,请稍后再试!"));
}
@Override
public String save(UserPdu userPdu, String authorization) {
return JSON.toJSONString(Rest.fail("暂时无法保存用户信息业务,请稍后再试!"));
}
@Override
public String portalLogin(UserPdu userPdu) {
return JSON.toJSONString(Rest.fail("登录失败!"));
}
};
}
}
package com.mortals.xhx.daemon.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.SendStatusEnum;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.common.utils.SendSmsTask;
import com.mortals.xhx.common.utils.SendTaskThreadPool;
import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendQuery;
import com.mortals.xhx.module.alarm.service.AlarmSmsSendService;
import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 同步用户
*/
@Slf4j
@Service("SyncUserTask")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private IUserFeign userFeign;
@Override
public void excuteTask(ITask task) throws AppException {
String resp = userFeign.list(new UserPdu());
log.info("resp:{}",resp);
JSONObject jsonObject = JSONObject.parseObject(resp);
if (jsonObject.getInteger("code") == 1) {
List<UserPdu> userList = jsonObject.getJSONObject("data").getObject("data", new TypeReference<List<UserPdu>>() {
});
log.info("userList:{}", JSON.toJSONString(userList));
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
......@@ -9,11 +9,11 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.UserPdu;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.common.utils.MemoryPagination;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.user.IApiUserFeign;
import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
......@@ -44,9 +44,9 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
@Autowired
private ISiteFeign siteFeign;
@Autowired
private IApiUserFeign userFeign;
@Autowired
private DeviceService deviceService;
@Autowired
private IUserFeign userFeign;
/**
* 重写带分页的方法
......
......@@ -10,7 +10,6 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.UserPdu;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.user.IApiUserFeign;
import com.mortals.xhx.module.sitestat.model.SitestatEntity;
import com.mortals.xhx.module.sitestat.service.SitestatService;
import lombok.extern.slf4j.Slf4j;
......@@ -37,8 +36,7 @@ public class SitestatController extends BaseCRUDJsonBodyMappingController<Sitest
@Autowired
private IAuthTokenService authTokenService;
@Autowired
private IApiUserFeign userFeign;
@Autowired
private ISiteFeign siteFeign;
......
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