PostGrepSql主键
id bigserial primary key
Json处理选用Google.gson
import com.google.gson.JsonObject;
import org.json.JSONObject;
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
截取浮点0
浮点截取:5.0--->5
public static String getPrettyNumber(String number) {
return BigDecimal.valueOf(Double.parseDouble(number))
.stripTrailingZeros().toPlainString();
}
测试Test
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { Application.class })
@ContextConfiguration({"classpath:spring-context.xml", "classpath:spring-context-druid.xml", "classpath:spring-context-mybatis.xml"})
@WebAppConfiguration
public class test(){
}
post请求取图片
byte[] data=httpEntity.getContent();
//对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
//返回Base64编码过的字节数组字符串
return encoder.encode(data);
-
面向对象的设计原则:
- 开:面向扩展开放,面向修改关闭
- 口:接口隔离原则
- 合:组合/聚合原则
- 里:里氏替换原则
- 最:最少知识原则(迪米特法则)
- 单:单一职责原则
- 依:依赖倒置原则
-
实现高内聚,低耦合
- 一个类只做一件事
- 一个方法只做一件事
- 写且只写一次
-
登录查询为什么不用账号密码直接SQL查询
- 防止SQL注入
- 正确方法
- 先用账号查询用户是否存在
- 存在密码进行比较
-
技术选型
- 搜索量,指数
- 社区活跃度,需求文档完备性 (gitHup)
- 是否开源
-
==注意==
- ==long eques比较==
- ==Sting StringUtils 比较==
- ==集合 collections比较==
- ==引用对象指代==
- ==对象判空==
- ==logger日志==
- ==涉及查询只有一条记录时加上limit 1==
- 数据插入同步代码块
同步代码块
if(oderid != null){
//该记录已存在
update();
}else{
synchronized(this){
if(oderid != null){
//该记录已存在
update();
}else{
insert();
}
}
}
String 拼接
String.format("%s?username=%s&password=%s",url,username,password);
网友评论