| | |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.all.SettingData; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.sys.AttachEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.FileHelper; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 上传附件服务类 |
| | |
| | | @Autowired |
| | | AttachService attachService; |
| | | |
| | | private static Map<String, String> attachTabs = new HashMap<>(); |
| | | |
| | | private final static Log log = LogFactory.getLog(UploadAttachService.class); |
| | | |
| | | private static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "文件找不到")); |
| | | |
| | | /** |
| | | * 初始化附件表 |
| | | */ |
| | | public static void init(String cfg) { |
| | | if (StringHelper.isEmpty(cfg)) { |
| | | return; |
| | | } |
| | | |
| | | String[] strs = cfg.split(StaticData.COMMA); |
| | | if (strs.length == 0) { |
| | | return; |
| | | } |
| | | |
| | | for (String str : strs) { |
| | | if (attachTabs.containsKey(str)) { |
| | | continue; |
| | | } |
| | | |
| | | attachTabs.put(str, str.contains("bd.") ? "materiname" : "photono"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传文件 |
| | | */ |
| | | public ResponseMsg<String> upload(UserEntity ue, String tab, MultipartFile file, BaseController ctrl) { |