Procházet zdrojové kódy

feat: rpc update user

Blizzard před 1 rokem
rodič
revize
853f91c883

+ 36 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/UpdateUserDTO.java

@@ -0,0 +1,36 @@
+package com.wtkj.dto;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-26 11:51
+ * @describe
+ */
+@Data
+public class UpdateUserDTO implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@NotNull(message = "userId can't be null")
+	private Long userId;
+
+	private String name;
+
+	private String phone;
+
+	@NotNull(message = "roleId can't be null")
+	private String roleIds;
+
+	private String postIds;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@NotNull(message = "deptId can't be null")
+	private Long deptId;
+}

+ 2 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/UploadFileDTO.java

@@ -15,6 +15,8 @@ import java.io.Serializable;
 @Data
 public class UploadFileDTO implements Serializable {
 
+	private static final long serialVersionUID = 1L;
+
 	@NotNull(message = "projectId不可为空")
 	@JsonSerialize(using = ToStringSerializer.class)
 	private Long projectId;

+ 15 - 4
blade-service/wt-okr/src/main/java/com/wtkj/controller/ContactController.java

@@ -2,6 +2,7 @@ package com.wtkj.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.wtkj.dto.UpdateUserDTO;
 import com.wtkj.entity.ContactOuter;
 import com.wtkj.service.IContactOuterService;
 import com.wtkj.service.IWorkStatusService;
@@ -15,10 +16,9 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
 
 /**
  * @author Blizzard
@@ -69,4 +69,15 @@ public class ContactController {
 		return R.data(workStatusVO);
 	}
 
+	/**
+	 * 修改用户信息
+	 */
+	@PostMapping("/update-user")
+	@ApiOperation(value = "修改用户信息", notes = "传入")
+	@ApiOperationSupport(order = 3)
+	public R updateUser(@RequestBody @Valid UpdateUserDTO dto) {
+		return R.status(contactOuterService.updateUser(dto));
+	}
+
+
 }

+ 19 - 12
blade-service/wt-okr/src/main/java/com/wtkj/controller/IndexController.java

@@ -2,6 +2,7 @@ package com.wtkj.controller;
 
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.wtkj.entity.Task;
+import com.wtkj.entity.WorkStatus;
 import com.wtkj.service.IIndexService;
 import com.wtkj.service.IWorkStatusService;
 import com.wtkj.wrapper.IndexTaskScheduleWrapper;
@@ -12,10 +13,7 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -41,17 +39,26 @@ public class IndexController {
 	@GetMapping("/work-status")
 	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "我的状态", notes = "")
-	public R wordStatus() {
+	public R workStatus() {
 		Long userId = AuthUtil.getUserId();
 		return R.data(workStatus.workStatus(userId));
 	}
 
+	/**
+	 * 修改工作状态
+	 */
+	@PostMapping("/submit-work-status")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "新增或者修改工作状态", notes = "")
+	public R submit(@RequestBody WorkStatus status) {
+		return R.status(workStatus.saveOrUpdate(status));
+	}
 
 	/**
 	 * 首页统计
 	 */
 	@GetMapping("/project-and-task")
-	@ApiOperationSupport(order = 2)
+	@ApiOperationSupport(order = 3)
 	@ApiOperation(value = "项目和任务统计", notes = "")
 	public R projectAndTask(@RequestParam Long topDept) {
 		return R.data(indexService.projectAndTaskSummary(topDept));
@@ -61,7 +68,7 @@ public class IndexController {
 	 * 待办事项
 	 */
 	@GetMapping("/todo-list")
-	@ApiOperationSupport(order = 3)
+	@ApiOperationSupport(order = 4)
 	@ApiOperation(value = "待办事项", notes = "传入isRead查看状态 0:全部 1:已读 2: 未读 默认未读,分页参数")
 	public R todoList(@RequestParam(defaultValue = "2") Integer isRead, Query query) {
 		return R.data(indexService.todoList(isRead, Condition.getPage(query)));
@@ -71,7 +78,7 @@ public class IndexController {
 	 * 学习资料
 	 */
 	@GetMapping("/study-list")
-	@ApiOperationSupport(order = 4)
+	@ApiOperationSupport(order = 5)
 	@ApiOperation(value = "学习资料", notes = "")
 	public R noticeList(Query query) {
 		return R.data(indexService.studyList(Condition.getPage(query)));
@@ -81,7 +88,7 @@ public class IndexController {
 	 * 阅读消息
 	 */
 	@GetMapping("/message-detail")
-	@ApiOperationSupport(order = 5)
+	@ApiOperationSupport(order = 6)
 	@ApiOperation(value = "阅读消息", notes = "传入id")
 	public R messageDetail(@RequestParam Long id) {
 		return R.data(indexService.messageDetail(id));
@@ -91,7 +98,7 @@ public class IndexController {
 	 * 工作日程
 	 */
 	@GetMapping("/user-schedule")
-	@ApiOperationSupport(order = 5)
+	@ApiOperationSupport(order = 7)
 	@ApiOperation(value = "用户工作日程", notes = "传入登录用户的顶级机构id,日期字符串")
 	public R schedule(@RequestParam Long topDept, String date) {
 		return R.data(indexService.schedule(topDept, date));
@@ -101,7 +108,7 @@ public class IndexController {
 	 * 工作日程展开
 	 */
 	@GetMapping("/user-schedule-expand")
-	@ApiOperationSupport(order = 6)
+	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "用户工作日程展开", notes = "传入用户id,日期字符串")
 	public R scheduleExpand(@RequestParam Long userId, String date) {
 		List<Task> taskList = indexService.scheduleExpand(userId, date);
@@ -113,7 +120,7 @@ public class IndexController {
 	 * 任务分布
 	 */
 	@GetMapping("/task-statistics")
-	@ApiOperationSupport(order = 7)
+	@ApiOperationSupport(order = 9)
 	@ApiOperation(value = "任务分布统计", notes = "传入日期")
 	public R taskTaskStatistics(@RequestParam Long topDept, @RequestParam String date) {
 		String userRole = AuthUtil.getUserRole();

+ 2 - 2
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectMapper.xml

@@ -6,10 +6,10 @@
     <select id="selectByCreate" resultType="java.lang.Long">
         select distinct id from blade_project where is_deleted = 0
         <if test="param1 != null">
-            and create_dept = #{pram1}
+            and create_dept = #{param1}
         </if>
         <if test="param2 != null">
-            and create_user = #{pram2}
+            and create_user = #{param2}
         </if>
     </select>
 </mapper>

+ 3 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IContactOuterService.java

@@ -1,6 +1,7 @@
 package com.wtkj.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.dto.UpdateUserDTO;
 import com.wtkj.entity.ContactOuter;
 import org.springblade.core.mp.base.BaseService;
 
@@ -14,5 +15,7 @@ public interface IContactOuterService extends BaseService<ContactOuter> {
 	IPage<ContactOuter> selectPage(Long userId, IPage<ContactOuter> page);
 
 	IPage<ContactOuter> contactPage(Long deptId, Long userId, IPage<ContactOuter> page);
+
+	boolean updateUser(UpdateUserDTO dto);
 }
 

+ 24 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ContactOuterServiceImpl.java

@@ -1,11 +1,15 @@
 package com.wtkj.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.dto.UpdateUserDTO;
 import com.wtkj.entity.ContactOuter;
 import com.wtkj.mapper.ContactOuterMapper;
 import com.wtkj.service.IContactOuterService;
 import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.tool.api.R;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,6 +21,8 @@ import org.springframework.stereotype.Service;
 @AllArgsConstructor
 public class ContactOuterServiceImpl extends BaseServiceImpl<ContactOuterMapper, ContactOuter> implements IContactOuterService {
 
+	private final IUserClient userClient;
+
 	@Override
 	public IPage<ContactOuter> selectPage(Long userId, IPage<ContactOuter> page) {
 		return page.setRecords(baseMapper.getPage(userId, page));
@@ -26,4 +32,22 @@ public class ContactOuterServiceImpl extends BaseServiceImpl<ContactOuterMapper,
 	public IPage<ContactOuter> contactPage(Long deptId, Long userId, IPage<ContactOuter> page) {
 		return page.setRecords(baseMapper.getUserPage(deptId, userId, page));
 	}
+
+	@Override
+	public boolean updateUser(UpdateUserDTO dto) {
+		boolean flag = false;
+		Long userId = dto.getUserId();
+		R<User> userR = userClient.userInfoById(userId);
+		if (userR.isSuccess() && userR.getData() != null) {
+			User user = userR.getData();
+			user.setPhone(dto.getPhone());
+			user.setRoleId(dto.getRoleIds());
+			user.setPostId(dto.getPostIds());
+			user.setName(dto.getName());
+			user.setDeptId(String.valueOf(dto.getDeptId()));
+			R<Boolean> booleanR = userClient.updateUser(user);
+			flag = booleanR.isSuccess();
+		}
+		return flag;
+	}
 }

+ 0 - 2
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/WorkStatusServiceImpl.java

@@ -8,7 +8,6 @@ import com.wtkj.vo.WorkStatusVO;
 import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 
 import java.util.Objects;
@@ -22,7 +21,6 @@ import java.util.Objects;
 @Service
 public class WorkStatusServiceImpl extends BaseServiceImpl<WorkStatusMapper, WorkStatus> implements IWorkStatusService {
 
-	private final IUserClient userClient;
 
 	@Override
 	public WorkStatusVO workStatus(Long userId) {