对接企业微信
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.rj.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.rj.common.DictItemConstants;
|
||||
import com.rj.dto.QiWeiConfig;
|
||||
import com.rj.entity.DictItem;
|
||||
import com.rj.service.IDictItemService;
|
||||
@@ -26,6 +28,8 @@ public class DictItemController {
|
||||
@Autowired
|
||||
private IDictItemService dictItemService;
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增")
|
||||
public ResponseEntity<Map<String, Object>> add(
|
||||
@@ -90,10 +94,18 @@ public class DictItemController {
|
||||
try {
|
||||
DictItem data = dictItemService.getById(id);
|
||||
if (data == null) {
|
||||
if ("qiwei_config".equals(name)) {
|
||||
if (DictItemConstants.QIWEI_CONFIG.equals(name)) {
|
||||
result.put("success", true);
|
||||
result.put("message", "查询成功");
|
||||
result.put("data", new QiWeiConfig());
|
||||
data= new DictItem();
|
||||
QiWeiConfig cfg = new QiWeiConfig();
|
||||
cfg.setCorpid("-");
|
||||
cfg.setAppSecret("-");
|
||||
cfg.setContractSecret("-");
|
||||
data.setValue(OBJECT_MAPPER.writeValueAsString(cfg));
|
||||
data.setName(DictItemConstants.QIWEI_CONFIG);
|
||||
data.setDescription("企微的默认配置项");
|
||||
result.put("data", data);
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.rj.controller;
|
||||
|
||||
import com.rj.entity.QweiDepartment;
|
||||
import com.rj.service.IQweiDepartmentService;
|
||||
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/qweiDepartment")
|
||||
@Tag(name = "企微部门", description = "qwei_department增删改查与分页")
|
||||
public class QweiDepartmentController {
|
||||
|
||||
@Autowired
|
||||
private IQweiDepartmentService qweiDepartmentService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增")
|
||||
public ResponseEntity<Map<String, Object>> add(
|
||||
@Parameter(description = "实体", required = true) @RequestBody QweiDepartment entity) {
|
||||
Map<String, Object> result = qweiDepartmentService.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<Map<String, Object>> update(
|
||||
@Parameter(description = "实体", required = true) @RequestBody QweiDepartment entity) {
|
||||
Map<String, Object> result = qweiDepartmentService.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<Map<String, Object>> delete(
|
||||
@Parameter(description = "主键ID(UUID)", required = true) @PathVariable String id) {
|
||||
Map<String, Object> result = qweiDepartmentService.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<Map<String, Object>> list(
|
||||
@RequestParam(defaultValue = "1") Integer current,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) Long deptId,
|
||||
@RequestParam(required = false) String deptName,
|
||||
@RequestParam(required = false) Long parentDeptId) {
|
||||
Map<String, Object> result = qweiDepartmentService.pageQuery(current, size, deptId, deptName, parentDeptId);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
if (success != null && success) {
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
75
src/main/java/com/rj/controller/QweiUserController.java
Normal file
75
src/main/java/com/rj/controller/QweiUserController.java
Normal file
@@ -0,0 +1,75 @@
|
||||
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<Map<String, Object>> add(
|
||||
@Parameter(description = "实体", required = true) @RequestBody QweiUser entity) {
|
||||
Map<String, Object> 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<Map<String, Object>> update(
|
||||
@Parameter(description = "实体", required = true) @RequestBody QweiUser entity) {
|
||||
Map<String, Object> 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<Map<String, Object>> delete(
|
||||
@Parameter(description = "主键ID(UUID)", required = true) @PathVariable String id) {
|
||||
Map<String, Object> 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<Map<String, Object>> 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<String, Object> 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user