添加图片附件管理,修改物资来源表,修改物资去向表

This commit is contained in:
zykzhangyukang 2020-04-25 22:15:06 +08:00
parent 7648d9a933
commit 6fc8798d0c
17 changed files with 17174 additions and 394 deletions

124
.idea/uiDesigner.xml Normal file
View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

File diff suppressed because it is too large Load diff

View file

@ -21,13 +21,13 @@
</javaTypeResolver>
<!-- 指定javaBean生成的位置 -->
<javaModelGenerator targetPackage="com.coderman.api.biz.pojo"
<javaModelGenerator targetPackage="com.coderman.api.system.pojo"
targetProject=".\src\main\java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- table指定每个表的生成策略 -->
<table tableName="biz_consumer" domainObjectName="Consumer"></table>
<table tableName="tb_image" domainObjectName="ImageAttachment"></table>
</context>
</generatorConfiguration>

View file

@ -1,61 +0,0 @@
package com.coderman.api.biz.controller;
import com.coderman.api.biz.utils.CommonFileUtil;
import com.coderman.api.system.bean.ResponseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
* 文件上传
* @Author zhangyukang
* @Date 2020/3/18 10:29
* @Version 1.0
**/
@Slf4j
@Api(tags = "文件上传接口")
@RestController
@RequestMapping("/upload")
public class FileUploadController {
@Autowired
private CommonFileUtil commonFileUtil;
/**
* 上传图片文件
* @param file
* @return
*/
@ApiOperation(value = "上传图片")
@RequiresPermissions({"upload:image"})
@PostMapping("/image")
public ResponseBean image(MultipartFile file){
if(file.isEmpty()){
return ResponseBean.error("文件为空");
}
String originalFilename = file.getOriginalFilename();
assert originalFilename != null;
String fileSuffix = originalFilename.substring(originalFilename.lastIndexOf("."));
if(!fileSuffix.equalsIgnoreCase("gif")&&!fileSuffix.equalsIgnoreCase(".jpg") && !fileSuffix.equalsIgnoreCase(".png")){
log.info("文件格式不正确");
return ResponseBean.error("文件格式不正确");
}
try {
String url = commonFileUtil.uploadFile(file);
System.out.println(url);
return ResponseBean.success(url);
} catch (IOException e) {
e.printStackTrace();
return ResponseBean.error("上传文件错误");
}
}
}

View file

@ -24,4 +24,6 @@ public class Consumer {
private String phone;
private Integer sort;
private String contact;
}

View file

@ -27,4 +27,6 @@ public class Supplier {
private Integer sort;
private String contact;
}

View file

@ -43,6 +43,12 @@ public class ConsumerServiceImpl implements ConsumerService {
if (consumerVO.getName() != null && !"".equals(consumerVO.getName())) {
o.createCriteria().andLike("name", "%" + consumerVO.getName() + "%");
}
if (consumerVO.getAddress() != null && !"".equals(consumerVO.getAddress())) {
o.createCriteria().andLike("address", "%" + consumerVO.getAddress() + "%");
}
if (consumerVO.getContact() != null && !"".equals(consumerVO.getContact())) {
o.createCriteria().andLike("contact", "%" + consumerVO.getContact() + "%");
}
List<Consumer> consumers = consumerMapper.selectByExample(o);
List<ConsumerVO> categoryVOS= ConsumerConverter.converterToVOList(consumers);
PageInfo<Consumer> info = new PageInfo<>(consumers);

View file

@ -110,6 +110,14 @@ public class CommonFileUtil {
}
}
/**
* 上传图片
* @param is
* @param size
* @param fileExtName
* @param metaData
* @return
*/
public String upfileImage(InputStream is, long size, String fileExtName, Set<MateData> metaData) {
StorePath path = storageClient.uploadImageAndCrtThumbImage(is, size, fileExtName, metaData);
return getResAccessUrl(path);

View file

@ -29,4 +29,6 @@ public class ConsumerVO {
private Integer sort;
private String contact;
}

View file

@ -36,4 +36,6 @@ public class SupplierVO {
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
private Date modifiedTime;
private String contact;
}

View file

@ -0,0 +1,135 @@
package com.coderman.api.system.controller;
import com.coderman.api.biz.utils.CommonFileUtil;
import com.coderman.api.system.bean.ResponseBean;
import com.coderman.api.system.mapper.ImageAttachmentMapper;
import com.coderman.api.system.pojo.ImageAttachment;
import com.coderman.api.system.vo.ImageAttachmentVO;
import com.coderman.api.system.vo.PageVO;
import com.coderman.api.system.vo.UserVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
* 文件上传
* @Author zhangyukang
* @Date 2020/3/18 10:29
* @Version 1.0
**/
@Slf4j
@Api(tags = "文件上传接口")
@RestController
@RequestMapping("/upload")
public class FileUploadController {
@Autowired
private CommonFileUtil commonFileUtil;
@Autowired
private ImageAttachmentMapper imageAttachmentMapper;
/**
* 上传图片文件
* @param file
* @return
*/
@ApiOperation(value = "上传图片")
@RequiresPermissions({"upload:image"})
@PostMapping("/image")
public ResponseBean image(MultipartFile file){
if(file.isEmpty()){
return ResponseBean.error("文件为空");
}
String originalFilename = file.getOriginalFilename();
assert originalFilename != null;
String fileSuffix = originalFilename.substring(originalFilename.lastIndexOf("."));
if(!fileSuffix.equalsIgnoreCase(".gif")
&&!fileSuffix.equalsIgnoreCase(".jpg")
&& !fileSuffix.equalsIgnoreCase(".png")){
log.info("文件格式不正确");
return ResponseBean.error("文件格式不正确");
}
try {
String url = commonFileUtil.uploadFile(file);
ImageAttachment t = new ImageAttachment();
t.setPath(url);
t.setCreateTime(new Date());
t.setMediaType(file.getContentType());
t.setSuffix(fileSuffix);
t.setSize(file.getSize());
BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); // 通过临时文件获取图片流
if(bufferedImage!=null){
int width = bufferedImage.getWidth();
int height = bufferedImage.getHeight();
t.setHeight(height);
t.setWidth(width);
}
imageAttachmentMapper.insert(t);
log.info("[上传文件]=>{}",url);
return ResponseBean.success(url);
} catch (IOException e) {
e.printStackTrace();
return ResponseBean.error("上传文件错误");
}
}
/**
* 附件列表(图片)
*
* @return
*/
@ApiOperation(value = "附件列表", notes = "模糊查询附件列表")
@GetMapping("/findImageList")
public ResponseBean findImageList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "8") Integer pageSize,
ImageAttachmentVO imageAttachmentVO) {
PageHelper.startPage(pageNum,pageSize);
Example o = new Example(ImageAttachment.class);
o.setOrderByClause("create_time desc");
if(imageAttachmentVO!=null){
if(imageAttachmentVO.getMediaType()!=null&&!"".equalsIgnoreCase(imageAttachmentVO.getMediaType())){
o.createCriteria().andEqualTo("mediaType",imageAttachmentVO.getMediaType());
}
if(imageAttachmentVO.getPath()!=null&&!"".equalsIgnoreCase(imageAttachmentVO.getPath())){
o.createCriteria().andLike("path","%"+imageAttachmentVO.getPath()+"%");
}
if(imageAttachmentVO.getSuffix()!=null&&!"".equalsIgnoreCase(imageAttachmentVO.getSuffix())){
o.createCriteria().andEqualTo("suffix",imageAttachmentVO.getSuffix());
}
}
List<ImageAttachment> imageAttachments = imageAttachmentMapper.selectByExample(o);
PageInfo<ImageAttachment> imageAttachmentPageInfo = new PageInfo<>(imageAttachments);
return ResponseBean.success(imageAttachmentPageInfo);
}
/**
* 删除图片
* @param id
* @return
*/
@ApiOperation(value = "删除图片", notes = "删除数据库记录,删除图片服务器上的图片")
@RequiresPermissions("image:delete")
@DeleteMapping("/delete/{id}")
public ResponseBean delete(@PathVariable Long id){
ImageAttachment imageAttachment = imageAttachmentMapper.selectByPrimaryKey(id);
commonFileUtil.deleteFile(imageAttachment.getPath());
imageAttachmentMapper.deleteByPrimaryKey(id);
return ResponseBean.success();
}
}

View file

@ -0,0 +1,13 @@
package com.coderman.api.system.mapper;
import com.coderman.api.system.pojo.ImageAttachment;
import tk.mybatis.mapper.common.Mapper;
/**
* @Author zhangyukang
* @Date 2020/4/25 10:17
* @Version 1.0
**/
public interface ImageAttachmentMapper extends Mapper<ImageAttachment> {
}

View file

@ -0,0 +1,29 @@
package com.coderman.api.system.pojo;
import lombok.Data;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Data
@Table(name = "tb_image")
public class ImageAttachment {
@Id
private Long id;
private String path;
private Long size;
private String mediaType;
private String suffix;
private Integer height;
private Integer width;
private Date createTime;
}

View file

@ -107,21 +107,19 @@ public class UserServiceImpl implements UserService {
public List<Menu> findMenuById(List<Role> roles) {
List<Menu> menus=new ArrayList<>();
if(!CollectionUtils.isEmpty(roles)){
Set<Long> menuIds=new HashSet<>();
Set<Long> menuIds=new HashSet<>();//存放用户的菜单id
List<RoleMenu> roleMenus;
for (Role role : roles) {
//根据角色ID查询权限ID
RoleMenu t = new RoleMenu();
t.setRoleId(role.getId());
roleMenus= roleMenuMapper.select(t);
Example o = new Example(RoleMenu.class);
o.createCriteria().andEqualTo("roleId",role.getId());
roleMenus= roleMenuMapper.selectByExample(o);
if(!CollectionUtils.isEmpty(roleMenus)){
for (RoleMenu roleMenu : roleMenus) {
menuIds.add(roleMenu.getMenuId());
}
}
}
if(!CollectionUtils.isEmpty(menuIds)){
for (Long menuId : menuIds) {
//该用户所有的菜单

View file

@ -18,7 +18,7 @@ public class JWTUtils {
/**
* 过期时间2小时
*/
private static final long EXPIRE_TIME = 2*60*60*1000;
private static final long EXPIRE_TIME = 12*60*60*1000;
/**
* 校验token是否正确

View file

@ -0,0 +1,19 @@
package com.coderman.api.system.vo;
import lombok.Data;
/**
* @Author zhangyukang
* @Date 2020/4/25 10:47
* @Version 1.0
**/
@Data
public class ImageAttachmentVO {
private String mediaType;
private String suffix;
private String path;
}

File diff suppressed because it is too large Load diff