shiro和redis调整,解决redis管道拥堵问题

yun-zuoyi
alwaysfrin 6 years ago
parent a5f9fc417b
commit 660698802a

@ -1,11 +1,5 @@
package cn.estsh.i3plus.core.api.iservice.base;
import cn.estsh.i3plus.pojo.mes.MachineFactory;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @Description : service
* @Reference :
@ -15,7 +9,7 @@ import java.util.List;
**/
public interface IDataSimpleService {
void saveMachineFactory(MachineFactory machineFactory);
//void saveMachineFactory(MachineFactory machineFactory);
/*@Transactional
void updateMachineFactoryNameById(long id, String factoryName);

@ -50,7 +50,7 @@ public class DemoAuthController extends CoreBaseController {
AuthUtil.setSessionObject("languageCode",languageCode);
return new ResultBean(true,"");
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + ",so:" + e.getErrorSolution());
return new ResultBean(false,e.getErrorDetail() + "-[解决]" + e.getErrorSolution());
}
}
@ -66,7 +66,7 @@ public class DemoAuthController extends CoreBaseController {
AuthUtil.logout();
return new ResultBean(true,"");
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + ",so:" + e.getErrorSolution());
return new ResultBean(false,e.getErrorDetail() + "-[解决]" + e.getErrorSolution());
}
}
@ -91,7 +91,7 @@ public class DemoAuthController extends CoreBaseController {
return new ResultBean(true,"",sUser);
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + ",so:" + e.getErrorSolution());
return new ResultBean(false,e.getErrorDetail() + "-[解决]" + e.getErrorSolution());
}
}

@ -7,11 +7,10 @@ import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.i3plus.pojo.mes.MachineFactory;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.ResultBean;
import com.rabbitmq.client.Channel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -22,7 +21,9 @@ import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.IOException;
@ -66,7 +67,7 @@ public class DemoRedisMqController extends CoreBaseController{
@ApiOperation(value="缓存",notes="放入数据")
public ResultBean putCache(){
//放入缓存
redisCore.putObject("machineFactory",new MachineFactory("111","nnnn"));
//redisCore.putObject("machineFactory",new MachineFactory("111","nnnn"));
redisCore.putObject("wms","123123123");
return new ResultBean(true,"已放入缓存");
@ -75,11 +76,11 @@ public class DemoRedisMqController extends CoreBaseController{
@GetMapping(value="/get-cache")
@ApiOperation(value="缓存",notes="获取数据")
public ResultBean getCache(){
MachineFactory mf = (MachineFactory) redisCore.getObject("machineFactory");
System.out.println("1===== " + mf);
//MachineFactory mf = (MachineFactory) redisCore.getObject("machineFactory");
//System.out.println("1===== " + mf);
System.out.println("2===== " + redisCore.getObject("wms"));
return new ResultBean(true,mf);
return new ResultBean(true);
}
@GetMapping(value="/send-mq")
@ -94,7 +95,7 @@ public class DemoRedisMqController extends CoreBaseController{
this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_HANDLE_QUEUE, context);
System.out.println("发送Object数据 : " + context);
this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_OBJ_QUEUE, new MachineFactory("111mq","rabbit"));
//this.rabbitTemplate.convertAndSend(I3CoreQueueConfig.DEMO_OBJ_QUEUE, new MachineFactory("111mq","rabbit"));
return new ResultBean(true,"操作成功");
}

@ -48,22 +48,6 @@ public class AuthController extends CoreBaseController {
*
* @return
*/
@GetMapping(value="/logout")
@ApiOperation(value="登出",notes="登出")
public ResultBean logout(){
LOGGER.info("用户退出...");
try {
AuthUtil.logout();
return new ResultBean(true,"").build();
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + ",so:" + e.getErrorSolution());
}
}
/**
*
* @return
*/
@GetMapping(value="/get-user-info")
@ApiOperation(value="获取登录用户信息",notes="获取当前登录用户详细信息")
public ResultBean getUserInfo(){
@ -73,7 +57,7 @@ public class AuthController extends CoreBaseController {
LOGGER.info("用户:{}",sUser);
return new ResultBean(true,"",sUser.getUserInfo());
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + ",so:" + e.getErrorSolution());
return new ResultBean(false,e.getErrorDetail() + "-[解决]" + e.getErrorSolution());
}
}
@ -90,7 +74,7 @@ public class AuthController extends CoreBaseController {
LOGGER.info("用户:{}",sUser);
return new ResultBean(true,"",sUser.getUser());
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + ",so:" + e.getErrorSolution());
return new ResultBean(false,e.getErrorDetail() + "-[解决]" + e.getErrorSolution());
}
}

@ -4,15 +4,15 @@ import cn.estsh.i3plus.core.api.iservice.base.IDataSimpleService;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
import cn.estsh.impp.framework.base.controller.CoreBaseController;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.i3plus.pojo.mes.MachineFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @Description :
@ -33,10 +33,10 @@ public class SimpleController extends CoreBaseController{
@PutMapping(value="/insert")
@ApiOperation(value="service服务",notes="返回内容添加service")
public ResultBean insertFactory(@RequestParam("name")String name, @RequestParam("code")String code){
MachineFactory machineFactory = new MachineFactory();
machineFactory.setFactoryName(name);
machineFactory.setFactoryCode(code);
dataSimpleService.saveMachineFactory(machineFactory);
// MachineFactory machineFactory = new MachineFactory();
// machineFactory.setFactoryName(name);
// machineFactory.setFactoryCode(code);
// dataSimpleService.saveMachineFactory(machineFactory);
return new ResultBean(true,"工厂已保存");
}

@ -71,7 +71,23 @@ public class WhiteController extends CoreBaseController {
}
}
@GetMapping(value="/auth/login")
/**
*
* @return
*/
@GetMapping(value="/logout")
@ApiOperation(value="登出",notes="登出")
public ResultBean logout(){
LOGGER.info("用户退出...");
try {
AuthUtil.logout();
return new ResultBean(true,"您已安全退出。").build();
} catch (ImppBusiException e) {
return new ResultBean(false,e.getErrorDetail() + "-[解决]" + e.getErrorSolution());
}
}
@GetMapping(value="/login")
@ApiOperation(value="登陆",notes="登陆")
public ResultBean login(HttpServletRequest request, String loginName, String loginPwd, String languageCode){
LOGGER.info("用户登陆 loginName:{} loginPwd:{} languageCode:{}",loginName,loginPwd,languageCode);
@ -81,6 +97,13 @@ public class WhiteController extends CoreBaseController {
ValidatorBean.checkNotNull(loginPwd,"密码不能为空");
ValidatorBean.checkNotNull(languageCode,"语言不能为空");
try {
//先进行登出
AuthUtil.logout();
}catch (Exception e){
e.printStackTrace();
}
SessionUser user = userService.queryUserLogin(loginName,loginPwd,languageCode);
String redisKey = CommonConstWords.USER_LOGIN_ERROR + "_" + user.getUser().getId();

@ -1,14 +1,5 @@
package cn.estsh.i3plus.core.apiservice.dao;
import cn.estsh.i3plus.pojo.mes.MachineFactory;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Description : hqldemo
* crudrepositoryhql
@ -18,7 +9,7 @@ import java.util.List;
* @Modify:
**/
//@Repository
public interface IMachineFactoryDao extends CrudRepository<MachineFactory,Long> {
//public interface IMachineFactoryDao extends CrudRepository<MachineFactory,Long> {
//此处findBy开头会自动根据属性名进行查询
/*List<MachineFactory> findByFactoryName(String factoryName);
@ -42,4 +33,4 @@ public interface IMachineFactoryDao extends CrudRepository<MachineFactory,Long>
//自定义Hql
@Query("from MachineFactory mf where mf.createDatetime like '2018-01-01%'")
List<MachineFactory> findMachineFactorySpecial();*/
}
//}

@ -1,12 +1,8 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.base;
import cn.estsh.i3plus.core.api.iservice.base.IDataSimpleService;
import cn.estsh.i3plus.core.apiservice.dao.IMachineFactoryDao;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.mes.MachineFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -20,7 +16,7 @@ import org.springframework.stereotype.Service;
public class DataSimpleServiceImpl implements IDataSimpleService {
private Logger LOGGER = LoggerFactory.getLogger(this.getClass());
@Autowired
/*@Autowired
private IMachineFactoryDao machineFactoryDao;
@Override
@ -28,7 +24,7 @@ public class DataSimpleServiceImpl implements IDataSimpleService {
//生成主键
machineFactory.setId(new SnowflakeIdMaker().nextId());
machineFactoryDao.save(machineFactory);
}
}*/
/*
@Override
public void updateMachineFactoryNameById(long id, String factoryName) {

Loading…
Cancel
Save