首页 文章 精选 留言 我的

精选列表

搜索[后台控制台],共10000篇文章
优秀的个人博客,低调大师

Python开发微信公众号后台(系列二)

2.3 文本消息操作小例——查快递 上一小节我们已经完成了对文本消息最基础的操作,但是原样返回内容,并没有做任何更多的操作,这一次我们来试试快递接口。 我使用的依然是前文中提到的文章中的 kuaidi100 查快递接口,不过我在本地测试了许多次通过但是 SAE 的服务器依然无法返回正常结果,在网上搜了很久发现时 快递100 封掉了来自 SAE IP 段的请求,也就是说那个接口不能用了,那段代码也废掉了。所以我们只能退而求其次,做一个通过快递单号判断快递公司的功能。 依然是修改weixinInterface.py def POST(self): str_xml = web.data() #获得post来的数据 xml = etree.fromstring(str_xml)#进行XML解析 msgType=xml

优秀的个人博客,低调大师

后台(36)——MyBatis的原始Dao开发方式

探索Android软键盘的疑难杂症 深入探讨Android异步精髓Handler 详解Android主流框架不可或缺的基石 站在源码的肩膀上全解Scroller工作机制 Android多分辨率适配框架(1)— 核心基础 Android多分辨率适配框架(2)— 原理剖析 Android多分辨率适配框架(3)— 使用指南 自定义View系列教程00–推翻自己和过往,重学自定义View 自定义View系列教程01–常用工具介绍 自定义View系列教程02–onMeasure源码详尽分析 自定义View系列教程03–onLayout源码详尽分析 自定义View系列教程04–Draw源码分析及其实践 自定义View系列教程05–示例分析 自定义View系列教程06–详解View的Touch事件处理 自定义View系列教程07–详解ViewGroup分发Touch事件 自定义View系列教程08–滑动冲突的产生及其处理 版权声明 本文原创作者:谷哥的小弟 作者博客地址:http://blog.csdn.net/lfdfhl 使用Mybatis开发Dao,通常有两个方法:原始Dao开发方式和Mapper接口开发方式。 在本篇文章中,我们在上一篇博客的基础上来一起完成原始Dao开发方式。 StudentDto /** * 本文作者:谷哥的小弟 * 博客地址:http://blog.csdn.net/lfdfhl */ package cn.com.dao; import java.io.IOException; import java.util.List; import cn.com.bean.Student; public interface StudentDto { public Student findStudentById(int id) throws IOException; public List<Student> findStudentByName(String name) throws IOException; public void insertStudent(Student student) throws IOException; public void deleteStudent(int id) throws IOException; public void updateStudent(Student student) throws IOException; } 在此定义了StudentDto,接下来再看它的实现。 StudentDtoImpl /** * 本文作者:谷哥的小弟 * 博客地址:http://blog.csdn.net/lfdfhl */ package cn.com.daoimpl; import java.io.IOException; import java.util.List; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import cn.com.bean.Student; import cn.com.dao.StudentDto; public class StudentDtoImpl implements StudentDto{ private SqlSessionFactory sqlSessionFactory; public StudentDtoImpl(SqlSessionFactory sqlSessionFactory){ this.sqlSessionFactory=sqlSessionFactory; } @Override public Student findStudentById(int id) throws IOException { SqlSession sqlSession=sqlSessionFactory.openSession(); Student student = sqlSession.selectOne("student.findStudentById", id); sqlSession.close(); return student; } @Override public List<Student> findStudentByName(String name) throws IOException { SqlSession sqlSession = sqlSessionFactory.openSession(); List<Student> list = sqlSession.selectList("student.findStudentByName", name); sqlSession.close(); return list; } @Override public void insertStudent(Student student) throws IOException { SqlSession sqlSession = sqlSessionFactory.openSession(); sqlSession.insert("student.insertStudent",student); sqlSession.commit(); sqlSession.close(); } @Override public void deleteStudent(int id) throws IOException { SqlSession sqlSession = sqlSessionFactory.openSession(); sqlSession.delete("student.deleteStudent", id); sqlSession.commit(); sqlSession.close(); } @Override public void updateStudent(Student student) throws IOException { SqlSession sqlSession = sqlSessionFactory.openSession(); sqlSession.update("student.updateStudent", student); sqlSession.commit(); sqlSession.close(); } } 请务必注意:SqlSession是线程不安全的,所以最好是在方法体内把SqlSession当做局部变量使用。 TestCRUD /** * 本文作者:谷哥的小弟 * 博客地址:http://blog.csdn.net/lfdfhl */ package cn.com.test; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.List; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.junit.Before; import org.junit.Test; import cn.com.bean.Student; import cn.com.dao.StudentDto; import cn.com.daoimpl.StudentDtoImpl; public class TestCRUD { private SqlSessionFactory sqlSessionFactory; @Before public void intiSqlSessionFactory() throws Exception { String resource = "SqlMapConfig.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); } @Test public void findStudentById() throws IOException{ StudentDto studentDto=new StudentDtoImpl(sqlSessionFactory); Student student = studentDto.findStudentById(2); System.out.println(student); } @Test public void findStudentByName() throws IOException { StudentDto studentDto = new StudentDtoImpl(sqlSessionFactory); List<Student> students = studentDto.findStudentByName("结"); for(Student student:students){ System.out.println(student); } } @Test public void deleteStudent() throws IOException{ StudentDto studentDto=new StudentDtoImpl(sqlSessionFactory); studentDto.deleteStudent(3); } @Test public void updateStudent() throws IOException{ StudentDto studentDto=new StudentDtoImpl(sqlSessionFactory); Student student=new Student(); student.setId(4); student.setName("小小木希"); student.setGender("female"); student.setBirthday(new Date()); studentDto.updateStudent(student); } } 除了以上的代码以外,SqlMapConfig.xml和StudentMapper.xml无需修改。 至此,我们在MyBatis中使用传统的DAO的方式就已经全部展示完了。 原始Dao开发方式的问题总结 DAT接口实现类的方法中存在大量冗余的代码 调用sqlsession对象的方法时存在硬编码 由于sqlsession对象的方法的输入参数使用泛型,故在调用sqlsession的方法时传入的变量即使有错在编译阶段也不报错,这不利于程序员开发的。 最后还是附上项目结构图,如下所示:

优秀的个人博客,低调大师

0.4Mb 就为 Java 中间件的控制台开发提供

比如你开发了个中间件(比如叫“annie”),想安排一个管理界面(比如叫:annie-admin)。后端接口想用什么开发? <dependencies> <dependency> <groupId>org.noear</groupId> <artifactId>solon-boot-jdkhttp</artifactId> </dependency> </dependencies> 只要 0.4Mb,有 Ioc/Aop 容器;有 Mvc 支持;有 Config 管理支持;还有无限的扩展支持。 一、自由的启动 1、如果你想做为“独立应用”,我们这么启动: public class AnnieApp{ public static void main(String[] args){ Solon.start(AnnieApp.class, args); } } 2、如果你想“内嵌”到 SpringBoot3 的项目里。就这么启动: @Configuration public class AnnieConfig { @PostConstruct public void start() { //启动 solon Solon.start(AnnieConfig.class, new String[]{"--cfg=annie.properties"}); //可以用特定的配置文件,避免与主应用冲突 } @PreDestroy public void stop() { if (Solon.app() != null) { //停止 solon(根据配置,可支持两段式安全停止) Solon.stopBlock(false, Solon.cfg().stopDelay()); } } @Bean public FilterRegistrationBean folkmqAdmin(){ //通过 Servlet Filter 实现 http 能力对接 FilterRegistrationBean<SolonServletFilter> filter = new FilterRegistrationBean<>(); filter.setName("AnnieFilter"); filter.addUrlPatterns("/annie-admin/*"); filter.setFilter(new SolonServletFilter()); return filter; } } 3、如果你想“内嵌”到 Vert.X 的项目里。这么启动: public class AnnieConfig extends AbstractVerticle { private final Router router; private final VxWebHandler handler; public AnnieConfig(Router router) { this.router = router; this.handler = new VxWebHandler(); } @Override public void start() { router.routeWithRegex("/annie-admin/*").handler(req -> { handler.handle(req.request()); }); Solon.start(AnnieConfig.class, new String[]{"--cfg=annie.properties"}); } @Override public void stop() { if (Solon.app() != null) { Solon.stopBlock(false, Solon.cfg().stopDelay()); } } } 4、如果你想“内嵌”到 jFinal 的项目里。这么启动: public class AnnieConfig extends Handler implements IPlugin { public boolean start() { Solon.start(AnnieConfig.class, new String[]{"--cfg=annie.properties"}); return true; } public boolean stop() { if (Solon.app() != null) { Solon.stopBlock(false, Solon.cfg().stopDelay()); } return true; } @Override public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) { if (target.startsWith("/annie-admin/")) { Context ctx = new SolonServletContext(request, response); try { //Solon处理(可能是空处理) Solon.app().tryHandle(ctx); if (isHandled != null && isHandled.length > 0) { isHandled[0] = true; } } catch (Throwable e) { ctx.errors = e; throw e; } finally { ContextUtil.currentRemove(); } } else { if (next != null) { next.handle(target, request, response, isHandled); } } } } 二、可独立、可内嵌的通用开发 添加配置 annie.properties #项目配置 annie.title=Annie #配置数据源 solon.dataSources.annie!.class=com.zaxxer.hikari.HikariDataSource solon.dataSources.annie!.jdbcUrl=jdbc:mysql://localhost:3306/rock?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true solon.dataSources.annie!.driverClassName=com.mysql.cj.jdbc.Driver solon.dataSources.annie!.username=demo solon.dataSources.annie!.password=123456 再引入轻量的 sql 工具(20kb),轻量的 http 工具(40kb) 开发接口 @Controller public class LoginController { @SqlUtils SqlUtils sqlUtils; @Mapping("hello") public String hello() { return "Hello world!"; } @Mapping("sql") public UserDo sql(String username, String passowd) { return sqlUtils.sql("SELECT * FROM username=? AND passowd?", username, passowd) .queryRow() .toBean(UserDo.class); } @Mapping("http") public UserDto http(String username, String passowd) { return HttpUtils.http("http://demo.org/user/get") .data("username", username) .data("passowd", passowd) .post(UserDto.class); } } 更多扩展与开发内容,可参考 Solon 官网。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册