Prechádzať zdrojové kódy

项目创建和修改

5 rokov pred
rodič
commit
3aa5e9a41b

+ 13 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/controller/ProjectController.java

@@ -42,5 +42,18 @@ public class ProjectController {
         return msg;
     }
 
+    /**
+     * 分配项目
+     * 参数:id 项目id ,userIds 参与项目的用户id 如:“1,2,3”(多个或者一个)
+     *
+     * @return
+     */
+    @ApiOperation("分配项目")
+    @RequestMapping("/ handOutProject")
+    @ResponseBody
+    public HttpRespMsg handOutProject(Project project,String userIds){
+        HttpRespMsg msg = projectService.handOutProject(project,userIds);
+        return msg;
+    }
 }
 

+ 21 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/controller/ProjectUserController.java

@@ -0,0 +1,21 @@
+package com.hssx.cloudmodel.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-07-29
+ */
+@RestController
+@RequestMapping("/projectuser")
+public class ProjectUserController {
+
+}
+

+ 79 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/ProjectUser.java

@@ -0,0 +1,79 @@
+package com.hssx.cloudmodel.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-07-29
+ */
+@TableName("tb_project_user")
+public class ProjectUser extends Model<ProjectUser> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 项目id
+     */
+    @TableField("project_id")
+    private Integer projectId;
+
+    /**
+     * 用户id
+     */
+    @TableField("user_id")
+    private Integer userId;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(Integer projectId) {
+        this.projectId = projectId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+    @Override
+    public String toString() {
+        return "ProjectUser{" +
+        "id=" + id +
+        ", projectId=" + projectId +
+        ", userId=" + userId +
+        "}";
+    }
+}

+ 16 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/ProjectUserMapper.java

@@ -0,0 +1,16 @@
+package com.hssx.cloudmodel.mapper;
+
+import com.hssx.cloudmodel.entity.ProjectUser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-07-29
+ */
+public interface ProjectUserMapper extends BaseMapper<ProjectUser> {
+
+}

+ 2 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/ProjectService.java

@@ -16,4 +16,6 @@ import com.hssx.cloudmodel.util.HttpRespMsg;
 public interface ProjectService extends IService<Project> {
 
     HttpRespMsg addAndUpdateProject(Project project, Integer flag);
+
+    HttpRespMsg handOutProject(Project project, String userIds);
 }

+ 16 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/ProjectUserService.java

@@ -0,0 +1,16 @@
+package com.hssx.cloudmodel.service;
+
+import com.hssx.cloudmodel.entity.ProjectUser;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-07-29
+ */
+public interface ProjectUserService extends IService<ProjectUser> {
+
+}

+ 9 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/ProjectServiceImpl.java

@@ -6,6 +6,7 @@ import com.hssx.cloudmodel.mapper.ProjectMapper;
 import com.hssx.cloudmodel.service.ProjectService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.ListUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -51,4 +52,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         }
         return msg;
     }
+
+    @Override
+    public HttpRespMsg handOutProject(Project project, String userIds) {
+        if(userIds != null && userIds != ""){
+            ListUtil.convertLongIdsArrayToList(userIds);
+        }
+        return null;
+    }
 }

+ 20 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/ProjectUserServiceImpl.java

@@ -0,0 +1,20 @@
+package com.hssx.cloudmodel.service.impl;
+
+import com.hssx.cloudmodel.entity.ProjectUser;
+import com.hssx.cloudmodel.mapper.ProjectUserMapper;
+import com.hssx.cloudmodel.service.ProjectUserService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-07-29
+ */
+@Service
+public class ProjectUserServiceImpl extends ServiceImpl<ProjectUserMapper, ProjectUser> implements ProjectUserService {
+
+}

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/util/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("tb_project");
+        strategy.setInclude("tb_project_user");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 130 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/util/ListUtil.java

@@ -0,0 +1,130 @@
+package com.hssx.cloudmodel.util;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 07 - 25 16:56
+ * Description:<描述>处理字符串转成集合的
+ * Version: 1.0
+ */
+
+public class ListUtil {
+	/**
+	 * 
+	 * @param idStr 1,2,3,4,5字符串
+	 * @return List<Long>
+	 */
+	public static List<Long> convertIdsArrayToList(String idStr) {
+		String[] array = idStr.split(",");
+		List<Long> ids = new ArrayList<Long>();
+		for (String a : array) {
+			if (a != null && a.length() > 0) {
+				ids.add(Long.valueOf(a));
+			}
+		}
+		return ids;
+	}
+	/**
+	 * Long
+	 * @param idStr  1,2,3,4,5字符串
+	 * @return
+	 */
+	public static List<String> convertLongIdsArrayToList(String idStr) {
+		String[] array = idStr.split(",");
+		List<String> ids = new ArrayList<String>();
+		for (String a : array) {
+			if (a != null && a.length() > 0) {
+				ids.add(a);
+			}
+		}
+		return ids;
+	}
+
+	public static List<Integer> extractIdFromList(List object, String key) {
+		List<Integer> list = new ArrayList<Integer>();
+        for (Object obj : object) {
+            // 得到类对象
+            Class userCla = (Class) obj.getClass();
+            /* 得到类中的所有属性集合 */
+            Field[] fs = userCla.getDeclaredFields();
+            for (int i = 0; i < fs.length; i++) {
+                Field f = fs[i];
+                f.setAccessible(true); // 设置些属性是可以访问的
+                try {
+                    if (f.getName().equals(key)) {
+                        list.add((Integer)f.get(obj));
+                    }
+                } catch (IllegalArgumentException e) {
+                    e.printStackTrace();
+                } catch (IllegalAccessException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return list;
+	}
+	
+	
+	public static List<String> extractNameFromList(List object, String key) {
+		List<String> list = new ArrayList<String>();
+		for (Object obj : object) {
+			// 得到类对象
+			Class userCla = (Class) obj.getClass();
+			/* 得到类中的所有属性集合 */
+			Field[] fs = userCla.getDeclaredFields();
+			for (int i = 0; i < fs.length; i++) {
+				Field f = fs[i];
+				f.setAccessible(true); // 设置些属性是可以访问的
+				try {
+					if (f.getName().equals(key)) {
+						list.add((String)f.get(obj));
+					}
+				} catch (IllegalArgumentException e) {
+					e.printStackTrace();
+				} catch (IllegalAccessException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return list;
+	}
+	
+	public static List<Integer> addList(String ids,List<Integer> idList){
+		String[] joinStr = ids.split(",");
+		boolean isCf = false;
+		for(String id : joinStr){
+			if (id != null && id.length() > 0) {
+				for(int i = 0;i<idList.size();i++){
+					if(Integer.valueOf(id).intValue() != idList.get(i).intValue()){
+						isCf = false;
+					}else{
+						isCf = true;
+						break;
+					}
+				}
+				if(!isCf){
+					idList.add(Integer.valueOf(id));
+				}
+			}
+		}
+		
+		return idList;
+	}
+	
+	//去重
+	public static List removeDuplicateData(List list) {
+		HashSet set = new HashSet();
+		set.addAll(list);
+		list.clear();
+		list.addAll(set);
+		return list;
+	}
+	
+	public static void main(String[] args) {
+		String str = "123|456";
+		System.out.println(str.contains("|"));
+	}
+}

+ 17 - 0
cloud-model/src/main/resources/mapper/ProjectUserMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hssx.cloudmodel.mapper.ProjectUserMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hssx.cloudmodel.entity.ProjectUser">
+        <id column="id" property="id" />
+        <result column="project_id" property="projectId" />
+        <result column="user_id" property="userId" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, project_id, user_id
+    </sql>
+
+</mapper>