/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable @typescript-eslint/no-var-requires */ const router = require('express').Router(); const Mock = require('mockjs'); const wrapper = require('../wrapper'); const { Random } = Mock; const groups = [101, 102, 103, 104]; router.get('/:projectId', (req, res) => { const { projectId: id } = req.params; res.json(wrapper( Mock.mock( { description: Random.csentence(5, 40), gitRemoteUrl: Random.url('http', 'gitlab.seecoder.cn'), groupId: 101, id, name: 'string', }, ), )); }); router.post('/create', (req, res) => { const { body } = req; body.id = 101; res.json(wrapper(body)); }); router.get('/listByUser/:userId', (req, res) => { res.json(wrapper( Mock.mock(Mock.mock({ 'data|5-10': [{ 'id|+1': 100, description: Random.csentence(5, 40), gitRemoteUrl: Random.url('http', 'gitlab.seecoder.cn'), 'groupId|1': groups, name: Random.cname(), }], }).data), )); }); router.post('/members', (req, res) => { res.json(wrapper('success')); }); router.get('/:projectId/members', (req, res) => { res.json(wrapper( Mock.mock({ 'data|4': [ { email: Random.email('smail.nju.edu.cn'), 'id|+1': 1110, phone: 'string', 'role|1': ['学生', '教师', '管理员'], 'username|1': ['hkshu12', 'cyt123', 'Jinyao'], withGitlab: Random.boolean(), }, ], }).data, )); }); router.get('/refresh', (req, res) => { res.json(wrapper('success')); }); module.exports = router;