|
|
@@ -1,41 +1,201 @@
|
|
|
+/**
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
|
|
+ * <p>
|
|
|
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
+ * you may not use this file except in compliance with the License.
|
|
|
+ * You may obtain a copy of the License at
|
|
|
+ * <p>
|
|
|
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
+ * <p>
|
|
|
+ * Unless required by applicable law or agreed to in writing, software
|
|
|
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
+ * See the License for the specific language governing permissions and
|
|
|
+ * limitations under the License.
|
|
|
+ */
|
|
|
package org.zhongzheng.user.controller;
|
|
|
|
|
|
|
|
|
-import org.zhongzheng.common.feignclient.zzbusinessuser.IUserClient;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.SneakyThrows;
|
|
|
+import org.zhongzheng.common.mybatisplus.Condition;
|
|
|
+import org.zhongzheng.common.mybatisplus.Query;
|
|
|
+import org.zhongzheng.common.secure.ZhongZhengUser;
|
|
|
+import org.zhongzheng.common.secure.annotation.PreAuth;
|
|
|
+import org.zhongzheng.common.secure.SecureUtil;
|
|
|
import org.zhongzheng.common.utils.R;
|
|
|
+import org.zhongzheng.common.env.ZhongZhengConstant;
|
|
|
+import org.zhongzheng.common.env.RoleConstant;
|
|
|
+import org.zhongzheng.common.utils.Func;
|
|
|
import org.zhongzheng.common.feignclient.zzbusinessuser.entity.User;
|
|
|
-import org.zhongzheng.common.feignclient.zzbusinessuser.entity.UserInfo;
|
|
|
-import org.zhongzheng.common.feignclient.zzbusinessuser.entity.UserOauth;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.zhongzheng.user.service.IUserService;
|
|
|
+import org.zhongzheng.user.vo.UserVO;
|
|
|
+import org.zhongzheng.user.wrapper.UserWrapper;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.BufferedInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 控制器
|
|
|
+ *
|
|
|
+ * @author Chill
|
|
|
+ */
|
|
|
@RestController
|
|
|
-@RequestMapping("/user")
|
|
|
-public class UserController implements IUserClient {
|
|
|
- //private IUserService service;
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<UserInfo> userInfo(Long userId) {
|
|
|
- return R.data( new UserInfo());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @GetMapping(API_PREFIX + "/user-info")
|
|
|
- public R<UserInfo> userInfo(String tenantId, String account, String password) {
|
|
|
- return R.data( new UserInfo());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @PostMapping(API_PREFIX + "/user-auth-info")
|
|
|
- public R<UserInfo> userAuthInfo(UserOauth userOauth) {
|
|
|
- return R.data( new UserInfo());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @PostMapping(API_PREFIX + "/save-user")
|
|
|
- public R<Boolean> saveUser(User user) {
|
|
|
- return R.data( false );
|
|
|
- }
|
|
|
+@RequestMapping
|
|
|
+@AllArgsConstructor
|
|
|
+public class UserController {
|
|
|
+
|
|
|
+ private IUserService userService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询单条
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "查看详情", notes = "传入id")
|
|
|
+ @GetMapping("/detail")
|
|
|
+ public R<UserVO> detail(User user) throws SQLException {
|
|
|
+ User detail = userService.getOne(Condition.getQueryWrapper(user));
|
|
|
+ return R.data(UserWrapper.build().entityVO(detail));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询单条
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order =2)
|
|
|
+ @ApiOperation(value = "查看详情", notes = "传入id")
|
|
|
+ @GetMapping("/info")
|
|
|
+ public R<UserVO> info(ZhongZhengUser user) {
|
|
|
+ User detail = userService.getById(user.getUserId());
|
|
|
+ return R.data(UserWrapper.build().entityVO(detail));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"),
|
|
|
+ @ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string")
|
|
|
+ })
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "列表", notes = "传入account和realName")
|
|
|
+ public R<IPage<UserVO>> list(@ApiIgnore @RequestParam Map<String, Object> user, Query query, ZhongZhengUser zzUser) throws SQLException {
|
|
|
+ System.out.println("list user 1:" + user.toString());
|
|
|
+ QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user, User.class);
|
|
|
+ System.out.println("list user 2:" + query.toString());
|
|
|
+ System.out.println("list user 3:" + zzUser.toString());
|
|
|
+ IPage<User> pages = userService.page(Condition.getPage(query), (!zzUser.getTenantId().equals(ZhongZhengConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(User::getTenantId, zzUser.getTenantId()) : queryWrapper);
|
|
|
+ return R.data(UserWrapper.build().pageVO(pages));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增或修改
|
|
|
+ */
|
|
|
+ @PostMapping("/submit")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "新增或修改", notes = "传入User")
|
|
|
+ public R submit(@Valid @RequestBody User user) {
|
|
|
+ System.out.println("submit user:" + user.toString());
|
|
|
+
|
|
|
+ return R.status(userService.submit(user));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "修改", notes = "传入User")
|
|
|
+ public R update(@Valid @RequestBody User user) {
|
|
|
+ return R.status(userService.updateById(user));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiOperation(value = "删除", notes = "传入地基和")
|
|
|
+ public R remove(@RequestParam String ids) {
|
|
|
+ return R.status(userService.deleteLogic(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置菜单权限
|
|
|
+ *
|
|
|
+ * @param userIds
|
|
|
+ * @param roleIds
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/grant")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合")
|
|
|
+ public R grant(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds,
|
|
|
+ @ApiParam(value = "roleId集合", required = true) @RequestParam String roleIds) {
|
|
|
+ boolean temp = userService.grant(userIds, roleIds);
|
|
|
+ return R.status(temp);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/reset-password")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "初始化密码", notes = "传入userId集合")
|
|
|
+ public R resetPassword(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds) {
|
|
|
+ boolean temp = userService.resetPassword(userIds);
|
|
|
+ return R.status(temp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改密码
|
|
|
+ *
|
|
|
+ * @param oldPassword
|
|
|
+ * @param newPassword
|
|
|
+ * @param newPassword1
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/update-password")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperation(value = "修改密码", notes = "传入密码")
|
|
|
+ public R updatePassword(ZhongZhengUser user, @ApiParam(value = "旧密码", required = true) @RequestParam String oldPassword,
|
|
|
+ @ApiParam(value = "新密码", required = true) @RequestParam String newPassword,
|
|
|
+ @ApiParam(value = "新密码", required = true) @RequestParam String newPassword1) {
|
|
|
+ boolean temp = userService.updatePassword(user.getUserId(), oldPassword, newPassword, newPassword1);
|
|
|
+ return R.status(temp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户列表
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/user-list")
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
+ @ApiOperation(value = "用户列表", notes = "传入user")
|
|
|
+ public R<List<User>> userList(User user) throws SQLException {
|
|
|
+ List<User> list = userService.list(Condition.getQueryWrapper(user));
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|