forked from rongchao/epmet-cloud-rizhao
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.7 KiB
123 lines
3.7 KiB
/**
|
|
* Copyright 2018 人人开源 https://www.renren.io
|
|
* <p>
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
* <p>
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* <p>
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package com.epmet.controller;
|
|
|
|
import com.epmet.commons.tools.page.PageData;
|
|
import com.epmet.commons.tools.utils.ExcelUtils;
|
|
import com.epmet.commons.tools.utils.Result;
|
|
import com.epmet.commons.tools.validator.AssertUtils;
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
import com.epmet.commons.tools.validator.group.AddGroup;
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup;
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup;
|
|
import com.epmet.dto.UserRoleDTO;
|
|
import com.epmet.dto.form.UserRoleFormDTO;
|
|
import com.epmet.dto.result.UserRoleResultDTO;
|
|
import com.epmet.excel.UserRoleExcel;
|
|
import com.epmet.service.UserRoleService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
* 用户角色关系表
|
|
*
|
|
* @author generator generator@elink-cn.com
|
|
* @since v1.0.0 2020-03-30
|
|
*/
|
|
@RestController
|
|
@RequestMapping("userrole")
|
|
public class UserRoleController {
|
|
|
|
@Autowired
|
|
private UserRoleService userRoleService;
|
|
|
|
@GetMapping("page")
|
|
public Result<PageData<UserRoleDTO>> page(@RequestParam Map<String, Object> params) {
|
|
PageData<UserRoleDTO> page = userRoleService.page(params);
|
|
return new Result<PageData<UserRoleDTO>>().ok(page);
|
|
}
|
|
|
|
@GetMapping("{id}")
|
|
public Result<UserRoleDTO> get(@PathVariable("id") String id) {
|
|
UserRoleDTO data = userRoleService.get(id);
|
|
return new Result<UserRoleDTO>().ok(data);
|
|
}
|
|
|
|
@PostMapping
|
|
public Result save(@RequestBody UserRoleDTO dto) {
|
|
//效验数据
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
|
userRoleService.save(dto);
|
|
return new Result();
|
|
}
|
|
|
|
@PutMapping
|
|
public Result update(@RequestBody UserRoleDTO dto) {
|
|
//效验数据
|
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
userRoleService.update(dto);
|
|
return new Result();
|
|
}
|
|
|
|
@DeleteMapping
|
|
public Result delete(@RequestBody String[] ids) {
|
|
//效验数据
|
|
AssertUtils.isArrayEmpty(ids, "id");
|
|
userRoleService.delete(ids);
|
|
return new Result();
|
|
}
|
|
|
|
@GetMapping("export")
|
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
|
List<UserRoleDTO> list = userRoleService.list(params);
|
|
ExcelUtils.exportExcelToTarget(response, null, list, UserRoleExcel.class);
|
|
}
|
|
|
|
/**
|
|
* @return UserRoleResultDTO
|
|
* @Description 根据用户Id、来源app、客户Id查询用户角色
|
|
* @Param userRoleFormDTO
|
|
* @Author wangc
|
|
* @Date 2020.03.30 15:35
|
|
**/
|
|
@PostMapping("getuserroleinfo")
|
|
public Result<List<UserRoleResultDTO>> getUserRoleInfo(@RequestBody UserRoleFormDTO userRoleFormDTO) {
|
|
|
|
ValidatorUtils.validateEntity(userRoleFormDTO);
|
|
|
|
return userRoleService.getUserRoleInfo(userRoleFormDTO);
|
|
}
|
|
|
|
/**
|
|
* 添加用户角色关系
|
|
*
|
|
* @param userRoleDTO 参数
|
|
* @return Result
|
|
*/
|
|
@PostMapping("saveUserRole")
|
|
public Result saveUserRole(@RequestBody UserRoleDTO userRoleDTO) {
|
|
return userRoleService.saveUserRole(userRoleDTO);
|
|
}
|
|
|
|
|
|
}
|