|
@@ -0,0 +1,193 @@
|
|
|
|
+package com.kmall.admin.controller;
|
|
|
|
+
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+import com.kmall.admin.entity.GoodsLabelHeadEntity;
|
|
|
|
+import com.kmall.admin.entity.SysOssEntity;
|
|
|
|
+import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
|
+import com.kmall.admin.service.GoodsLabelHeadService;
|
|
|
|
+import com.kmall.admin.utils.ShiroUtils;
|
|
|
|
+import com.kmall.common.constant.Dict;
|
|
|
|
+import com.kmall.common.fileserver.util.FileManager;
|
|
|
|
+import com.kmall.common.utils.PageUtils;
|
|
|
|
+import com.kmall.common.utils.Query;
|
|
|
|
+import com.kmall.common.utils.R;
|
|
|
|
+import com.kmall.common.utils.RRException;
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 标签头维护表Controller
|
|
|
|
+ *
|
|
|
|
+ * @author emato
|
|
|
|
+ * @email admin@qhdswl.com
|
|
|
|
+ * @date 2020-09-11 14:24:36
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("goodslabelhead")
|
|
|
|
+public class GoodsLabelHeadController {
|
|
|
|
+ @Autowired
|
|
|
|
+ private GoodsLabelHeadService goodsLabelHeadService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看列表
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/list")
|
|
|
|
+// @RequiresPermissions("goodslabelhead:list")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public R list(@RequestParam Map<String, Object> params) {
|
|
|
|
+ //查询列表数据
|
|
|
|
+ String merchSn = null;
|
|
|
|
+ Integer storeId = null;
|
|
|
|
+ SysUserEntity sysUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
+ if(!"1".equals(sysUser.getRoleType())){
|
|
|
|
+ merchSn = sysUser.getMerchSn();
|
|
|
|
+ storeId = sysUser.getStoreId();
|
|
|
|
+ }
|
|
|
|
+ params.put("merchSn",merchSn);
|
|
|
|
+ params.put("storeId",storeId);
|
|
|
|
+ Query query = new Query(params);
|
|
|
|
+ List<GoodsLabelHeadEntity> goodsLabelHeadList = goodsLabelHeadService.queryList(query);
|
|
|
|
+ int total = goodsLabelHeadService.queryTotal(query);
|
|
|
|
+
|
|
|
|
+ PageUtils pageUtil = new PageUtils(goodsLabelHeadList, total, query.getLimit(), query.getPage());
|
|
|
|
+
|
|
|
|
+ return R.ok().put("page", pageUtil);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看信息
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/info/{id}")
|
|
|
|
+// @RequiresPermissions("goodslabelhead:info")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public R info(@PathVariable("id") Integer id) {
|
|
|
|
+ GoodsLabelHeadEntity goodsLabelHead = goodsLabelHeadService.queryObject(id);
|
|
|
|
+
|
|
|
|
+ return R.ok().put("goodsLabelHead", goodsLabelHead);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/save")
|
|
|
|
+// @RequiresPermissions("goodslabelhead:save")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public R save(@RequestBody GoodsLabelHeadEntity goodsLabelHead) {
|
|
|
|
+ goodsLabelHeadService.save(goodsLabelHead);
|
|
|
|
+
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/update")
|
|
|
|
+// @RequiresPermissions("goodslabelhead:update")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public R update(@RequestBody GoodsLabelHeadEntity goodsLabelHead) {
|
|
|
|
+ goodsLabelHeadService.update(goodsLabelHead);
|
|
|
|
+
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/delete")
|
|
|
|
+// @RequiresPermissions("goodslabelhead:delete")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public R delete(@RequestBody Integer[]ids) {
|
|
|
|
+ goodsLabelHeadService.deleteBatch(ids);
|
|
|
|
+
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看所有列表
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/queryAll")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public R queryAll(@RequestParam Map<String, Object> params) {
|
|
|
|
+ String merchSn = null;
|
|
|
|
+ Integer storeId = null;
|
|
|
|
+ SysUserEntity sysUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
+ if(!"1".equals(sysUser.getRoleType())){
|
|
|
|
+ merchSn = sysUser.getMerchSn();
|
|
|
|
+ storeId = sysUser.getStoreId();
|
|
|
|
+ }
|
|
|
|
+ params.put("merchSn",merchSn);
|
|
|
|
+ params.put("storeId",storeId);
|
|
|
|
+ List<GoodsLabelHeadEntity> list = goodsLabelHeadService.queryList(params);
|
|
|
|
+
|
|
|
|
+ return R.ok().put("list", list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传文件
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping("/upload")
|
|
|
|
+ public R upload(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
|
+ if (file.isEmpty()) {
|
|
|
|
+ throw new RRException("上传文件不能为空");
|
|
|
|
+ }
|
|
|
|
+// int AllowImgFileSize=0; //允许上传图片文件的大小 0为无限制 单位:KB
|
|
|
|
+// Long size = file.getSize();
|
|
|
|
+// int ImgFileSize=Math.round(size/1024*100)/100;//取得图片文件的大小
|
|
|
|
+// if(ImgFileSize > 200){
|
|
|
|
+// throw new RRException("上传图片,不能超过 300k");
|
|
|
|
+// }
|
|
|
|
+ //上传文件
|
|
|
|
+ String url = FileManager.upload(file);
|
|
|
|
+
|
|
|
|
+ //保存文件信息
|
|
|
|
+ GoodsLabelHeadEntity goodsLabelHeadEntity = new GoodsLabelHeadEntity();
|
|
|
|
+ String merchSn = null;
|
|
|
|
+ Integer storeId = null;
|
|
|
|
+ SysUserEntity sysUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
+ if(!"1".equals(sysUser.getRoleType())){
|
|
|
|
+ merchSn = sysUser.getMerchSn();
|
|
|
|
+ storeId = sysUser.getStoreId();
|
|
|
|
+ }
|
|
|
|
+ goodsLabelHeadEntity.setMerchSn(merchSn);
|
|
|
|
+ goodsLabelHeadEntity.setCreaterSn(ShiroUtils.getUserId().toString());
|
|
|
|
+ goodsLabelHeadEntity.setCreateTime(new Date());
|
|
|
|
+ goodsLabelHeadEntity.setLabelHeadUrl(url);
|
|
|
|
+ goodsLabelHeadEntity.setIsValid(Dict.isValid.item_0.getItem());
|
|
|
|
+ goodsLabelHeadEntity.setLabelHeadName(file.getOriginalFilename());
|
|
|
|
+ goodsLabelHeadEntity.setStoreId(storeId);
|
|
|
|
+
|
|
|
|
+ goodsLabelHeadService.save(goodsLabelHeadEntity);
|
|
|
|
+ R r = R.ok();
|
|
|
|
+ r.put("url", url);
|
|
|
|
+ r.put("goodsLabelHead", goodsLabelHeadEntity);
|
|
|
|
+ return r;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|