新增评价控制类

pull/11/head
zhanglinhao 1 year ago
parent d6932b75e1
commit 5e37650982

@ -18,7 +18,7 @@ public class Configurer implements WebMvcConfigurer {
.allowCredentials(true)
//放行哪些原始域
.allowedOriginPatterns("*")
.allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"})
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.exposedHeaders("*");
}

@ -0,0 +1,58 @@
package com.softegg.freetogo.Evaluate.controller;
import com.softegg.freetogo.Evaluate.bean.Evaluations;
import com.softegg.freetogo.Evaluate.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: zhanglinhao
* @date: 2024/5/11 17:33
*/
@RestController
@RequestMapping("/evaluate")
public class EvaluationController {
@Autowired
EvaluateService evaluateService;
/**
* @description:
* @param: null
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/12 0:11
*/
@GetMapping("findAllEvaluation")
public List<Evaluations> findAllEvaluation() {
return evaluateService.evaluationList();
}
/**
* @description:
* @param: ebody
* @return: void
* @author: zhanglinhao
* @date: 2024/5/12 0:28
*/
@PostMapping("addEvaluation")
public void addEvaluation(@RequestBody Map<String, Evaluations> ebody) {
Evaluations evaluation = ebody.get("evaluation");
evaluateService.addEvaluation(evaluation);
}
/**
* @description:
* @param: phone
* @return: java.util.List<com.softegg.freetogo.Evaluate.bean.Evaluations>
* @author: zhanglinhao
* @date: 2024/5/12 0:30
*/
@GetMapping("evaluationByPhone")
public List<Evaluations> evaluationByPhone(String phone) {
return evaluateService.getEListByPhone(phone);
}
}

@ -11,9 +11,14 @@ import java.util.List;
* @date:2024/5/10 8:52
*/
@Service
public interface evaluateService {
public interface EvaluateService {
List<Evaluations> evaluationList();//获取所有评论
List<Evaluations> getEListByPhone(String phone);//根据电话筛选评价
void addEvaluation(Evaluations evaluation);//添加评论
void editEvaluation(int eid, String ebody);//编辑评论
void deleteEvaluation(int eid);//删除评论
}

@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
/**
* @description:
@ -13,7 +14,7 @@ import java.util.List;
* @date:2024/5/10 9:25
*/
@Component
public class evaluateServiceImpl implements evaluateService {
public class EvaluateServiceImpl implements EvaluateService {
@Autowired
EvaluateRepository evaluateRepository;
@ -30,6 +31,7 @@ public class evaluateServiceImpl implements evaluateService {
System.out.println("查询评论");
return evaluateRepository.findAll();
}
/**
* @description:
* @param: phone
@ -56,5 +58,37 @@ public class evaluateServiceImpl implements evaluateService {
System.out.println("添加评论" + evaluation.getEbody());
}
/**
* @description:
* @param: eid
* @return: void
* @author: zhanglinhao
* @date: 2024/5/11 17:10
*/
@Override
public void editEvaluation(int eid, String ebody) {
System.out.println("编辑评论:" + eid);
Optional<Evaluations> opt = evaluateRepository.findById(eid);
if (opt.isPresent()) {
Evaluations evaluation = opt.get();
evaluation.setEbody(ebody);
evaluateRepository.save(evaluation);
System.out.println("编辑成功:" + eid);
}
}
/**
* @description:
* @param: eid
* @return: void
* @author: zhanglinhao
* @date: 2024/5/11 17:28
*/
@Override
public void deleteEvaluation(int eid) {
evaluateRepository.deleteById(eid);
System.out.println("删除评论:" + eid);
}
}

@ -1,9 +1,7 @@
package com.softegg.freetogo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
@SpringBootApplication
public class FreeToGoApplication {

@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* @description:

@ -15,7 +15,7 @@ import java.util.Map;
*/
@RestController
//@CrossOrigin(origins = "*")
@RequestMapping("/users")
@RequestMapping("/Users")
public class UsersController {
@Autowired
private UsersService usersService;
@ -149,6 +149,16 @@ public class UsersController {
return true;
}
@PostMapping("Pupdate")
public boolean Pupdate(@RequestBody Map<String, Users> user) {
Users ubody = user.get("user");
System.out.println(ubody);
// System.out.println(ubody.get("uid"));
Users User = new Users(ubody.getUid(), ubody.getName(), ubody.getEmail(), ubody.getPassword(), ubody.getCreatetime(), ubody.getIDCard(), ubody.getReputation(), ubody.isGender(), ubody.isMembertype(), ubody.getPhone(), ubody.getNickname(), ubody.getStatus());
usersService.update(User);
return true;
}
/**
* @description:
* @param: phone

Loading…
Cancel
Save