Jay
2024-11-01 03e8aca3ad6201c0d74e00d4c8d7367cdaaa54f9
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java
@@ -7,10 +7,12 @@
import com.iailab.module.data.channel.http.service.HttpTokenService;
import com.iailab.module.data.channel.http.vo.HttpTokenPageReqVO;
import com.iailab.module.data.channel.http.vo.HttpTokenRespVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@@ -22,52 +24,59 @@
 * @createTime 2024年08月27日
 */
@RestController
@RequestMapping("/data/http/token")
@RequestMapping("/data/channel/http/token")
public class HttpTokenController {
    @Resource
    private HttpTokenService httpTokenService;
    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
    @GetMapping("page")
    public CommonResult<PageResult<HttpTokenRespVO>> page(@Valid HttpTokenPageReqVO reqVO) {
        PageResult<HttpTokenEntity> page = httpTokenService.queryPage(reqVO);
        return success(BeanUtils.toBean(page, HttpTokenRespVO.class));
    }
    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
    @GetMapping("list")
    public CommonResult<List<HttpTokenEntity>> list(){
        List<HttpTokenEntity> list = httpTokenService.list();
        return new CommonResult<List<HttpTokenEntity>>().setData(list);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
    @GetMapping("/info/{id}")
    public CommonResult<HttpTokenEntity> info(@PathVariable("id") String id){
        HttpTokenEntity info= httpTokenService.info(id);
        return success(info);
    }
    @PostMapping("/add")
    public CommonResult<Boolean> add(@RequestBody HttpTokenEntity HttpTokenEntity){
        String id = UUID.randomUUID().toString();
        HttpTokenEntity.setId(id);
    @PreAuthorize("@ss.hasPermission('data:channel-http:create')")
    @PostMapping("/create")
    public CommonResult<Boolean> create(@RequestBody HttpTokenEntity HttpTokenEntity){
        HttpTokenEntity.setId(UUID.randomUUID().toString());
        HttpTokenEntity.setUpdateTime(new Date());
        httpTokenService.add(HttpTokenEntity);
        return success(true);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-http:update')")
    @PutMapping("/update")
    public CommonResult<Boolean> update(@RequestBody HttpTokenEntity HttpTokenEntity) {
        httpTokenService.update(HttpTokenEntity);
        return success(true);
    }
    @PreAuthorize("@ss.hasPermission('data:channel-http:delete')")
    @DeleteMapping("/delete")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        httpTokenService.delete(id);
        return success(true);
    }
    @GetMapping("/api-id/{apiId}")
    public CommonResult<HttpTokenEntity> apiId(@PathVariable("apiId") String apiId) {
    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
    @GetMapping("/api-id")
    public CommonResult<HttpTokenEntity> apiId(@RequestParam("apiId") String apiId) {
        HttpTokenEntity info = httpTokenService.getByApiId(apiId);
        return success(info);
    }