Merge pull request '发送需求' (#10) from wuyifan_branch into develop

wuyifan_branch
mwxbgi697 1 year ago
commit 0d739d8a5a

@ -0,0 +1,41 @@
package com.softegg.freetogo.SendDemand.controller;
import com.softegg.freetogo.SendDemand.service.SendDemandService;
import com.softegg.freetogo.Demand.Dao.DemandsRepository;
import com.softegg.freetogo.Demand.bean.Demands;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:09
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/SendDemand")
public class SendDemandController {
@Autowired
SendDemandService sendDemandService;
/**
* @description:
* @param: map
* @return: java.lang.String
* @author: zhanglinhao
* @date: 2024/5/9 22:45
*/
@PostMapping("register")
public int SendDemand(@RequestBody Map<String, Object> map) {
return switch (sendDemandService.sendnewDemandAccount(map.get("city").toString(), map.get("phone").toString())){
case 1005 -> 1;//需求发送成功
default -> 0;
};
}
}

@ -0,0 +1,13 @@
package com.softegg.freetogo.SendDemand.service;
import org.springframework.stereotype.Service;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:31
*/
@Service
public interface SendDemandService {
int sendnewDemandAccount(String city, String phone);
}

@ -0,0 +1,39 @@
package com.softegg.freetogo.SendDemand.service;
import com.softegg.freetogo.Demand.bean.Demands;
import com.softegg.freetogo.Demand.service.DemandsService;
import com.softegg.freetogo.User.service.UsersService;
import com.softegg.freetogo.User.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @description:
* @author:wuyifan
* @date:2024/5/10 23:10
*/
@Component
public class SendDemandServiceImpl implements SendDemandService {
@Autowired
DemandsService demandsService;
UsersService usersService;
/**
* @description:
* @param: city
* @return: int
* @author: wuyifan
* @date: 2024/5/10 23:25
*/
@Override
public int sendnewDemandAccount(String city, String phone) {
Demands demand = new Demands();
Users user = usersService.getUserByPhone(phone);
demand.setPhone(phone);
demand.setCity(city);
demand.setTouristGender(user.isGender());
demand.setNickname(user.getNickname());
demandsService.add(demand);
return 1005;//添加需求成功
}
}
Loading…
Cancel
Save