133 lines
4.4 KiB
Java
133 lines
4.4 KiB
Java
package com.gxwebsoft.common.system.controller;
|
|
|
|
import com.gxwebsoft.common.core.web.BaseController;
|
|
import com.gxwebsoft.common.system.entity.User;
|
|
import com.gxwebsoft.common.system.service.UserOauthService;
|
|
import com.gxwebsoft.common.system.entity.UserOauth;
|
|
import com.gxwebsoft.common.system.param.UserOauthParam;
|
|
import com.gxwebsoft.common.core.web.ApiResult;
|
|
import com.gxwebsoft.common.core.web.PageResult;
|
|
import com.gxwebsoft.common.core.web.PageParam;
|
|
import com.gxwebsoft.common.core.web.BatchParam;
|
|
import com.gxwebsoft.common.core.annotation.OperationLog;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 第三方用户信息表控制器
|
|
*
|
|
* @author 科技小王子
|
|
* @since 2023-10-07 22:39:46
|
|
*/
|
|
@Api(tags = "第三方用户信息表管理")
|
|
@RestController
|
|
@RequestMapping("/api/system/user-oauth")
|
|
public class UserOauthController extends BaseController {
|
|
@Resource
|
|
private UserOauthService userOauthService;
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:list')")
|
|
@OperationLog
|
|
@ApiOperation("分页查询第三方用户信息表")
|
|
@GetMapping("/page")
|
|
public ApiResult<PageResult<UserOauth>> page(UserOauthParam param) {
|
|
// 使用关联查询
|
|
return success(userOauthService.pageRel(param));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:list')")
|
|
@OperationLog
|
|
@ApiOperation("查询全部第三方用户信息表")
|
|
@GetMapping()
|
|
public ApiResult<List<UserOauth>> list(UserOauthParam param) {
|
|
// 使用关联查询
|
|
return success(userOauthService.listRel(param));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:list')")
|
|
@OperationLog
|
|
@ApiOperation("根据id查询第三方用户信息表")
|
|
@GetMapping("/{id}")
|
|
public ApiResult<UserOauth> get(@PathVariable("id") Integer id) {
|
|
// 使用关联查询
|
|
return success(userOauthService.getByIdRel(id));
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:save')")
|
|
@OperationLog
|
|
@ApiOperation("添加第三方用户信息表")
|
|
@PostMapping()
|
|
public ApiResult<?> save(@RequestBody UserOauth userOauth) {
|
|
// 记录当前登录用户id
|
|
User loginUser = getLoginUser();
|
|
if (loginUser != null) {
|
|
userOauth.setUserId(loginUser.getUserId());
|
|
}
|
|
if (userOauthService.save(userOauth)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:update')")
|
|
@OperationLog
|
|
@ApiOperation("修改第三方用户信息表")
|
|
@PutMapping()
|
|
public ApiResult<?> update(@RequestBody UserOauth userOauth) {
|
|
if (userOauthService.updateById(userOauth)) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:remove')")
|
|
@OperationLog
|
|
@ApiOperation("删除第三方用户信息表")
|
|
@DeleteMapping("/{id}")
|
|
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
|
if (userOauthService.removeById(id)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:save')")
|
|
@OperationLog
|
|
@ApiOperation("批量添加第三方用户信息表")
|
|
@PostMapping("/batch")
|
|
public ApiResult<?> saveBatch(@RequestBody List<UserOauth> list) {
|
|
if (userOauthService.saveBatch(list)) {
|
|
return success("添加成功");
|
|
}
|
|
return fail("添加失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:update')")
|
|
@OperationLog
|
|
@ApiOperation("批量修改第三方用户信息表")
|
|
@PutMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserOauth> batchParam) {
|
|
if (batchParam.update(userOauthService, "id")) {
|
|
return success("修改成功");
|
|
}
|
|
return fail("修改失败");
|
|
}
|
|
|
|
@PreAuthorize("hasAuthority('sys:userOauth:remove')")
|
|
@OperationLog
|
|
@ApiOperation("批量删除第三方用户信息表")
|
|
@DeleteMapping("/batch")
|
|
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
|
if (userOauthService.removeByIds(ids)) {
|
|
return success("删除成功");
|
|
}
|
|
return fail("删除失败");
|
|
}
|
|
|
|
}
|