2024.12.16

package com.men.common.model;

import com.men.common.model.base.BaseTranslate;

/**
* Generated by JFinal.
*/
@SuppressWarnings("serial")
public class Translate extends BaseTranslate<Translate> {
}
package com.men.common.model;

import com.men.common.model.base.BaseUser;

/**
* 数据库字段名建议使用驼峰命名规则,便于与 java 代码保持一致,如字段名: userId
*/
@SuppressWarnings("serial")
public class User extends BaseUser<User>
{

}
package com.men.common;

import com.jfinal.config.*;
import com.jfinal.ext.interceptor.SessionInViewInterceptor;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.server.undertow.UndertowServer;
import com.jfinal.template.Engine;
import com.men.common.model._MappingKit;
import com.men.index.IndexController;
import com.men.picture.PictureController;
import com.men.translate.TranslateController;
import com.men.user.UserController;

public class AppConfig1 extends JFinalConfig
{
static Prop p;


public static void main(String[] args)
{
UndertowServer.start(AppConfig1.class);
}


static void loadConfig()
{
if (p == null)
{
p = PropKit.useFirstFound("demo-config-pro.txt", "demo-config-dev.txt");
}
}

/**
* 配置常量
*/
@Override
public void configConstant(Constants me)
{
loadConfig();

me.setDevMode(p.getBoolean("devMode", false));

/**
* 支持 Controller、Interceptor、Validator 之中使用 @Inject 注入业务层,并且自动实现 AOP
* 注入动作支持任意深度并自动处理循环注入
*/
me.setInjectDependency(true);

// 配置对超类中的属性进行注入
me.setInjectSuperClass(true);
}

/**
* 配置路由
*/
@Override
public void configRoute(Routes me)
{
// 第三个参数为该Controller的视图存放路径
me.add("/", IndexController.class, "/index");
// 第三个参数省略时默认与第一个参数值相同,在此即为 "/user
me.add("/user", UserController.class);
me.add("/translate", TranslateController.class);
me.add("/picture", PictureController.class);
}

@Override
public void configEngine(Engine me)
{
me.addSharedFunction("/common/_layout.html");
me.addSharedFunction("/common/_paginate.html");
}

/**
* 配置插件
*/
@Override
public void configPlugin(Plugins me)
{
// 配置 druid 数据库连接池插件
DruidPlugin druidPlugin = new DruidPlugin(p.get("jdbcUrl"), p.get("username"), p.get("password").trim());
me.add(druidPlugin);

// 配置ActiveRecord插件
ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
// 所有映射在 MappingKit 中自动化搞定
_MappingKit.mapping(arp);
me.add(arp);
}

public static DruidPlugin createDruidPlugin()
{
loadConfig();

return new DruidPlugin(p.get("jdbcUrl"), p.get("username"), p.get("password").trim());
}

/**
* 配置全局拦截器
*/
@Override
public void configInterceptor(Interceptors me)
{
me.add(new SessionInViewInterceptor());
}

/**
* 配置处理器
*/
@Override
public void configHandler(Handlers me)
{

}
}
package com.men.common;

/**
* Base64 工具类
*/
public class Base64Util
{
private static final char last2byte = (char) Integer.parseInt("00000011", 2);
private static final char last4byte = (char) Integer.parseInt("00001111", 2);
private static final char last6byte = (char) Integer.parseInt("00111111", 2);
private static final char lead6byte = (char) Integer.parseInt("11111100", 2);
private static final char lead4byte = (char) Integer.parseInt("11110000", 2);
private static final char lead2byte = (char) Integer.parseInt("11000000", 2);
private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};

public Base64Util()
{
}

public static String encode(byte[] from)
{
StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
int num = 0;
char currentByte = 0;

int i;
for (i = 0; i < from.length; ++i)
{
for (num %= 8; num < 8; num += 6)
{
switch (num)
{
case 0:
currentByte = (char) (from[i] & lead6byte);
currentByte = (char) (currentByte >>> 2);
case 1:
case 3:
case 5:
default:
break;
case 2:
currentByte = (char) (from[i] & last6byte);
break;
case 4:
currentByte = (char) (from[i] & last4byte);
currentByte = (char) (currentByte << 2);
if (i + 1 < from.length)
{
currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
}
break;
case 6:
currentByte = (char) (from[i] & last2byte);
currentByte = (char) (currentByte << 4);
if (i + 1 < from.length)
{
currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
}
}

to.append(encodeTable[currentByte]);
}
}

if (to.length() % 4 != 0)
{
for (i = 4 - to.length() % 4; i > 0; --i)
{
to.append("=");
}
}

return to.toString();
}
}
posted @   我也不想的  阅读(3)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
点击右上角即可分享
微信分享提示