Skip to content

Instantly share code, notes, and snippets.

Avatar

等待时候 Jandaes

View GitHub Profile
View TimestampToDate(javascript)
/*时间戳转时间*/
timestamp = 1520839465;
var time = new Date(timestamp);
var year = time.getFullYear();
var month = (time.getMonth() + 1) > 9 && (time.getMonth() + 1) || ("0" + (time.getMonth() + 1))
var date = time.getDate() > 9 && time.getDate() || ("0" + time.getDate())
var hour = time.getHours() > 9 && time.getHours() || ("0" + time.getHours())
var minute = time.getMinutes() > 9 && time.getMinutes() || ("0" + time.getMinutes())
var second = time.getSeconds() > 9 && time.getSeconds() || ("0" + time.getSeconds())
var YmdHis = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
@Jandaes
Jandaes / SpringBootCache.md
Created Oct 30, 2017
Spring Boot CachePut缓存 #Spring #Cache
View SpringBootCache.md

Spring CachePut 是Spring自带的缓存、只需要添加注解即可使用

   /**
     * @CachePut缓存新增或更新数据到缓存,其中缓存名称为people,数据key是people的id
     * @param person
     * @return
     */
    @Override
    @CachePut(value = "people",key = "#person.id")
    public Person save(Person person) {
@Jandaes
Jandaes / SpringTransactional.java
Created Oct 30, 2017
Spring事务回滚代码片段 #Transactional #Spring
View SpringTransactional.java
/**
* 遇到异常回滚事务
* @param person
* @return
*/
@Override
@Transactional(rollbackFor = {IllegalArgumentException.class})
public Person savePersonWithRollBack(Person person) {
Person p=personRepository.save(person);
if(person.getName().equals("73")){
You can’t perform that action at this time.