public SwitchGame(String id, String switchName, String switchPrice, String switchColor) { this.id = id; this.switchName = switchName; this.switchPrice = switchPrice; this.switchColor = switchColor; } public Swi
) COMMENT= '订单表'; INSERT INTO `t_order` (`id`, `order_id`, `user_id`, `goods_name`, `goods_price`) VALUES (1, 805646264648356, 1, 'Switch 游戏机', 1400.00); INSERT INTO `t_order` (`id`, `order_id`, `user_id`, `goods_name`, `goods_price`) VALUES (2, 55178744131050...
针对这种情况,MyBatis 提供了 choose 元素,它有点像 Java 中的 switch 语句。还是上面的例子,但是策略变为:传入了 “title” 就按 “title” 查找,传入了 “author” 就按 “author” 查找的情形。若两者都没有传入,就返回标记为 featured 的 BLOG SELECT * FROM BLOG WHERE state = ‘ACTIVE’ <choose...
@Override public DataSource determineDataSource() { return getDataSource(DynamicDataSourceContextHolder.peek()); } /** * 获取数据源 * * @param ds 数据源名称 * @return 数据源 */ public DataSource getDataSource(String ds) { //没有传数据源名称,默认使用主数据源 if (StringUtils.isEmpty(ds)...
User user = SecurityUtils.getUser();// 2、当前角色即角色或角色类型(可能多种角色) Set<String> roleTypeSet = remoteRoleService.currentUserRoleType(); DataScope scopeType = DataPermission.getScope(roleTypeSet);switch (scopeType) {// 查看全部case ALL:return where;case DEPT:// 查看本部...
switch (type) { case MOBILE: return DesensitizedUtil.mobilePhone(value); case EMAIL: return DesensitizedUtil.email(value); case ID_CARD: return DesensitizedUtil.idCardNum(value, 1, 2); default: return value; } } } 4. 配置 MyBatis-Plus ...
/** * 测试手动方式切换数据源 */ @Test void testDataSourceSwitchManually() { DynamicDataSourceContextHolder.push("master"); SysUser masterUser = userMapper.selectById(userId); log.info("手动切换:主库姓名:{}", masterUser.getNickname()); DynamicDataSourceContextHolder.poll(); DynamicDataSource...
public Object switchDataSource(ProceedingJoinPoint point, DataSource dataSource) throws Throwable { try { // 在方法执行前设置数据源 DataSourceContextHolder.setDatabaseType(dataSource.value()); return point.proceed(); // 执行目标方法 } finally { ...
switch (command.getType()) { case INSERT: { Object param = method.convertArgsToSqlCommandParam(args); result = rowCountResult(sqlSession.insert(command.getName(), param)); break; } case UPDATE: { Object param = method.convertArgsToSqlCommandParam(args); ...
switch (scopeType) { // 查看全部 case ALL: return where; case DEPT: // 查看本部门用户数据 // 创建IN 表达式 // 创建IN范围的元素集合 List<String> deptUserList = remoteUserService.listUserCodesByDeptCodes(user.getDeptCode()); // 把集合转变为JSQLParser需要的元素列表 ...