Shanks 7 年之前
父節點
當前提交
976612c20a

+ 16 - 0
pom.xml

@@ -74,6 +74,22 @@
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-thymeleaf</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>commons-fileupload</groupId>
+			<artifactId>commons-fileupload</artifactId>
+			<version>1.3.2</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>2.5</version>
+		</dependency>
+		<!-- Spring 文件上传的依赖包  -->
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>1.3.2</version>
+		</dependency>
 	</dependencies>
 
 	<build>

+ 79 - 0
src/main/java/com/ygj/yuemum/controller/admin/ImageUploadController.java

@@ -0,0 +1,79 @@
+package com.ygj.yuemum.controller.admin;
+
+import com.ygj.yuemum.domain.admin.Photo;
+import com.ygj.yuemum.service.admin.PhotoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.ClassUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+@Controller
+public class ImageUploadController {
+    @Autowired
+    private PhotoService photoService;
+
+    @RequestMapping(value = "/upload", method = RequestMethod.GET)
+    public String upload() {
+        return "/fileupload";
+    }
+
+    @RequestMapping(value = "/uploadDisplay", method = RequestMethod.POST)
+    @ResponseBody
+    public int uploadDisplay(@RequestParam("file") MultipartFile file,int id,int type) {
+//        照片类型 1:display 2:certificate 3:comment 4:service
+        String folder = "";
+        switch (type) {
+            case 1:
+                folder = "display";
+                break;
+            case 2:
+                folder = "certificate";
+                break;
+            case 3:
+                folder = "comment";
+                break;
+            case 4:
+                folder = "service";
+                break;
+
+        }
+        int dot = file.getOriginalFilename().lastIndexOf('.');
+        String newname = file.getOriginalFilename().substring(dot);
+        Photo photo = new Photo();
+        if(file.isEmpty()){
+            return 0;
+        }
+        Date date = new Date();
+        DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        String path = ClassUtils.getDefaultClassLoader().getResource("").getPath()+"/src/main/resources/static/img/"+folder+"Img" ;
+        File dest = new File(path + "/"+folder+id+type+sdf.format(date)+newname);
+        try {
+            file.transferTo(dest); //保存文件
+            photo.setServant_code(id);
+            photo.setPhoto_type(type);
+            photo.setPhoto_path(dest.getAbsolutePath());
+            photoService.addPhoto(photo);
+            return 1;
+        } catch (IllegalStateException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            return 0;
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+}

+ 9 - 0
src/main/java/com/ygj/yuemum/controller/admin/JlAdminUserController.java

@@ -18,6 +18,15 @@ public class JlAdminUserController {
         return jladminuserService.getUsers();
     }
 
+    @PostMapping("/logIN")
+    public int logIN(@ModelAttribute JlAdminUser jladminuser) {
+        if(jladminuser.getUsername() == null || jladminuser.getPassword() ==null){
+            return 0;
+        } else {
+        return jladminuserService.logIN(jladminuser);
+        }
+    }
+
     @PostMapping("/JlAdminadd")
     public int add(@ModelAttribute JlAdminUser jladminuser) {
         return jladminuserService.addUser(jladminuser);

+ 1 - 0
src/main/java/com/ygj/yuemum/controller/maternitymatron/JlServiceUserController.java

@@ -112,6 +112,7 @@ public class JlServiceUserController {
     @PostMapping("/updatejlServiceUser")
     public int updatejlServiceUser(@ModelAttribute JlServiceUser jlServiceUser) {
         JlServiceUserInfo jlServiceUserInfo = new JlServiceUserInfo();
+        jlServiceUser.setUpdated_at(new Date());
         //jlServiceUserInfo
         jlServiceUserInfo.setIdcard(jlServiceUser.getIdcard());
         jlServiceUserInfo.setSeniority(jlServiceUser.getSeniority());

+ 1 - 0
src/main/java/com/ygj/yuemum/dao/admin/JlAdminUserDao.java

@@ -14,6 +14,7 @@ public interface JlAdminUserDao {
      * @return List<User>
      */
     List<JlAdminUser> getAll();
+    int logIN(JlAdminUser jlAdminUser);
 
     /**
      * 根据id删除某个用户信息

+ 28 - 18
src/main/java/com/ygj/yuemum/domain/admin/Photo.java

@@ -3,13 +3,24 @@ package com.ygj.yuemum.domain.admin;
 public class Photo {
 
     private Integer id;
-    private Integer photo_code; // 照片编号
-    private String photo_title; // 照片名称
+    private Integer photo_type; // 照片编号
+    private Integer resume_code;
+    private String photo_path; // 照片名称
+    private Integer servant_code;
+
 
     public Photo() {
         super();
     }
 
+    public Integer getServant_code() {
+        return servant_code;
+    }
+
+    public void setServant_code(Integer servant_code) {
+        this.servant_code = servant_code;
+    }
+
     public Integer getId() {
         return id;
     }
@@ -18,28 +29,27 @@ public class Photo {
         this.id = id;
     }
 
-    public Integer getPhoto_code() {
-        return photo_code;
+    public Integer getPhoto_type() {
+        return photo_type;
+    }
+
+    public void setPhoto_type(Integer photo_type) {
+        this.photo_type = photo_type;
     }
 
-    public void setPhoto_code(Integer photo_code) {
-        this.photo_code = photo_code;
+    public Integer getResume_code() {
+        return resume_code;
     }
 
-    public String getPhoto_title() {
-        return photo_title;
+    public void setResume_code(Integer resume_code) {
+        this.resume_code = resume_code;
     }
 
-    public void setPhoto_title(String photo_title) {
-        this.photo_title = photo_title;
+    public String getPhoto_path() {
+        return photo_path;
     }
 
-    @Override
-    public String toString() {
-        return "Photo{" +
-                "id=" + id +
-                ", photo_code='" + photo_code + '\'' +
-                ", photo_title='" + photo_title + '\'' +
-                '}';
+    public void setPhoto_path(String photo_path) {
+        this.photo_path = photo_path;
     }
-}
+}

+ 20 - 21
src/main/java/com/ygj/yuemum/domain/admin/Resume.java

@@ -3,9 +3,10 @@ package com.ygj.yuemum.domain.admin;
 public class Resume {
 
     private Integer id;
-    private Integer resume_code; // 简历编号
-    private String resume_name; // 简历名称
-    private String resume_path;// 简历路径
+    private Integer servant_code; // 简历编号
+    private int module_code; // 简历名称
+    private String resume_comment;// 简历路径
+    private String resume_path;
 
     public Resume() {
         super();
@@ -19,20 +20,28 @@ public class Resume {
         this.id = id;
     }
 
-    public Integer getResume_code() {
-        return resume_code;
+    public Integer getServant_code() {
+        return servant_code;
     }
 
-    public void setResume_code(Integer resume_code) {
-        this.resume_code = resume_code;
+    public void setServant_code(Integer servant_code) {
+        this.servant_code = servant_code;
     }
 
-    public String getResume_name() {
-        return resume_name;
+    public int getModule_code() {
+        return module_code;
     }
 
-    public void setResume_name(String resume_name) {
-        this.resume_name = resume_name;
+    public void setModule_code(int module_code) {
+        this.module_code = module_code;
+    }
+
+    public String getResume_comment() {
+        return resume_comment;
+    }
+
+    public void setResume_comment(String resume_comment) {
+        this.resume_comment = resume_comment;
     }
 
     public String getResume_path() {
@@ -42,14 +51,4 @@ public class Resume {
     public void setResume_path(String resume_path) {
         this.resume_path = resume_path;
     }
-
-    @Override
-    public String toString() {
-        return "Resume{" +
-                "id=" + id +
-                ", resume_code='" + resume_code + '\'' +
-                ", resume_name='" + resume_name + '\'' +
-                ", resume_path='" + resume_path + '\'' +
-                '}';
-    }
 }

+ 4 - 0
src/main/java/com/ygj/yuemum/service/admin/JlAdminUserService.java

@@ -27,6 +27,10 @@ public class JlAdminUserService {
         return jladminuserdao.deleteByPrimaryKey(id);
     }
 
+    public int logIN(JlAdminUser jladminuser) {
+        return jladminuserdao.logIN(jladminuser);
+    }
+
     public int updateUser(JlAdminUser jladminusers) {
         return jladminuserdao.updateByPrimaryKeySelective(jladminusers);
     }

+ 13 - 0
src/main/resources/mybatis/mapper/admin/JlAdminUserMapper.xml

@@ -35,6 +35,19 @@
         from jl_admin_user
     </select>
 
+    <select id="logIN" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.admin.JlAdminUser">
+        select
+        count(1)
+        from jl_admin_user
+        where 1=1
+        <if test="username != null" >
+            and username =  #{username,jdbcType=VARCHAR}
+        </if>
+        <if test="password != null" >
+            and password = #{password,jdbcType=VARCHAR}
+        </if>
+    </select>
+
     <!-- 根据id查找某个用户信息 -->
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
         select

+ 41 - 21
src/main/resources/mybatis/mapper/admin/PhotoMapper.xml

@@ -4,64 +4,84 @@
 
     <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.admin.Photo" >
         <id column="id" property="id" jdbcType="INTEGER" />
-        <result column="photo_code" property="photo_code" jdbcType="INTEGER" />
-        <result column="photo_title" property="photo_title" jdbcType="VARCHAR" />
+        <result column="photo_type" property="photo_type" jdbcType="INTEGER" />
+        <result column="resume_code" property="resume_code" jdbcType="INTEGER" />
+        <result column="servant_code" property="servant_code" jdbcType="VARCHAR" />
+        <result column="photo_path" property="photo_path" jdbcType="VARCHAR" />
     </resultMap>
 
     <sql id="Base_Column_List" >
-        id, photo_code, photo_title
+        id, photo_type, resume_code,photo_path,servant_code
     </sql>
 
     <!-- 得到所有的照片信息 -->
     <select id="getAll" resultMap="BaseResultMap" >
         select
         <include refid="Base_Column_List" />
-        from photo
+        from mm_info_photo
     </select>
 
     <!-- 根据id查找某个照片信息 -->
     <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
         select
         <include refid="Base_Column_List" />
-        from photo
-        where photo_code = #{photo_code,jdbcType=INTEGER}
+        from mm_info_photo
+        where resume_code = #{resume_code,jdbcType=INTEGER}
     </select>
     <!-- 根据id删除某个照片信息 -->
     <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
-        delete from photo
+        delete from mm_info_photo
         where id = #{id,jdbcType=INTEGER}
     </delete>
 
     <!-- 插入一条照片信息 -->
     <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.admin.Photo" >
-        insert into photo
+        insert into mm_info_photo
         <trim prefix="(" suffix=")" suffixOverrides="," >
-            <if test="photo_code != null" >
-                photo_code,
+            <if test="resume_code != null" >
+                resume_code,
             </if>
-            <if test="photo_title != null" >
-                photo_title,
+            <if test="photo_type != null" >
+                photo_type,
+            </if>
+            <if test="photo_path != null" >
+                photo_path,
+            </if>
+            <if test="servant_code != null" >
+                servant_code
             </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides="," >
-            <if test="photo_code != null" >
-                #{photo_code,jdbcType=INTEGER},
+            <if test="resume_code != null" >
+                #{resume_code,jdbcType=INTEGER},
+            </if>
+            <if test="photo_type != null" >
+                #{photo_type,jdbcType=VARCHAR},
             </if>
-            <if test="photo_title != null" >
-                #{photo_title,jdbcType=VARCHAR}
+            <if test="photo_path != null" >
+                #{photo_path,jdbcType=VARCHAR},
+            </if>
+            <if test="servant_code != null" >
+                #{servant_code,jdbcType=VARCHAR}
             </if>
         </trim>
     </insert>
 
     <!-- 根据id更新一条照片信息 -->
     <update id="updateByPrimaryKeySelective" parameterType="com.ygj.yuemum.domain.admin.Photo" >
-        update photo
+        update mm_info_photo
         <set >
-            <if test="photo_code != null" >
-                photo_code = #{photo_code,jdbcType=INTEGER},
+            <if test="resume_code != null" >
+                resume_code = #{resume_code,jdbcType=INTEGER},
+            </if>
+            <if test="photo_type != null" >
+                photo_type = #{photo_type,jdbcType=VARCHAR},
+            </if>
+            <if test="photo_path != null" >
+                photo_path = #{photo_path,jdbcType=VARCHAR},
             </if>
-            <if test="photo_title != null" >
-                photo_title = #{photo_title,jdbcType=VARCHAR}
+            <if test="servant_code != null" >
+                servant_code = #{servant_code,jdbcType=VARCHAR}
             </if>
         </set>
         where id = #{id,jdbcType=INTEGER}

+ 26 - 16
src/main/resources/mybatis/mapper/admin/ResumeMapper.xml

@@ -4,13 +4,14 @@
 
     <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.admin.Resume" >
         <id column="id" property="id" jdbcType="INTEGER" />
-        <result column="resume_code" property="resume_code" jdbcType="INTEGER" />
-        <result column="resume_name" property="resume_name" jdbcType="VARCHAR" />
+        <result column="servant_code" property="servant_code" jdbcType="INTEGER" />
+        <result column="module_code" property="module_code" jdbcType="INTEGER" />
+        <result column="resume_comment" property="resume_comment" jdbcType="VARCHAR" />
         <result column="resume_path" property="resume_path" jdbcType="VARCHAR" />
     </resultMap>
 
     <sql id="Base_Column_List" >
-        id,resume_code,resume_name,resume_path
+        id,servant_code,module_code,resume_comment,resume_path
     </sql>
 
     <!-- 得到所有的简历信息 -->
@@ -25,7 +26,7 @@
         select
         <include refid="Base_Column_List" />
         from resume
-        where resume_code = #{resume_code,jdbcType=INTEGER}
+        where servant_code = #{servant_code,jdbcType=INTEGER}
     </select>
     <!-- 根据id删除某个简历信息 -->
     <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
@@ -37,22 +38,28 @@
     <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.admin.Resume" >
         insert into resume
         <trim prefix="(" suffix=")" suffixOverrides="," >
-            <if test="resume_code != null" >
-                resume_code,
+            <if test="servant_code != null" >
+                servant_code,
             </if>
-            <if test="resume_name != null" >
-                resume_name,
+            <if test="module_code != null" >
+                module_code,
+            </if>
+            <if test="resume_comment != null" >
+                resume_comment
             </if>
             <if test="resume_path != null" >
                 resume_path
             </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides="," >
-            <if test="resume_code != null" >
-                #{resume_code,jdbcType=INTEGER},
+            <if test="servant_code != null" >
+                #{servant_code,jdbcType=INTEGER},
+            </if>
+            <if test="module_code != null" >
+                #{module_code,jdbcType=VARCHAR},
             </if>
-            <if test="resume_name != null" >
-                #{resume_name,jdbcType=VARCHAR},
+            <if test="resume_comment != null" >
+                #{resume_comment,jdbcType=VARCHAR}
             </if>
             <if test="resume_path != null" >
                 #{resume_path,jdbcType=VARCHAR}
@@ -64,11 +71,14 @@
     <update id="updateByPrimaryKeySelective" parameterType="com.ygj.yuemum.domain.admin.Resume" >
         update resume
         <set >
-            <if test="resume_code != null" >
-                resume_code = #{resume_code,jdbcType=INTEGER},
+            <if test="servant_code != null" >
+                servant_code = #{servant_code,jdbcType=INTEGER},
+            </if>
+            <if test="module_code != null" >
+                module_code = #{module_code,jdbcType=VARCHAR},
             </if>
-            <if test="resume_name != null" >
-                resume_name = #{resume_name,jdbcType=VARCHAR},
+            <if test="resume_comment != null" >
+                resume_comment = #{resume_comment,jdbcType=VARCHAR}
             </if>
             <if test="resume_path != null" >
                 resume_path = #{resume_path,jdbcType=VARCHAR}