feat(farm): 新增根据协议类型获取协议详情接口
- 在 AgreementController 中添加根据类型获取协议的 GET 接口 - 为接口添加 @PermitAll 注解以允许匿名访问 - 在 AgreementService 中定义 getAgreementByType 服务方法- 在 AgreementServiceImpl 中实现根据 type 查询协议逻辑 - 使用 QueryWrapper 构造查询条件 - 添加 Swagger 注解描述接口用途
This commit is contained in:
@@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.farm.service.agreement.AgreementService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -47,4 +48,11 @@ public class AgreementController {
|
||||
public CommonResult<Integer> updateAgreement(@Valid @RequestBody AgreementVO req) {
|
||||
return agreementService.updateAgreement(req);
|
||||
}
|
||||
|
||||
@GetMapping("/type/{type}")
|
||||
@Operation(summary = "协议-详情")
|
||||
@PermitAll
|
||||
public CommonResult<AgreementDO> getAgreementByType(@PathVariable("type") String type) {
|
||||
return agreementService.getAgreementByType(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,11 @@ public interface AgreementService {
|
||||
* 协议 - 修改
|
||||
* */
|
||||
CommonResult<Integer> updateAgreement(@Valid AgreementVO updateReqVO);
|
||||
|
||||
/**
|
||||
* api 接口
|
||||
*
|
||||
* 协议 - 根据协议类型获取
|
||||
* */
|
||||
CommonResult<AgreementDO> getAgreementByType(String type);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.agreement.vo.AgreementReqVO
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.agreement.vo.AgreementVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.agreement.AgreementDO;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.agreement.AgreementMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -52,4 +53,10 @@ public class AgreementServiceImpl implements AgreementService {
|
||||
agreementDO.setContext(res.getContext());
|
||||
return CommonResult.success(agreementMapper.updateById(agreementDO));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommonResult<AgreementDO> getAgreementByType(String type) {
|
||||
return CommonResult.success(agreementMapper.selectOne(new QueryWrapper<AgreementDO>().eq("type", type)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user