12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- 'use strict';
- const await = require('await-stream-ready/lib/await');
- const Controller = require('egg').Controller;
- class UserController extends Controller {
- async list() {
- const {ctx, service} = this;
- let query = ctx.request.query;
- let ret = await service.adminUser.list(query);
- ctx.adminOK(ret);
- }
- async delete() {
- const {ctx, service} = this;
- let id = ctx.request.query.id;
- let ret = await service.adminUser.delete(id);
- ctx.adminOK(ret, "删除成功");
- }
- async edit() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.adminUser.edit( data );
- ctx.adminOK(ret, "更新成功");
- }
- async add() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.adminUser.add( data );
- ctx.adminOK(ret, "添加成功");
- }
- async resetpwd() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.adminUser.resetpwd( data );
- ctx.adminOK(ret, "重置成功");
- }
- async lock() {
- const {ctx, service} = this;
- let data = ctx.request.body;
- let ret = await service.adminUser.lockUser( data );
- ctx.adminOK(ret, "冻结成功");
- }
-
- async teachers() {
- const {ctx, service} = this;
- let query = ctx.request.query;
- query.role = 1;
- let ret = await service.adminUser.list(query);
-
- ctx.adminOK(ret);
- }
- async getProfile() {
- const {ctx, service} = this;
- await ctx.queryHandleByService(service.adminUser, "getUserProfile");
- }
- async getUserRecord() {
- const {ctx, service} = this;
- await ctx.queryHandleByService(service.record, "getUserRecord");
- }
- async getUserRecordList() {
- const {ctx, service} = this;
- await ctx.queryHandleByService(service.record, "getUserRecordList");
- }
- async commentUserRecord() {
- const {ctx, service} = this;
- await ctx.bodyHandleByService(service.adminUser, "commentUserRecord", "提交成功");
- }
- async exportXls() {
- const {ctx, service} = this;
- ctx.set("Content-Type", "application/vnd.openxmlformats");
- ctx.set("Content-Disposition","attachment;filename*=UTF-8 xx.xlsx");
- let ret = await service.adminUser.exportUserListXls( ctx.request.query );
- ctx.body = ret;
- }
- async exportProfileXls() {
- const {ctx, service} = this;
- ctx.set("Content-Type", "application/vnd.openxmlformats");
- ctx.set("Content-Disposition","attachment;filename*=UTF-8 xx.xlsx");
- let ret = await service.adminUser.exportProfileXls( ctx.request.query );
- ctx.body = ret;
- }
- }
- module.exports = UserController;
|