Merge pull request '后端代码新增' (#9) from wuyifan_branch into develop
commit
1676bb1968
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 30 KiB |
@ -0,0 +1,13 @@
|
||||
package com.softegg.freetogo.Demand.Dao;
|
||||
|
||||
import com.softegg.freetogo.Demand.bean.Demands;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @description:继承Jpa数据库接口类
|
||||
* @author:wuyifan
|
||||
* @date:2024/5/10 19:50
|
||||
*/
|
||||
public interface DemandsRepository extends JpaRepository<Demands, Integer> {
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.softegg.freetogo.Demand.bean;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @description:数据库中表demand的对应实体类
|
||||
* @author:wuyifan
|
||||
* @date:2024/5/10 11:36
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="demands")
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Demands {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer uid;
|
||||
@Column
|
||||
private String phone;//游客手机号码
|
||||
@Column
|
||||
private boolean touristGender;//游客性别 ture:male, false:female
|
||||
@Column
|
||||
private String nickname;//发布需求的游客昵称信息
|
||||
@Column
|
||||
private String createTime;//需求发布时间
|
||||
@Column
|
||||
private String departureDate;//游客需求起始日期
|
||||
@Column
|
||||
private String endDate;//游客需求结束日期
|
||||
@Column
|
||||
private String sumDay;//游客旅游总天数
|
||||
@Column
|
||||
private String city;//发布需求的目的城市
|
||||
@Column
|
||||
private String message;//需求备注内容
|
||||
// @Column
|
||||
// private boolean guideGender;//希望导游性别
|
||||
// @Column
|
||||
// private int status;
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.softegg.freetogo.Demand.service;
|
||||
|
||||
import com.softegg.freetogo.Demand.Dao.DemandsRepository;
|
||||
import com.softegg.freetogo.Demand.bean.Demands;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description:数据库操作接口实现类
|
||||
* @author:wuyifan
|
||||
* @date:2024/5/10 19:50
|
||||
*/
|
||||
@Component
|
||||
public class DemandsServiceImpl implements DemandsService {
|
||||
@Autowired
|
||||
private DemandsRepository DemandsRepository;
|
||||
|
||||
/**
|
||||
* @description: 查找所有游客需求
|
||||
* @param: null
|
||||
* @return: java.util.List<com.softegg.freetogo.Demand.Bean.Demands>
|
||||
* @author: wuyifan
|
||||
* @date: 2024/5/10 19:53
|
||||
*/
|
||||
public List<Demands> findAll() {
|
||||
System.out.println("查询成功");
|
||||
return DemandsRepository.findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 以demand为游客需求入库
|
||||
* @param: demand
|
||||
* @return: void
|
||||
* @author: wuyifan
|
||||
* @date: 2024/5/10 19:55
|
||||
*/
|
||||
public void add(Demands demand) {
|
||||
DemandsRepository.save(demand);
|
||||
System.out.println("添加成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 删除对应序号id的需求
|
||||
* @param: id
|
||||
* @return: void
|
||||
* @author: wuyifan
|
||||
* @date: 2024/5/10 19:59
|
||||
*/
|
||||
public void deleteById(int id) {
|
||||
DemandsRepository.deleteById(id);
|
||||
System.out.println("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获得对应序号id的需求
|
||||
* @param: id
|
||||
* @return: com.softegg.freetogo.Demand.Bean.Demands
|
||||
* @author: wuyifan
|
||||
* @date: 2024/5/10 20:02
|
||||
*/
|
||||
public Demands getDemandById(int id) {
|
||||
return DemandsRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 更新需求信息
|
||||
* @param: demand
|
||||
* @return: void
|
||||
* @author: wuyifan
|
||||
* @date: 2024/5/10 20:05
|
||||
*/
|
||||
public void update(Demands demand) {
|
||||
DemandsRepository.save(demand);
|
||||
System.out.println("更新成功");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @description: 判断相同需求是否已经入库
|
||||
// * @param: id
|
||||
// * @return: boolean
|
||||
// * @author: wuyifan
|
||||
// * @date: 2024/5/10 20:05
|
||||
// */
|
||||
// public boolean isRegister(int id) {
|
||||
// Demands demand = DemandsRepository.findById(id);
|
||||
// System.out.println(demand);
|
||||
// return users != null;
|
||||
// }
|
||||
|
||||
}
|
Loading…
Reference in new issue