赞
踩
Cursor (https://www.cursor.so/)是 GPT-4 驱动的一款强大代码编辑器,可以辅助程序员进行日常的编码。
设置里面支持多语言
下面通过实际例子来展示cursor如何帮你编程
默认有react及python的基本示例
1.通过ctrl+k提问:基于java语言,实现user基础信息定义,实现user基于mybits增删改查过程
- public class User {
- private int id;
- private String name;
- private String email;
- private String password;
- // getters and setters
- }
-
- // DAO interface
- public interface UserDao {
- User findById(int id);
- List<User> findAll();
- void save(User user);
- void update(User user);
- void delete(int id);
- }
-
- // DAO implementation using MyBatis
- public class UserDaoImpl implements UserDao {
- private SqlSessionFactory sessionFactory;
-
- public UserDaoImpl(SqlSessionFactory sessionFactory) {
- this.sessionFactory = sessionFactory;
- }
-
- @Override
- public User findById(int id) {
- try (SqlSession session = sessionFactory.openSession()) {
- return session.selectOne("UserMapper.findById", id);
- }
- }
-
- @Override
- public List<User> findAll() {
- try (SqlSession session = sessionFactory.openSession()) {
- return session.selectList("UserMapper.findAll");
- }
- }
-
- @Override
- public void save(User user) {
- try (SqlSession session = sessionFactory.openSession()) {
- session.insert("UserMapper.save", user);
- session.commit();
- }
- }
-
- @Override
- public void update(User user) {
- try (SqlSession session = sessionFactory.openSession()) {
- session.update("UserMapper.update", user);
- session.commit();
- }
- }
-
- @Override
- public void delete(int id) {
- try (SqlSession session = sessionFactory.openSession()) {
- session.delete("UserMapper.delete", id);
- session.commit();
- }
- }
- }
-
-
2.通过ctrl+l进行提问是解答
问题:基于此类进一步优化,使其具备多并发
Cursor对于编程而言是个不错的帮手
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。