feat(genmai): 集成跟卖精灵账号管理系统跟
- 新增卖精灵账号管理功能,支持多账号切换 - 实现账号增删改查接口与前端交互逻辑 -优化打开跟卖精灵流程,增加账号选择界面 - 添加账号权限限制与订阅升级提醒 - 完善后端账号实体类及数据库映射 - 更新系统控制器以支持指定账号启动功能- 调整HTTP请求路径适配新工具模块路由- 升级客户端版本至2.5.3并优化代码结构
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.web.controller.tool;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.system.domain.GenmaiAccount;
|
||||
import com.ruoyi.system.domain.ClientAccount;
|
||||
import com.ruoyi.system.mapper.GenmaiAccountMapper;
|
||||
import com.ruoyi.system.mapper.ClientAccountMapper;
|
||||
import com.ruoyi.system.service.IGenmaiAccountService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/tool/genmai")
|
||||
@Anonymous
|
||||
public class GenmaiAccountController {
|
||||
|
||||
@Autowired
|
||||
private IGenmaiAccountService accountService;
|
||||
@Autowired
|
||||
private ClientAccountMapper clientAccountMapper;
|
||||
@Autowired
|
||||
private GenmaiAccountMapper genmaiAccountMapper;
|
||||
|
||||
@GetMapping("/accounts")
|
||||
public R<?> listAccounts(String name) {
|
||||
return R.ok(accountService.listSimple(name));
|
||||
}
|
||||
|
||||
@GetMapping("/account-limit")
|
||||
public R<?> getAccountLimit(String name) {
|
||||
ClientAccount client = clientAccountMapper.selectClientAccountByUsername(name);
|
||||
int limit = "paid".equals(client.getAccountType()) && new Date().before(client.getExpireTime()) ? 3 : 1;
|
||||
GenmaiAccount query = new GenmaiAccount();
|
||||
query.setClientUsername(name);
|
||||
int count = genmaiAccountMapper.selectList(query).size();
|
||||
return R.ok(Map.of("limit", limit, "count", count));
|
||||
}
|
||||
|
||||
@PostMapping("/accounts")
|
||||
public R<?> saveAccount(@RequestBody GenmaiAccount body, String name) {
|
||||
if (body.getId() == null) {
|
||||
String token = accountService.validateAndGetToken(body.getUsername(), body.getPassword());
|
||||
body.setToken(token);
|
||||
body.setTokenExpireAt(new Date(System.currentTimeMillis() + 30L * 24 * 60 * 60 * 1000));
|
||||
}
|
||||
return R.ok(Map.of("id", accountService.saveOrUpdate(body, name)));
|
||||
}
|
||||
|
||||
@DeleteMapping("/accounts/{id}")
|
||||
public R<?> remove(@PathVariable Long id) {
|
||||
accountService.remove(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/accounts/{id}/validate")
|
||||
public R<?> validateAndRefresh(@PathVariable Long id) {
|
||||
return accountService.refreshTokenIfNeeded(id) ? R.ok() : R.fail("刷新失败");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user