|
|
@@ -0,0 +1,145 @@
|
|
|
+package shop.alien.second.controller;
|
|
|
+
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import shop.alien.entity.result.R;
|
|
|
+import shop.alien.entity.second.SecondEntrustUser;
|
|
|
+import shop.alien.entity.second.vo.SecondEntrustUserDTO;
|
|
|
+import shop.alien.second.service.SecondEntrustUserService;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 二手委托人信息表 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author ssk
|
|
|
+ * @since 2025-11-21
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Api(tags = {"二手平台-委托人信息管理"})
|
|
|
+@ApiSort(10)
|
|
|
+@CrossOrigin
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RestController
|
|
|
+@RequestMapping("/secondEntrustUser")
|
|
|
+public class SecondEntrustUserController {
|
|
|
+
|
|
|
+ private final SecondEntrustUserService secondEntrustUserService;
|
|
|
+
|
|
|
+ @ApiOperation("创建委托人信息")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @PostMapping("/create")
|
|
|
+ public R<Boolean> createEntrustUser(@Validated @RequestBody SecondEntrustUserDTO dto) {
|
|
|
+ log.info("SecondEntrustUserController.createEntrustUser dto={}", dto);
|
|
|
+ try {
|
|
|
+ boolean result = secondEntrustUserService.createEntrustUser(dto);
|
|
|
+ if (result) {
|
|
|
+ return R.success("创建成功");
|
|
|
+ }
|
|
|
+ return R.fail("创建失败");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondEntrustUserController.createEntrustUser error: {}", e.getMessage(), e);
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据交易ID获取委托人信息")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "tradeId", value = "交易ID", dataType = "Integer", paramType = "query", required = true)
|
|
|
+ })
|
|
|
+ @GetMapping("/getByTradeId")
|
|
|
+ public R<SecondEntrustUser> getByTradeId(@RequestParam Integer tradeId) {
|
|
|
+ log.info("SecondEntrustUserController.getByTradeId tradeId={}", tradeId);
|
|
|
+ try {
|
|
|
+ SecondEntrustUser entrustUser = secondEntrustUserService.getByTradeId(tradeId);
|
|
|
+ return R.data(entrustUser);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondEntrustUserController.getByTradeId error: {}", e.getMessage(), e);
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据ID获取委托人信息")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "委托人ID", dataType = "Integer", paramType = "query", required = true)
|
|
|
+ })
|
|
|
+ @GetMapping("/getById")
|
|
|
+ public R<SecondEntrustUser> getById(@RequestParam Integer id) {
|
|
|
+ log.info("SecondEntrustUserController.getById id={}", id);
|
|
|
+ try {
|
|
|
+ SecondEntrustUser entrustUser = secondEntrustUserService.getById(id);
|
|
|
+ if (entrustUser == null) {
|
|
|
+ return R.fail("委托人信息不存在");
|
|
|
+ }
|
|
|
+ return R.data(entrustUser);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondEntrustUserController.getById error: {}", e.getMessage(), e);
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("更新委托人信息")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @PutMapping("/update/{id}")
|
|
|
+ public R<Boolean> updateEntrustUser(
|
|
|
+ @ApiParam(value = "委托人ID", required = true) @PathVariable Integer id,
|
|
|
+ @Validated @RequestBody SecondEntrustUserDTO dto) {
|
|
|
+ log.info("SecondEntrustUserController.updateEntrustUser id={}, dto={}", id, dto);
|
|
|
+ try {
|
|
|
+ boolean result = secondEntrustUserService.updateEntrustUser(id, dto);
|
|
|
+ if (result) {
|
|
|
+ return R.success("更新成功");
|
|
|
+ }
|
|
|
+ return R.fail("更新失败");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondEntrustUserController.updateEntrustUser error: {}", e.getMessage(), e);
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("删除委托人信息")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "委托人ID", dataType = "Integer", paramType = "query", required = true)
|
|
|
+ })
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ public R<Boolean> deleteEntrustUser(@RequestParam Integer id) {
|
|
|
+ log.info("SecondEntrustUserController.deleteEntrustUser id={}", id);
|
|
|
+ try {
|
|
|
+ boolean result = secondEntrustUserService.deleteEntrustUser(id);
|
|
|
+ if (result) {
|
|
|
+ return R.success("删除成功");
|
|
|
+ }
|
|
|
+ return R.fail("删除失败");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondEntrustUserController.deleteEntrustUser error: {}", e.getMessage(), e);
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据用户电话查询委托人信息列表")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "userPhone", value = "用户电话", dataType = "String", paramType = "query", required = true)
|
|
|
+ })
|
|
|
+ @GetMapping("/getByUserPhone")
|
|
|
+ public R<List<SecondEntrustUser>> getByUserPhone(@RequestParam String userPhone) {
|
|
|
+ log.info("SecondEntrustUserController.getByUserPhone userPhone={}", userPhone);
|
|
|
+ try {
|
|
|
+ List<SecondEntrustUser> list = secondEntrustUserService.getByUserPhone(userPhone);
|
|
|
+ return R.data(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondEntrustUserController.getByUserPhone error: {}", e.getMessage(), e);
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|