| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | @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(); |
| | | log.info("{}添加代理商{}", user.getInviteId(), agentUser.getInviteId()); |
| | | 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(); |
| | | } |
| | | } |