package com.rj.controller; import com.rj.entity.QweiUser; import com.rj.service.IQweiUserService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.Map; @RestController @RequestMapping("/api/qweiUser") @Tag(name = "企微用户", description = "qwei_user增删改查与分页") public class QweiUserController { @Autowired private IQweiUserService qweiUserService; @PostMapping("/add") @Operation(summary = "新增") public ResponseEntity> add( @Parameter(description = "实体", required = true) @RequestBody QweiUser entity) { Map result = qweiUserService.add(entity); Boolean success = (Boolean) result.get("success"); if (success != null && success) { return ResponseEntity.ok(result); } return ResponseEntity.badRequest().body(result); } @PutMapping("/update") @Operation(summary = "更新") public ResponseEntity> update( @Parameter(description = "实体", required = true) @RequestBody QweiUser entity) { Map result = qweiUserService.update(entity); Boolean success = (Boolean) result.get("success"); if (success != null && success) { return ResponseEntity.ok(result); } return ResponseEntity.badRequest().body(result); } @DeleteMapping("/delete/{id}") @Operation(summary = "删除") public ResponseEntity> delete( @Parameter(description = "主键ID(UUID)", required = true) @PathVariable String id) { Map result = qweiUserService.deleteById(id); Boolean success = (Boolean) result.get("success"); if (success != null && success) { return ResponseEntity.ok(result); } return ResponseEntity.badRequest().body(result); } @GetMapping("/list") @Operation(summary = "分页查询") public ResponseEntity> list( @RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, @RequestParam(required = false) String userid, @RequestParam(required = false) String userName, @RequestParam(required = false) Long mainDepartmentId, @RequestParam(required = false) Integer status) { Map result = qweiUserService.pageQuery(current, size, userid, userName, mainDepartmentId, status); Boolean success = (Boolean) result.get("success"); if (success != null && success) { return ResponseEntity.ok(result); } return ResponseEntity.internalServerError().body(result); } @PostMapping("/sync") @Operation(summary = "同步企微用户并入库") public ResponseEntity> sync( @RequestParam(required = false) String tenantId) { Map result = qweiUserService.syncFromQiWei(tenantId); Boolean success = (Boolean) result.get("success"); if (success != null && success) { return ResponseEntity.ok(result); } return ResponseEntity.badRequest().body(result); } @PostMapping("/syncCustomer") @Operation(summary = "同步企微客户并入库") public ResponseEntity> syncCustomer( @RequestParam(required = false) String tenantId) { Map result = qweiUserService.syncCustomerFromQiWei(tenantId); Boolean success = (Boolean) result.get("success"); if (success != null && success) { return ResponseEntity.ok(result); } return ResponseEntity.badRequest().body(result); } }