yanliming пре 1 година
родитељ
комит
09434da3ce

+ 18 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/ImageWallDAO.java

@@ -0,0 +1,18 @@
+package com.jpsoft.employment.modules.base.dao;
+
+import java.util.List;
+import org.springframework.stereotype.Repository;
+import com.jpsoft.employment.modules.base.entity.ImageWall;
+import java.util.Map;
+import com.jpsoft.employment.modules.common.dto.Sort;
+
+@Repository
+public interface ImageWallDAO {
+	int insert(ImageWall entity);
+	int update(ImageWall entity);
+	int exist(String id);
+	ImageWall get(String id);
+	int delete(String id);
+	List<ImageWall> list();
+	List<ImageWall> search(Map<String, Object> searchParams, List<Sort> sortList);
+}

+ 52 - 0
common/src/main/java/com/jpsoft/employment/modules/base/entity/ImageWall.java

@@ -0,0 +1,52 @@
+package com.jpsoft.employment.modules.base.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import java.util.List;
+
+import com.jpsoft.employment.modules.base.dto.ImageDTO;
+import org.springframework.data.annotation.Transient;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+  描述:base_image_wall的实体类
+ */
+@Data
+@ApiModel(value = "base_image_wall的实体类")
+public class ImageWall {
+		@ApiModelProperty(value = "ID")
+	private String id;
+	
+				@ApiModelProperty(value = "图片集")
+	private String images;
+	
+				@ApiModelProperty(value = "创建人")
+	private String createBy;
+	
+					@ApiModelProperty(value = "创建时间")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	private Date createTime;
+	
+			@ApiModelProperty(value = "更新人")
+	private String updateBy;
+	
+					@ApiModelProperty(value = "更新时间")
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	private Date updateTime;
+	
+			@ApiModelProperty(value = "是否删除")
+	private Boolean delFlag;
+
+	@Transient
+	@ApiModelProperty(value = "图片集")
+	private String[] imageArr;
+	
+		}

+ 17 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/ImageWallService.java

@@ -0,0 +1,17 @@
+package com.jpsoft.employment.modules.base.service;
+
+import java.util.List;
+import java.util.Map;
+import com.jpsoft.employment.modules.base.entity.ImageWall;
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.common.dto.Sort;
+
+public interface ImageWallService {
+	ImageWall get(String id);
+	boolean exist(String id);
+	int insert(ImageWall model);
+	int update(ImageWall model);
+	int delete(String id);
+	List<ImageWall> list();
+	Page<ImageWall> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+}

+ 70 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/ImageWallServiceImpl.java

@@ -0,0 +1,70 @@
+package com.jpsoft.employment.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.employment.modules.base.dao.ImageWallDAO;
+import com.jpsoft.employment.modules.base.entity.ImageWall;
+import com.jpsoft.employment.modules.base.service.ImageWallService;
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="imageWallService")
+public class ImageWallServiceImpl implements ImageWallService {
+	@Resource(name="imageWallDAO")
+	private ImageWallDAO imageWallDAO;
+
+	@Override
+	public ImageWall get(String id) {
+		// TODO Auto-generated method stub
+		return imageWallDAO.get(id);
+	}
+
+	@Override
+	public int insert(ImageWall model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return imageWallDAO.insert(model);
+	}
+
+	@Override
+	public int update(ImageWall model) {
+		// TODO Auto-generated method stub
+		return imageWallDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return imageWallDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = imageWallDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<ImageWall> list() {
+		// TODO Auto-generated method stub
+		return imageWallDAO.list();
+	}
+		
+	@Override
+	public Page<ImageWall> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<ImageWall> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            imageWallDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 85 - 0
common/src/main/resources/mapper/base/ImageWall.xml

@@ -0,0 +1,85 @@
+<?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">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.employment.modules.base.dao.ImageWallDAO">
+	<resultMap id="ImageWallMap" type="com.jpsoft.employment.modules.base.entity.ImageWall">
+		<id property="id" column="id_" />
+			<result property="images" column="images_" />
+			<result property="createBy" column="create_by" />
+			<result property="createTime" column="create_time" />
+			<result property="updateBy" column="update_by" />
+			<result property="updateTime" column="update_time" />
+			<result property="delFlag" column="del_flag" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.employment.modules.base.entity.ImageWall">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_image_wall
+	    (id_,images_,create_by,create_time,update_by,update_time,del_flag)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{images,jdbcType=VARCHAR}
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+,#{delFlag,jdbcType= NUMERIC }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_image_wall where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.employment.modules.base.entity.ImageWall">
+		update base_image_wall
+		<set>
+				<if test="images!=null">
+		images_=#{images,jdbcType=VARCHAR},
+		</if>
+				<if test="createBy!=null">
+		create_by=#{createBy,jdbcType=VARCHAR},
+		</if>
+				<if test="createTime!=null">
+		create_time=#{createTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="updateBy!=null">
+		update_by=#{updateBy,jdbcType=VARCHAR},
+		</if>
+				<if test="updateTime!=null">
+		update_time=#{updateTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="ImageWallMap">
+		select * from base_image_wall where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_image_wall where id_=#{0}
+	</select>
+	<select id="list" resultMap="ImageWallMap">
+		select * from base_image_wall
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="ImageWallMap">
+		<![CDATA[
+			select * from base_image_wall
+		]]>
+		<where>
+			<if test="searchParams.id != null">
+				and ID_ like #{searchParams.id}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 241 - 0
web/src/main/java/com/jpsoft/employment/modules/base/controller/ImageWallController.java

@@ -0,0 +1,241 @@
+package com.jpsoft.employment.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.common.dto.MessageResult;
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
+import com.jpsoft.employment.modules.base.entity.ImageWall;
+import com.jpsoft.employment.modules.base.service.ImageWallService;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/imageWall")
+public class ImageWallController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private ImageWallService imageWallService;
+
+
+    @ApiOperation(value = "创建空记录")
+    @GetMapping("create")
+    public MessageResult<ImageWall> create() {
+        MessageResult<ImageWall> msgResult = new MessageResult<>();
+
+        ImageWall imageWall = new ImageWall();
+
+        msgResult.setData(imageWall);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "添加信息")
+    @PostMapping("add")
+    public MessageResult<ImageWall> add(@RequestBody ImageWall imageWall, @RequestAttribute String subject) {
+        MessageResult<ImageWall> msgResult = new MessageResult<>();
+
+        try {
+            imageWall.setId(UUID.randomUUID().toString());
+            imageWall.setDelFlag(false);
+            imageWall.setCreateBy(subject);
+            imageWall.setCreateTime(new Date());
+
+            if (imageWall.getImageArr().length > 0) {
+                String imageArr = StringUtils.join(imageWall.getImageArr(), ",");
+                imageWall.setImages(imageArr);
+            }
+
+            int affectCount = imageWallService.insert(imageWall);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(imageWall);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<ImageWall> edit(@PathVariable("id") String id) {
+        MessageResult<ImageWall> msgResult = new MessageResult<>();
+
+        try {
+            ImageWall imageWall = imageWallService.get(id);
+
+            if (imageWall != null) {
+                if(StringUtils.isNotEmpty(imageWall.getImages())){
+                    imageWall.setImageArr(imageWall.getImages().split(","));
+                }
+                msgResult.setResult(true);
+                msgResult.setData(imageWall);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "更新用户")
+    @PostMapping("update")
+    public MessageResult<ImageWall> update(@RequestBody ImageWall imageWall, @RequestAttribute String subject) {
+        MessageResult<ImageWall> msgResult = new MessageResult<>();
+
+        try {
+            imageWall.setUpdateBy(subject);
+            imageWall.setUpdateTime(new Date());
+
+            if (imageWall.getImageArr().length > 0) {
+                String imageArr = StringUtils.join(imageWall.getImageArr(), ",");
+                imageWall.setImages(imageArr);
+            }
+
+            int affectCount = imageWallService.update(imageWall);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(imageWall);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "删除用户")
+    @PostMapping("delete/{id}")
+    public MessageResult<ImageWall> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
+        MessageResult<ImageWall> msgResult = new MessageResult<>();
+
+        try {
+
+            ImageWall imageWall = imageWallService.get(id);
+            imageWall.setDelFlag(true);
+            imageWall.setUpdateBy(subject);
+            imageWall.setUpdateTime(new Date());
+
+            int affectCount = imageWallService.update(imageWall);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库删除失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value = "批量删除")
+    @PostMapping("batchDelete")
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                ImageWall imageWall = imageWallService.get(id);
+                imageWall.setDelFlag(true);
+                imageWall.setUpdateBy(subject);
+                imageWall.setUpdateTime(new Date());
+
+                affectCount += imageWallService.update(imageWall);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "列表")
+    @RequestMapping(value = "pageList", method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String id,
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+            HttpServletRequest request) {
+        String subject = (String) request.getAttribute("subject");
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String, Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("create_time", "desc"));
+
+        if (StringUtils.isNotEmpty(id)) {
+            searchParams.put("id", "%" + id + "%");
+        }
+
+
+        Page<ImageWall> page = imageWallService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
+
+        for (ImageWall imageWall:page) {
+            if(StringUtils.isNotEmpty(imageWall.getImages())){
+                imageWall.setImageArr(imageWall.getImages().split(","));
+            }
+        }
+
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}