| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- package com.hr.controller;
- import com.github.pagehelper.PageInfo;
- import com.hr.param.AccountInterfaceParam;
- import com.hr.param.InterfaceConfigParam;
- import com.hr.param.IpInterfaceParam;
- import com.hr.param.SwitchStatusParam;
- import com.hr.service.IpTokenInterfaceService;
- import com.hr.service.IpInterfaceService;
- import com.hr.vo.*;
- import com.yy.basedevelop.common.data.BasePageResult;
- import com.yy.basedevelop.common.data.BaseReturnDto;
- import com.yy.basedevelop.common.http.config.TokenUtil;
- import com.yy.basedevelop.dto.LoginUser;
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.annotations.tags.Tag;
- import org.apache.commons.lang3.RandomStringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.domain.Page;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * 接口管理
- * @author : longhoo
- * @date : 2025-10-10
- */
- @RestController
- @RequestMapping("/ipInterface")
- @Tag(name = "接口管理")
- public class IpInterfaceController {
- @Autowired
- private IpInterfaceService ipInterfaceService;
- @Autowired
- private IpTokenInterfaceService ipTokenInterfaceService;
-
- /**
- * 分页查询
- *
- * @param ipInterfaceParam 筛选条件
- * @return 查询结果
- */
- @Operation(summary = "分页查询")
- @GetMapping("/list")
- public BasePageResult<IpInterfaceVO> paginQuery(IpInterfaceParam ipInterfaceParam){
- BasePageResult<IpInterfaceVO> ipAccountPOS = ipInterfaceService.paginQuery(ipInterfaceParam, ipInterfaceParam.getPageNum(), ipInterfaceParam.getPageSize());
- return ipAccountPOS;
- }
-
- /**
- * 新增数据
- *
- * @param ipInterfaceParam 实例对象
- * @return 实例对象
- */
- @Operation(summary = "新增/更新数据")
- @PostMapping("/saveOrUpdate")
- public BaseReturnDto<IpAccountVO> saveOrUpdate(@RequestBody IpInterfaceParam ipInterfaceParam){
- LoginUser user= TokenUtil.getUser();
- ipInterfaceService.saveOrUpdate(ipInterfaceParam,user.getUsername(),user.getUserid());
- return BaseReturnDto.success();
- }
- /**
- * 通过主键删除数据
- *
- * @param id 主键
- * @return 是否成功
- */
- @Operation(summary = "通过主键删除数据")
- @DeleteMapping("/delete/{id}")
- public BaseReturnDto<Boolean> deleteById(@PathVariable Long id){
- return BaseReturnDto.success(ipInterfaceService.deleteById(id));
- }
- /**
- * 修改状态
- * @param switchStatusParam 主键
- * @return 是否成功
- */
- @Operation(summary = "修改状态")
- @PostMapping("/switchStatus")
- public BaseReturnDto<Boolean> switchStatus(@RequestBody SwitchStatusParam switchStatusParam){
- return BaseReturnDto.success(ipInterfaceService.switchStatus(switchStatusParam));
- }
- /**
- * 接口下拉列表
- * @return 列表
- */
- @Operation(summary = "接口下拉列表")
- @PostMapping("/optionList")
- public BaseReturnDto<List<NameValueVO>> optionList(){
- return BaseReturnDto.success(ipInterfaceService.optionList());
- }
- /**
- * 账号配置接口
- */
- @Operation(summary = "账号配置接口")
- @PostMapping("/interfaceConfig")
- public BaseReturnDto interfaceConfig(@RequestBody InterfaceConfigParam param){
- LoginUser user = TokenUtil.getUser();
- ipTokenInterfaceService.interfaceConfig(param,user);
- return BaseReturnDto.success();
- }
- /**
- * 生成 token
- */
- @Operation(summary = "生成 token")
- @PostMapping("/token/generate")
- public BaseReturnDto<SecretVO> generateToken(){
- SecretVO vo = new SecretVO();
- String secret = RandomStringUtils.random(64, "0123456789abcdef");
- String token = RandomStringUtils.random(32, "0123456789abcdef");
- vo.setToken(token);
- vo.setSecret(secret);
- return BaseReturnDto.success(vo);
- }
- /**
- * 删除账号接口配置
- */
- @Operation(summary = "删除账号关联的接口")
- @DeleteMapping("/delAccountInterface/{id}")
- public BaseReturnDto delAccountInterface(@PathVariable Long id){
- LoginUser user = TokenUtil.getUser();
- ipTokenInterfaceService.delAccountInterface(id,user);
- return BaseReturnDto.success();
- }
- /**
- * 查询账号下关联的接口列表
- */
- @Operation(summary = "查询账号下关联的接口列表")
- @PostMapping("/account/ref/list")
- public BasePageResult<AccountInterfaceVO> accountInterfaceList(@RequestBody AccountInterfaceParam pageParam){
- BasePageResult<AccountInterfaceVO> result = ipTokenInterfaceService.accountInterfaceList(pageParam);
- return result;
- }
- /**
- * 账号关联接口修改接口状态
- * @param switchStatusParam 主键
- * @return 是否成功
- */
- @Operation(summary = "修改状态")
- @PostMapping("/account/interface/ref/switchStatus")
- public BaseReturnDto<Boolean> accountInterfaceRefSwitch(@RequestBody SwitchStatusParam switchStatusParam){
- return BaseReturnDto.success(ipTokenInterfaceService.switchStatus(switchStatusParam));
- }
- }
|