AdministerController.java 2.87 KB
package com.zhongzhi.controller;

import com.zhongzhi.common.constant.Platform;
import com.zhongzhi.common.utils.LoginRequired;
import com.zhongzhi.common.utils.ResponseData;
import com.zhongzhi.dto.administer.AdministerPageDTO;
import com.zhongzhi.dto.administer.LoginDTO;
import com.zhongzhi.model.AdministerDO;
import com.zhongzhi.service.AdministerService;
import com.zhongzhi.vo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 中心管理账户表 前端控制器
 * </p>
 *
 * @author DengMin
 * @since 2021-04-28
 */
@RestController
@Api(tags = "中心管理账户")
@RequestMapping("/administer")
public class AdministerController {

    @Autowired
    private AdministerService administerService;

    @PostMapping(value = "/login")
    @ApiOperation("中心端 --- 登录:手机号/telephone, code/验证码")
    public ResponseVO login(@RequestBody LoginDTO loginDTO) {
        return ResponseData.generateCreatedResponse(0, administerService.login(loginDTO));
    }

    @PostMapping(value = "/getAdministerPage")
    @LoginRequired({Platform.center})
    @ApiOperation("中心端 --- 成员管理分页查询:listItem/角色、 username/搜索名称、pageNo/当前页数、pageSize/每页显示条数")
    public ResponseVO getAdministerPage(@RequestBody AdministerPageDTO administerPageDTO) {
        return ResponseData.generateCreatedResponse(0, administerService.getAdministerPage(administerPageDTO));
    }

    @PostMapping(value = "/createAdminister")
    @LoginRequired({Platform.center})
    @ApiOperation("中心端 --- 新增成员:username/名称、telephone/手机号、avatar/头像、role/角色")
    public ResponseVO createAdminister(@RequestBody AdministerDO administerDO) {
        administerService.save(administerDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/updateAdminister")
    @LoginRequired({Platform.center})
    @ApiOperation("中心端 --- 编辑成员:id/成员ID、username/名称、telephone/手机号、avatar/头像、role/角色")
    public ResponseVO updateAdminister(@RequestBody AdministerDO administerDO) {
        administerService.updateById(administerDO);
        return ResponseData.generateCreatedResponse(0);
    }

    @PostMapping(value = "/deleteById")
    @LoginRequired({Platform.center})
    @ApiOperation("中心端 --- 删除成员:id/成员ID")
    public ResponseVO delete(@RequestBody AdministerDO administerDO) {
        administerService.removeById(administerDO.getId());
        return ResponseData.generateCreatedResponse(0);
    }
}