| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- package com.train.controller;
- import com.train.common.Result;
- import com.train.service.EvalService;
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.annotations.tags.Tag;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestAttribute;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import javax.annotation.Resource;
- import java.util.Map;
- /**
- * 评价线 Controller(用户/公网侧)
- *
- * - E1 submit:客户服务评价(★only-after-confirmed,uk(order_id) 幂等),必须本人(worker)
- * - E2 org / E3 training:机构绩效 / 培训考核成绩(Service 内 RoleGuard.requireOrgOrTeacher)
- * - E4 mine:四层评价汇总 + 综合评级
- */
- @Tag(name = "评价", description = "客户服务评价 / 机构绩效 / 培训考核 / 综合评级")
- @RestController
- @RequestMapping("/api/eval")
- public class EvalController {
- @Resource
- private EvalService evalService;
- /**
- * 客户服务评价(★only-after-confirmed)
- * body: {orderId, score(1-5), comment?}
- */
- @Operation(summary = "客户服务评价(订单确认后)")
- @PostMapping("/submit")
- public Result<Map<String, Object>> submit(
- @RequestAttribute("userId") Long userId,
- @RequestBody(required = false) Map<String, Object> body) {
- Long orderId = toLong(body == null ? null : body.get("orderId"));
- Integer score = toInt(body == null ? null : body.get("score"));
- String comment = body == null || body.get("comment") == null ? null : body.get("comment").toString().trim();
- return evalService.submitClient(userId, orderId, score, comment);
- }
- /**
- * 机构绩效评价
- * body: {userId(被评), score(1-100), dimension?, comment?}
- */
- @Operation(summary = "机构绩效评价")
- @PostMapping("/org")
- public Result<Map<String, Object>> org(
- @RequestAttribute("userId") Long operatorId,
- @RequestBody(required = false) Map<String, Object> body) {
- Long targetUserId = toLong(body == null ? null : body.get("userId"));
- Integer score = toInt(body == null ? null : body.get("score"));
- String dimension = body == null || body.get("dimension") == null ? null : body.get("dimension").toString().trim();
- String comment = body == null || body.get("comment") == null ? null : body.get("comment").toString().trim();
- return evalService.submitOrg(operatorId, targetUserId, score, dimension, comment);
- }
- /**
- * 培训考核成绩(双达标自动触发证书)
- * body: {userId(被评), examScore(0-100), creditHours?(分钟)}
- */
- @Operation(summary = "培训考核成绩(双达标触发证书)")
- @PostMapping("/training")
- public Result<Map<String, Object>> training(
- @RequestAttribute("userId") Long operatorId,
- @RequestBody(required = false) Map<String, Object> body) {
- Long targetUserId = toLong(body == null ? null : body.get("userId"));
- Integer examScore = toInt(body == null ? null : body.get("examScore"));
- Integer creditHours = toInt(body == null ? null : body.get("creditHours"));
- return evalService.submitTraining(operatorId, targetUserId, examScore, creditHours);
- }
- /**
- * 我的四层评价汇总
- * 出参: {client:{avg,count}, org:{avg,count}, training:{avg,count,creditTotal,passCount}, composite}
- */
- @Operation(summary = "我的四层评价汇总")
- @PostMapping("/mine")
- public Result<Map<String, Object>> mine(@RequestAttribute("userId") Long userId) {
- return evalService.mine(userId);
- }
- private Long toLong(Object v) {
- if (v == null) {
- return null;
- }
- try {
- return Long.valueOf(v.toString().trim());
- } catch (NumberFormatException e) {
- return null;
- }
- }
- private Integer toInt(Object v) {
- if (v == null) {
- return null;
- }
- try {
- return Integer.valueOf(v.toString().trim());
- } catch (NumberFormatException e) {
- return null;
- }
- }
- }
|