Helius
2020-06-18 a3ee255827cd44b92c697e5f3e313359e4407547
src/main/java/com/xcong/excoin/modules/agent/controller/AgentController.java
@@ -1,5 +1,7 @@
package com.xcong.excoin.modules.agent.controller;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.xcong.excoin.common.annotation.ControllerEndpoint;
import com.xcong.excoin.common.controller.BaseController;
import com.xcong.excoin.common.entity.FebsResponse;
import com.xcong.excoin.common.entity.QueryRequest;
@@ -10,12 +12,11 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Map;
/**
@@ -34,15 +35,44 @@
    @GetMapping("getList")
    @RequiresPermissions("agent:view")
    public FebsResponse getList(AgentUser agentUser, QueryRequest queryRequest) {
        User user = getCurrentUser();
        agentUser.setRefererId(user.getInviteId());
        Map<String, Object> map = getDataTable(agentService.findAgentList(agentUser, queryRequest));
        return new FebsResponse().success().data(map);
    }
    @PostMapping("add")
    @RequiresPermissions("agent:add")
    @ControllerEndpoint(operation = "新增代理商", exceptionMessage = "新增代理商失败")
    public FebsResponse add(@Valid AgentUser agentUser) {
        User user = getCurrentUser();
        agentService.addAgent(agentUser, user);
        return new FebsResponse().success();
    }
    @GetMapping("del/{ids}")
    @RequiresPermissions("agent:del")
    @ControllerEndpoint(operation = "删除代理商", exceptionMessage = "删除代理商失败")
    public FebsResponse del(@NotBlank(message = "{required}") @PathVariable("ids") String ids) {
        String[] idsArr = ids.split(StringPool.COMMA);
        agentService.delAgent(idsArr);
        return new FebsResponse().success();
    }
    @PostMapping("reset/{id}")
    @RequiresPermissions("agent:password:reset")
    @ControllerEndpoint(operation = "重置密码", exceptionMessage = "重置密码失败")
    public FebsResponse reset(@NotNull(message = "{required}") @PathVariable("id") Long id) {
        agentService.resetPwd(id);
        return new FebsResponse().success();
    }
    @PostMapping("edit")
    @RequiresPermissions("agent:edit")
    @ControllerEndpoint(operation = "修改代理商", exceptionMessage = "修改代理商失败")
    public FebsResponse edit(@Valid AgentUser agentUser) {
        User user = getCurrentUser();
        agentService.editAgent(agentUser, user);
        return new FebsResponse().success();
    }
}