1、保存日期到Mysql数据库发现少了一天

解决:mysql驱动serverTimezone=UTC的问题,改为上海或者香港即可

原驱动jdbc:mysql://localhost:3306/sms?serverTimezone=UTC

改为jdbc:mysql://localhost:3306/sms?serverTimezone=Asia/Shanghai

2、发现前端的按钮和输入框都很大

解决:在注册ElementUI时,将size设置为small

Vue.use(ElementUI, { size: "small" });

 3、分页组件的使用,在components目录中添加Pagination.vue,代码如下:

<template>
  <div :class="{ hidden: hidden }" class="pagination-container">
    <el-pagination
      :background="background"
      :current-page.sync="currentPage"
      :page-size.sync="pageSize"
      :page-sizes="pageSizes"
      :layout="layout"
      :total="total"
      v-bind="$attrs"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: "Pagination",
  props: {
    total: {
      required: true,
      type: Number
    },
    page: {
      type: Number,
      default: 1
    },
    limit: {
      type: Number,
      default: 10
    },
    pageSizes: {
      type: Array,
      default() {
        return [5, 10, 20, 30, 40, 50, 100];
      }
    },
    layout: {
      type: String,
      default: "total, sizes, prev, pager, next, jumper"
    },
    background: {
      type: Boolean,
      default: true
    },
    autoScroll: {
      type: Boolean,
      default: true
    },
    hidden: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    currentPage: {
      get() {
        return this.page;
      },
      set(val) {
        this.$emit("update:page", val);
      }
    },
    pageSize: {
      get() {
        return this.limit;
      },
      set(val) {
        this.$emit("update:limit", val);
      }
    }
  },
  methods: {
    handleSizeChange(val) {
      this.$emit("pagination", { page: this.currentPage, limit: val });
    },
    handleCurrentChange(val) {
      this.$emit("pagination", { page: val, limit: this.pageSize });
    }
  }
};
</script>

<style scoped>
.pagination-container {
  background: #fff;
  padding: 32px 16px;
}

.pagination-container.hidden {
  display: none;
}
</style>

使用Pagination组件:

<pagination
        v-show="total>0"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="getList"/>

 4、mybatis-plus通用IService

service层需要继承IService,当然实现层也要继承对应的实现类ServiceImpl。

public interface UserBasicInfoService extends IService<UserBasicInfo> {
    int addUserBasicInfo(UserBasicInfo userBasicInfo);

    int updateUserBasicInfo(UserBasicInfo userBasicInfo);

    int delete(String id);
}
@Service
public class UserBasicInfoServiceImpl extends ServiceImpl<UserBasicInfoMapper,UserBasicInfo> implements UserBasicInfoService {
    @Autowired
    private UserBasicInfoMapper userBasicInfoMapper;
    @Override
    public int addUserBasicInfo(UserBasicInfo userBasicInfo) {
        return userBasicInfoMapper.insert(userBasicInfo);
    }
}

 

posted on 2020-09-24 11:22  周文豪  阅读(115)  评论(0编辑  收藏  举报