diff --git a/hope-winery/src/main/java/com/ruoyi/winery/component/MiniComponent.java b/hope-winery/src/main/java/com/ruoyi/winery/component/MiniComponent.java index d58963600..b048799be 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/component/MiniComponent.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/component/MiniComponent.java @@ -3,9 +3,13 @@ package com.ruoyi.winery.component; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.util.SignUtils; import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.winery.config.wx.WxMiniProperties; import com.ruoyi.winery.domain.winery.WineryMauser; import com.ruoyi.winery.service.IWineryMauserService; @@ -14,6 +18,8 @@ import me.chanjar.weixin.common.error.WxErrorException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.TimeUnit; @@ -36,6 +42,13 @@ public class MiniComponent { private RedisCache redisCache; + @Autowired + private WxMiniProperties wxMiniProperties; + + @Autowired + private WxPayService wxPayService; + + public WxMaJscode2SessionResult login(String code) throws WxErrorException { WxMaJscode2SessionResult sessionInfo = wxMaService.getUserService().getSessionInfo(code); @@ -88,4 +101,27 @@ public class MiniComponent { return mobile.getPhoneNumber(); } + public JSONObject getRealAuthJson(String openid) { + + + JSONObject json = new JSONObject(); + json.set("api_version", "1.0"); + json.set("mch_id", wxMiniProperties.getMchId()); + json.set("appid", wxMiniProperties.getAppId()); + json.set("scope", "pay_identity"); + json.set("response_type", "code"); +// json.set("openid", "okT7b4rOqy7FkJ_DxuBhyRPo0sGA"); + json.set("openid", openid); + json.set("sign_type", "HMAC-SHA256"); + json.set("nonce_str", IdUtil.fastSimpleUUID()); + + Map params = json.toBean(HashMap.class); + + + json.set("sign", SignUtils.createSign(params, "HMAC-SHA256", wxMiniProperties.getMchKey(), (String[]) null)); + + + return json; + } + } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/controller/goods/GoodsMainController.java b/hope-winery/src/main/java/com/ruoyi/winery/controller/goods/GoodsMainController.java new file mode 100644 index 000000000..d80deb50f --- /dev/null +++ b/hope-winery/src/main/java/com/ruoyi/winery/controller/goods/GoodsMainController.java @@ -0,0 +1,133 @@ +package com.ruoyi.winery.controller.goods; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; + +import java.util.List; +import java.util.Arrays; + +import com.ruoyi.common.utils.StringUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.winery.domain.goods.GoodsMain; +import com.ruoyi.winery.service.IGoodsMainService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 商品信息Controller + * + * @author ruoyi + * @date 2020-12-28 + */ +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController +@RequestMapping("/goods/goods_main") +public class GoodsMainController extends BaseController { + + private final IGoodsMainService iWineryGoodsService; + + /** + * 查询商品信息列表 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_main:list')") + @GetMapping("/list") + public TableDataInfo list(UsernamePasswordAuthenticationToken token, GoodsMain goodsMain) { + startPage(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(goodsMain); + + + lqw.eq(GoodsMain::getDeptId, getDeptId(token)); + + if (StringUtils.isNotBlank(goodsMain.getGoodsName())) { + lqw.like(GoodsMain::getGoodsName, goodsMain.getGoodsName()); + } + if (StringUtils.isNotBlank(goodsMain.getGoodsAlias())) { + lqw.eq(GoodsMain::getGoodsAlias, goodsMain.getGoodsAlias()); + } + if (StringUtils.isNotBlank(goodsMain.getGoodsType())) { + lqw.eq(GoodsMain::getGoodsType, goodsMain.getGoodsType()); + } + if (StringUtils.isNotBlank(goodsMain.getGoodsSpec())) { + lqw.eq(GoodsMain::getGoodsSpec, goodsMain.getGoodsSpec()); + } + if (StringUtils.isNotBlank(goodsMain.getGoodsDesc())) { + lqw.eq(GoodsMain::getGoodsDesc, goodsMain.getGoodsDesc()); + } + if (StringUtils.isNotBlank(goodsMain.getGoodsFaceImg())) { + lqw.eq(GoodsMain::getGoodsFaceImg, goodsMain.getGoodsFaceImg()); + } + if (StringUtils.isNotBlank(goodsMain.getGoodsImg())) { + lqw.eq(GoodsMain::getGoodsImg, goodsMain.getGoodsImg()); + } + List list = iWineryGoodsService.list(lqw); + return getDataTable(list); + } + + /** + * 导出商品信息列表 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_main:export')") + @Log(title = "商品信息", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(GoodsMain goodsMain) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper(goodsMain); + List list = iWineryGoodsService.list(lqw); + ExcelUtil util = new ExcelUtil(GoodsMain.class); + return util.exportExcel(list, "winery_goods"); + } + + /** + * 获取商品信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_main:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) { + return AjaxResult.success(iWineryGoodsService.getById(id)); + } + + /** + * 新增商品信息 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_main:add')") + @Log(title = "商品信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(UsernamePasswordAuthenticationToken token, @RequestBody GoodsMain goodsMain) { + goodsMain.setDeptId(getDeptId(token)); + return toAjax(iWineryGoodsService.save(goodsMain) ? 1 : 0); + } + + /** + * 修改商品信息 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_main:edit')") + @Log(title = "商品信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody GoodsMain goodsMain) { + return toAjax(iWineryGoodsService.updateById(goodsMain) ? 1 : 0); + } + + /** + * 删除商品信息 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_main:remove')") + @Log(title = "商品信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(iWineryGoodsService.removeByIds(Arrays.asList(ids)) ? 1 : 0); + } +} diff --git a/hope-winery/src/main/java/com/ruoyi/winery/controller/goods/GoodsSpecController.java b/hope-winery/src/main/java/com/ruoyi/winery/controller/goods/GoodsSpecController.java new file mode 100644 index 000000000..71354d9be --- /dev/null +++ b/hope-winery/src/main/java/com/ruoyi/winery/controller/goods/GoodsSpecController.java @@ -0,0 +1,127 @@ +package com.ruoyi.winery.controller.goods; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; + +import java.util.List; +import java.util.Arrays; + +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.winery.domain.goods.GoodsSpec; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.winery.service.IGoodsSpecService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 商品规格Controller + * + * @author ruoyi + * @date 2020-12-28 + */ +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController +@RequestMapping("/goods/goods_spec") +public class GoodsSpecController extends BaseController { + + private final IGoodsSpecService iWineryGoodsSpecService; + + /** + * 查询商品规格列表 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_spec:list')") + @GetMapping("/list") + public TableDataInfo list(UsernamePasswordAuthenticationToken token, GoodsSpec goodsSpec) { + startPage(); + + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(goodsSpec); + + lqw.eq(GoodsSpec::getDeptId, getDeptId(token)); + + if (StringUtils.isNotBlank(goodsSpec.getSpecName())) { + lqw.like(GoodsSpec::getSpecName, goodsSpec.getSpecName()); + } + if (StringUtils.isNotBlank(goodsSpec.getSpecDesc())) { + lqw.eq(GoodsSpec::getSpecDesc, goodsSpec.getSpecDesc()); + } + if (StringUtils.isNotBlank(goodsSpec.getSpecImg())) { + lqw.eq(GoodsSpec::getSpecImg, goodsSpec.getSpecImg()); + } + if (goodsSpec.getSpecPrice() != null) { + lqw.eq(GoodsSpec::getSpecPrice, goodsSpec.getSpecPrice()); + } + if (goodsSpec.getDetailSpec() != null) { + lqw.eq(GoodsSpec::getDetailSpec, goodsSpec.getDetailSpec()); + } + List list = iWineryGoodsSpecService.list(lqw); + return getDataTable(list); + } + + /** + * 导出商品规格列表 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_spec:export')") + @Log(title = "商品规格", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(GoodsSpec goodsSpec) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper(goodsSpec); + List list = iWineryGoodsSpecService.list(lqw); + ExcelUtil util = new ExcelUtil(GoodsSpec.class); + return util.exportExcel(list, "spec"); + } + + /** + * 获取商品规格详细信息 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_spec:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) { + return AjaxResult.success(iWineryGoodsSpecService.getById(id)); + } + + /** + * 新增商品规格 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_spec:add')") + @Log(title = "商品规格", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(UsernamePasswordAuthenticationToken token, @RequestBody GoodsSpec goodsSpec) { + goodsSpec.setDeptId(getDeptId(token)); + return toAjax(iWineryGoodsSpecService.save(goodsSpec) ? 1 : 0); + } + + /** + * 修改商品规格 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_spec:edit')") + @Log(title = "商品规格", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody GoodsSpec goodsSpec) { + return toAjax(iWineryGoodsSpecService.updateById(goodsSpec) ? 1 : 0); + } + + /** + * 删除商品规格 + */ + @PreAuthorize("@ss.hasPermi('goods:goods_spec:remove')") + @Log(title = "商品规格", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(iWineryGoodsSpecService.removeByIds(Arrays.asList(ids)) ? 1 : 0); + } +} diff --git a/hope-winery/src/main/java/com/ruoyi/winery/controller/mini/MiniController.java b/hope-winery/src/main/java/com/ruoyi/winery/controller/mini/MiniController.java index 9d2b81ec0..65e176326 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/controller/mini/MiniController.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/controller/mini/MiniController.java @@ -102,6 +102,14 @@ public class MiniController { } + @GetMapping("/getRealAuthJson") + AjaxResult getRealAuthJson(@RequestParam String openid) { + + + return AjaxResult.success(miniComponent.getRealAuthJson(openid)); + + } + private WineryCompanyRecord parseRecordWineryModel(JSONObject json) { WineryCompanyRecord record = new WineryCompanyRecord(); diff --git a/hope-winery/src/main/java/com/ruoyi/winery/controller/winery/WineryGoodsController.java b/hope-winery/src/main/java/com/ruoyi/winery/controller/winery/WineryGoodsController.java deleted file mode 100644 index c89d4ebcb..000000000 --- a/hope-winery/src/main/java/com/ruoyi/winery/controller/winery/WineryGoodsController.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.ruoyi.winery.controller.winery; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; - -import java.util.List; -import java.util.Arrays; - -import com.ruoyi.common.utils.StringUtils; -import lombok.RequiredArgsConstructor; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.winery.domain.winery.WineryGoods; -import com.ruoyi.winery.service.IWineryGoodsService; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.common.core.page.TableDataInfo; - -/** - * 商品信息Controller - * - * @author ruoyi - * @date 2020-12-28 - */ -@RequiredArgsConstructor(onConstructor_ = @Autowired) -@RestController -@RequestMapping("/winery/winery_goods" ) -public class WineryGoodsController extends BaseController { - - private final IWineryGoodsService iWineryGoodsService; - - /** - * 查询商品信息列表 - */ - @PreAuthorize("@ss.hasPermi('winery:winery_goods:list')") - @GetMapping("/list") - public TableDataInfo list(WineryGoods wineryGoods) - { - startPage(); - LambdaQueryWrapper lqw = Wrappers.lambdaQuery(wineryGoods); - if (wineryGoods.getDeptId() != null){ - lqw.eq(WineryGoods::getDeptId ,wineryGoods.getDeptId()); - } - if (StringUtils.isNotBlank(wineryGoods.getGoodsName())){ - lqw.like(WineryGoods::getGoodsName ,wineryGoods.getGoodsName()); - } - if (StringUtils.isNotBlank(wineryGoods.getGoodsAlias())){ - lqw.eq(WineryGoods::getGoodsAlias ,wineryGoods.getGoodsAlias()); - } - if (StringUtils.isNotBlank(wineryGoods.getGoodsType())){ - lqw.eq(WineryGoods::getGoodsType ,wineryGoods.getGoodsType()); - } - if (StringUtils.isNotBlank(wineryGoods.getGoodsSpec())){ - lqw.eq(WineryGoods::getGoodsSpec ,wineryGoods.getGoodsSpec()); - } - if (StringUtils.isNotBlank(wineryGoods.getGoodsDesc())){ - lqw.eq(WineryGoods::getGoodsDesc ,wineryGoods.getGoodsDesc()); - } - if (StringUtils.isNotBlank(wineryGoods.getGoodsFaceImg())){ - lqw.eq(WineryGoods::getGoodsFaceImg ,wineryGoods.getGoodsFaceImg()); - } - if (StringUtils.isNotBlank(wineryGoods.getGoodsImg())){ - lqw.eq(WineryGoods::getGoodsImg ,wineryGoods.getGoodsImg()); - } - List list = iWineryGoodsService.list(lqw); - return getDataTable(list); - } - - /** - * 导出商品信息列表 - */ - @PreAuthorize("@ss.hasPermi('winery:winery_goods:export')" ) - @Log(title = "商品信息" , businessType = BusinessType.EXPORT) - @GetMapping("/export" ) - public AjaxResult export(WineryGoods wineryGoods) { - LambdaQueryWrapper lqw = new LambdaQueryWrapper(wineryGoods); - List list = iWineryGoodsService.list(lqw); - ExcelUtil util = new ExcelUtil(WineryGoods. class); - return util.exportExcel(list, "winery_goods" ); - } - - /** - * 获取商品信息详细信息 - */ - @PreAuthorize("@ss.hasPermi('winery:winery_goods:query')" ) - @GetMapping(value = "/{id}" ) - public AjaxResult getInfo(@PathVariable("id" ) Long id) { - return AjaxResult.success(iWineryGoodsService.getById(id)); - } - - /** - * 新增商品信息 - */ - @PreAuthorize("@ss.hasPermi('winery:winery_goods:add')" ) - @Log(title = "商品信息" , businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody WineryGoods wineryGoods) { - return toAjax(iWineryGoodsService.save(wineryGoods) ? 1 : 0); - } - - /** - * 修改商品信息 - */ - @PreAuthorize("@ss.hasPermi('winery:winery_goods:edit')" ) - @Log(title = "商品信息" , businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody WineryGoods wineryGoods) { - return toAjax(iWineryGoodsService.updateById(wineryGoods) ? 1 : 0); - } - - /** - * 删除商品信息 - */ - @PreAuthorize("@ss.hasPermi('winery:winery_goods:remove')" ) - @Log(title = "商品信息" , businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}" ) - public AjaxResult remove(@PathVariable Long[] ids) { - return toAjax(iWineryGoodsService.removeByIds(Arrays.asList(ids)) ? 1 : 0); - } -} diff --git a/hope-winery/src/main/java/com/ruoyi/winery/controller/winery/WineryGoodsSpecController.java b/hope-winery/src/main/java/com/ruoyi/winery/controller/winery/WineryGoodsSpecController.java deleted file mode 100644 index cc71dc665..000000000 --- a/hope-winery/src/main/java/com/ruoyi/winery/controller/winery/WineryGoodsSpecController.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.ruoyi.winery.controller.winery; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; - -import java.util.List; -import java.util.Arrays; - -import com.ruoyi.common.utils.StringUtils; -import lombok.RequiredArgsConstructor; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.winery.domain.winery.WineryGoodsSpec; -import com.ruoyi.winery.service.IWineryGoodsSpecService; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.common.core.page.TableDataInfo; - -/** - * 商品规格Controller - * - * @author ruoyi - * @date 2020-12-28 - */ -@RequiredArgsConstructor(onConstructor_ = @Autowired) -@RestController -@RequestMapping("/winery/spec" ) -public class WineryGoodsSpecController extends BaseController { - - private final IWineryGoodsSpecService iWineryGoodsSpecService; - - /** - * 查询商品规格列表 - */ - @PreAuthorize("@ss.hasPermi('winery:spec:list')") - @GetMapping("/list") - public TableDataInfo list(WineryGoodsSpec wineryGoodsSpec) - { - startPage(); - LambdaQueryWrapper lqw = Wrappers.lambdaQuery(wineryGoodsSpec); - if (wineryGoodsSpec.getDeptId() != null){ - lqw.eq(WineryGoodsSpec::getDeptId ,wineryGoodsSpec.getDeptId()); - } - if (StringUtils.isNotBlank(wineryGoodsSpec.getSpecName())){ - lqw.like(WineryGoodsSpec::getSpecName ,wineryGoodsSpec.getSpecName()); - } - if (StringUtils.isNotBlank(wineryGoodsSpec.getSpecDesc())){ - lqw.eq(WineryGoodsSpec::getSpecDesc ,wineryGoodsSpec.getSpecDesc()); - } - if (StringUtils.isNotBlank(wineryGoodsSpec.getSpecImg())){ - lqw.eq(WineryGoodsSpec::getSpecImg ,wineryGoodsSpec.getSpecImg()); - } - if (wineryGoodsSpec.getSpecPrice() != null){ - lqw.eq(WineryGoodsSpec::getSpecPrice ,wineryGoodsSpec.getSpecPrice()); - } - if (wineryGoodsSpec.getDetailSpec() != null){ - lqw.eq(WineryGoodsSpec::getDetailSpec ,wineryGoodsSpec.getDetailSpec()); - } - List list = iWineryGoodsSpecService.list(lqw); - return getDataTable(list); - } - - /** - * 导出商品规格列表 - */ - @PreAuthorize("@ss.hasPermi('winery:spec:export')" ) - @Log(title = "商品规格" , businessType = BusinessType.EXPORT) - @GetMapping("/export" ) - public AjaxResult export(WineryGoodsSpec wineryGoodsSpec) { - LambdaQueryWrapper lqw = new LambdaQueryWrapper(wineryGoodsSpec); - List list = iWineryGoodsSpecService.list(lqw); - ExcelUtil util = new ExcelUtil(WineryGoodsSpec. class); - return util.exportExcel(list, "spec" ); - } - - /** - * 获取商品规格详细信息 - */ - @PreAuthorize("@ss.hasPermi('winery:spec:query')" ) - @GetMapping(value = "/{id}" ) - public AjaxResult getInfo(@PathVariable("id" ) Long id) { - return AjaxResult.success(iWineryGoodsSpecService.getById(id)); - } - - /** - * 新增商品规格 - */ - @PreAuthorize("@ss.hasPermi('winery:spec:add')" ) - @Log(title = "商品规格" , businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody WineryGoodsSpec wineryGoodsSpec) { - return toAjax(iWineryGoodsSpecService.save(wineryGoodsSpec) ? 1 : 0); - } - - /** - * 修改商品规格 - */ - @PreAuthorize("@ss.hasPermi('winery:spec:edit')" ) - @Log(title = "商品规格" , businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody WineryGoodsSpec wineryGoodsSpec) { - return toAjax(iWineryGoodsSpecService.updateById(wineryGoodsSpec) ? 1 : 0); - } - - /** - * 删除商品规格 - */ - @PreAuthorize("@ss.hasPermi('winery:spec:remove')" ) - @Log(title = "商品规格" , businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}" ) - public AjaxResult remove(@PathVariable Long[] ids) { - return toAjax(iWineryGoodsSpecService.removeByIds(Arrays.asList(ids)) ? 1 : 0); - } -} diff --git a/hope-winery/src/main/java/com/ruoyi/winery/domain/NewsContent.java b/hope-winery/src/main/java/com/ruoyi/winery/domain/NewsContent.java index 6fa1d8a59..3fff26eab 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/domain/NewsContent.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/domain/NewsContent.java @@ -69,6 +69,5 @@ private static final long serialVersionUID=1L; private Integer newsType; /** 状态 */ - @Excel(name = "状态") private Integer state; } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryGoods.java b/hope-winery/src/main/java/com/ruoyi/winery/domain/goods/GoodsMain.java similarity index 91% rename from hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryGoods.java rename to hope-winery/src/main/java/com/ruoyi/winery/domain/goods/GoodsMain.java index 77e8b442a..24363bf4c 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryGoods.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/domain/goods/GoodsMain.java @@ -1,4 +1,4 @@ -package com.ruoyi.winery.domain.winery; +package com.ruoyi.winery.domain.goods; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; @@ -26,8 +26,8 @@ import com.ruoyi.common.core.domain.BaseEntity; @EqualsAndHashCode @NoArgsConstructor @Accessors(chain = true) -@TableName("winery_goods") -public class WineryGoods implements Serializable { +@TableName("goods_main") +public class GoodsMain implements Serializable { private static final long serialVersionUID=1L; @@ -83,4 +83,9 @@ private static final long serialVersionUID=1L; /** 备注 */ @Excel(name = "备注") private String remark; + + /** + * 状态 + */ + private Integer state; } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryGoodsSpec.java b/hope-winery/src/main/java/com/ruoyi/winery/domain/goods/GoodsSpec.java similarity index 91% rename from hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryGoodsSpec.java rename to hope-winery/src/main/java/com/ruoyi/winery/domain/goods/GoodsSpec.java index 37bde5fa4..05fa49c55 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryGoodsSpec.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/domain/goods/GoodsSpec.java @@ -1,4 +1,4 @@ -package com.ruoyi.winery.domain.winery; +package com.ruoyi.winery.domain.goods; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; @@ -26,8 +26,8 @@ import com.ruoyi.common.core.domain.BaseEntity; @EqualsAndHashCode @NoArgsConstructor @Accessors(chain = true) -@TableName("winery_goods_spec") -public class WineryGoodsSpec implements Serializable { +@TableName("goods_spec") +public class GoodsSpec implements Serializable { private static final long serialVersionUID=1L; @@ -66,7 +66,7 @@ private static final long serialVersionUID=1L; /** 规格单价 */ @Excel(name = "规格单价") - private Long specPrice; + private BigDecimal specPrice; /** 规格详细 */ @Excel(name = "规格详细") diff --git a/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryOrders.java b/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryOrders.java index 1e03fd7a5..15695dfca 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryOrders.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/domain/winery/WineryOrders.java @@ -80,7 +80,7 @@ public class WineryOrders implements Serializable { * 商品基准单价 */ @Excel(name = "商品基准单价") - private Long goodsPrice; + private BigDecimal goodsPrice; /** * 商品数量 diff --git a/hope-winery/src/main/java/com/ruoyi/winery/mapper/WineryGoodsMapper.java b/hope-winery/src/main/java/com/ruoyi/winery/mapper/GoodsMainMapper.java similarity index 58% rename from hope-winery/src/main/java/com/ruoyi/winery/mapper/WineryGoodsMapper.java rename to hope-winery/src/main/java/com/ruoyi/winery/mapper/GoodsMainMapper.java index 3e29a6cb5..1db5d7c8e 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/mapper/WineryGoodsMapper.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/mapper/GoodsMainMapper.java @@ -1,6 +1,6 @@ package com.ruoyi.winery.mapper; -import com.ruoyi.winery.domain.winery.WineryGoods; +import com.ruoyi.winery.domain.goods.GoodsMain; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** @@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author ruoyi * @date 2020-12-28 */ -public interface WineryGoodsMapper extends BaseMapper { +public interface GoodsMainMapper extends BaseMapper { } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/mapper/WineryGoodsSpecMapper.java b/hope-winery/src/main/java/com/ruoyi/winery/mapper/GoodsSpecMapper.java similarity index 56% rename from hope-winery/src/main/java/com/ruoyi/winery/mapper/WineryGoodsSpecMapper.java rename to hope-winery/src/main/java/com/ruoyi/winery/mapper/GoodsSpecMapper.java index cc44fca8b..2c1b8e574 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/mapper/WineryGoodsSpecMapper.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/mapper/GoodsSpecMapper.java @@ -1,6 +1,6 @@ package com.ruoyi.winery.mapper; -import com.ruoyi.winery.domain.winery.WineryGoodsSpec; +import com.ruoyi.winery.domain.goods.GoodsSpec; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** @@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author ruoyi * @date 2020-12-28 */ -public interface WineryGoodsSpecMapper extends BaseMapper { +public interface GoodsSpecMapper extends BaseMapper { } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/service/IWineryGoodsService.java b/hope-winery/src/main/java/com/ruoyi/winery/service/IGoodsMainService.java similarity index 59% rename from hope-winery/src/main/java/com/ruoyi/winery/service/IWineryGoodsService.java rename to hope-winery/src/main/java/com/ruoyi/winery/service/IGoodsMainService.java index fd44bde9e..0e38b1cdf 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/service/IWineryGoodsService.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/service/IGoodsMainService.java @@ -1,6 +1,6 @@ package com.ruoyi.winery.service; -import com.ruoyi.winery.domain.winery.WineryGoods; +import com.ruoyi.winery.domain.goods.GoodsMain; import com.baomidou.mybatisplus.extension.service.IService; /** @@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.extension.service.IService; * @author ruoyi * @date 2020-12-28 */ -public interface IWineryGoodsService extends IService { +public interface IGoodsMainService extends IService { } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/service/IWineryGoodsSpecService.java b/hope-winery/src/main/java/com/ruoyi/winery/service/IGoodsSpecService.java similarity index 57% rename from hope-winery/src/main/java/com/ruoyi/winery/service/IWineryGoodsSpecService.java rename to hope-winery/src/main/java/com/ruoyi/winery/service/IGoodsSpecService.java index 4fb2b0e0b..f3522ffb3 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/service/IWineryGoodsSpecService.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/service/IGoodsSpecService.java @@ -1,6 +1,6 @@ package com.ruoyi.winery.service; -import com.ruoyi.winery.domain.winery.WineryGoodsSpec; +import com.ruoyi.winery.domain.goods.GoodsSpec; import com.baomidou.mybatisplus.extension.service.IService; /** @@ -9,6 +9,6 @@ import com.baomidou.mybatisplus.extension.service.IService; * @author ruoyi * @date 2020-12-28 */ -public interface IWineryGoodsSpecService extends IService { +public interface IGoodsSpecService extends IService { } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsServiceImpl.java b/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsServiceImpl.java index feb0b28e4..9bbef35f6 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsServiceImpl.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsServiceImpl.java @@ -1,10 +1,10 @@ package com.ruoyi.winery.service.impl; +import com.ruoyi.winery.mapper.GoodsMainMapper; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.winery.mapper.WineryGoodsMapper; -import com.ruoyi.winery.domain.winery.WineryGoods; -import com.ruoyi.winery.service.IWineryGoodsService; +import com.ruoyi.winery.domain.goods.GoodsMain; +import com.ruoyi.winery.service.IGoodsMainService; /** * 商品信息Service业务层处理 @@ -13,6 +13,6 @@ import com.ruoyi.winery.service.IWineryGoodsService; * @date 2020-12-28 */ @Service -public class WineryGoodsServiceImpl extends ServiceImpl implements IWineryGoodsService { +public class WineryGoodsServiceImpl extends ServiceImpl implements IGoodsMainService { } diff --git a/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsSpecServiceImpl.java b/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsSpecServiceImpl.java index 6dd84aff0..4de4ebdf3 100644 --- a/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsSpecServiceImpl.java +++ b/hope-winery/src/main/java/com/ruoyi/winery/service/impl/WineryGoodsSpecServiceImpl.java @@ -2,9 +2,9 @@ package com.ruoyi.winery.service.impl; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.winery.mapper.WineryGoodsSpecMapper; -import com.ruoyi.winery.domain.winery.WineryGoodsSpec; -import com.ruoyi.winery.service.IWineryGoodsSpecService; +import com.ruoyi.winery.mapper.GoodsSpecMapper; +import com.ruoyi.winery.domain.goods.GoodsSpec; +import com.ruoyi.winery.service.IGoodsSpecService; /** * 商品规格Service业务层处理 @@ -13,6 +13,6 @@ import com.ruoyi.winery.service.IWineryGoodsSpecService; * @date 2020-12-28 */ @Service -public class WineryGoodsSpecServiceImpl extends ServiceImpl implements IWineryGoodsSpecService { +public class WineryGoodsSpecServiceImpl extends ServiceImpl implements IGoodsSpecService { } diff --git a/hope-winery/src/main/resources/mapper/winery/WineryGoodsMapper.xml b/hope-winery/src/main/resources/mapper/goods/WineryGoodsMapper.xml similarity index 89% rename from hope-winery/src/main/resources/mapper/winery/WineryGoodsMapper.xml rename to hope-winery/src/main/resources/mapper/goods/WineryGoodsMapper.xml index 83dac7080..1174e9e2c 100644 --- a/hope-winery/src/main/resources/mapper/winery/WineryGoodsMapper.xml +++ b/hope-winery/src/main/resources/mapper/goods/WineryGoodsMapper.xml @@ -2,9 +2,9 @@ - + - + diff --git a/hope-winery/src/main/resources/mapper/winery/WineryGoodsSpecMapper.xml b/hope-winery/src/main/resources/mapper/goods/WineryGoodsSpecMapper.xml similarity index 86% rename from hope-winery/src/main/resources/mapper/winery/WineryGoodsSpecMapper.xml rename to hope-winery/src/main/resources/mapper/goods/WineryGoodsSpecMapper.xml index 35a158a6b..ef0ac4d92 100644 --- a/hope-winery/src/main/resources/mapper/winery/WineryGoodsSpecMapper.xml +++ b/hope-winery/src/main/resources/mapper/goods/WineryGoodsSpecMapper.xml @@ -2,9 +2,9 @@ - + - + diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/CosUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/CosUtils.java index 29a40e6ec..2eae54e50 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/CosUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/CosUtils.java @@ -42,9 +42,18 @@ public class CosUtils { @Autowired private CosProperties properties; - // 指定要上传到的存储桶 + /** + * 正则异常字符 + */ String SPECIAL_CHARACTERS = "[`~! @#$%^&*()+=|{}':;',//[//]<>/?~!@#¥%……&*()_——+|{}【】‘;:”“’。,、?]"; + /** + * 表单提交文件 + * + * @param type + * @param file + * @return + */ public String upload(String type, MultipartFile file) { @@ -69,10 +78,42 @@ public class CosUtils { } - public void getFile(String fileName, HttpServletResponse response) { + + /** + * 上传文件 + * + * @param type + * @param fileKey + * @param file + * @return + */ + public String uploadFile(String type, String fileKey, File file) { + + // 指定要上传到 COS 上对象键 + String key = ReUtil.replaceAll(StrUtil.trim(Optional.of(fileKey).orElse(StrUtil.EMPTY)), SPECIAL_CHARACTERS, StrUtil.EMPTY); + // 生成 cos 客户端。 + COSClient cosClient = new COSClient(cosCredentials, clientConfig); + try { + PutObjectResult putObjectResult = cosClient.putObject(properties.getBucketName(), type + "/" + key, file); + } catch (Exception e) { + } finally { + + cosClient.shutdown(); + } + return type + "/" + key; + + } + + /** + * 根据文件key下载文件 + * + * @param fileKey + * @param response + */ + public void getFile(String fileKey, HttpServletResponse response) { COSClient cosClient = new COSClient(cosCredentials, clientConfig); - GetObjectRequest getObjectRequest = new GetObjectRequest(properties.getBucketName(), fileName); + GetObjectRequest getObjectRequest = new GetObjectRequest(properties.getBucketName(), fileKey); // 限流使用的单位是bit/s, 这里设置下载带宽限制为 10MB/s getObjectRequest.setTrafficLimit(80 * 1024 * 1024); @@ -110,22 +151,4 @@ public class CosUtils { } - public String uploadFile(String type, String filename, File file) { - - - // 指定要上传到 COS 上对象键 - String key = ReUtil.replaceAll(StrUtil.trim(Optional.of(filename).orElse(StrUtil.EMPTY)), SPECIAL_CHARACTERS, StrUtil.EMPTY); - // 生成 cos 客户端。 - COSClient cosClient = new COSClient(cosCredentials, clientConfig); - try { - PutObjectResult putObjectResult = cosClient.putObject(properties.getBucketName(), type + "/" + key, file); - } catch (Exception e) { - } finally { - - cosClient.shutdown(); - } - return type + "/" + key; - - } - } diff --git a/ruoyi-ui/src/api/winery/winery_goods.js b/ruoyi-ui/src/api/goods/goods_main.js similarity index 77% rename from ruoyi-ui/src/api/winery/winery_goods.js rename to ruoyi-ui/src/api/goods/goods_main.js index 9332243b1..9afac1fb3 100644 --- a/ruoyi-ui/src/api/winery/winery_goods.js +++ b/ruoyi-ui/src/api/goods/goods_main.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询商品信息列表 export function listWinery_goods(query) { return request({ - url: '/winery/winery_goods/list', + url: '/goods/goods_main/list', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listWinery_goods(query) { // 查询商品信息详细 export function getWinery_goods(id) { return request({ - url: '/winery/winery_goods/' + id, + url: '/goods/goods_main/' + id, method: 'get' }) } @@ -20,7 +20,7 @@ export function getWinery_goods(id) { // 新增商品信息 export function addWinery_goods(data) { return request({ - url: '/winery/winery_goods', + url: '/goods/goods_main', method: 'post', data: data }) @@ -29,7 +29,7 @@ export function addWinery_goods(data) { // 修改商品信息 export function updateWinery_goods(data) { return request({ - url: '/winery/winery_goods', + url: '/goods/goods_main', method: 'put', data: data }) @@ -38,7 +38,7 @@ export function updateWinery_goods(data) { // 删除商品信息 export function delWinery_goods(id) { return request({ - url: '/winery/winery_goods/' + id, + url: '/goods/goods_main/' + id, method: 'delete' }) } @@ -46,8 +46,8 @@ export function delWinery_goods(id) { // 导出商品信息 export function exportWinery_goods(query) { return request({ - url: '/winery/winery_goods/export', + url: '/goods/goods_main/export', method: 'get', params: query }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/api/winery/spec.js b/ruoyi-ui/src/api/goods/goods_spec.js similarity index 77% rename from ruoyi-ui/src/api/winery/spec.js rename to ruoyi-ui/src/api/goods/goods_spec.js index e1c892e2d..51e9a5ace 100644 --- a/ruoyi-ui/src/api/winery/spec.js +++ b/ruoyi-ui/src/api/goods/goods_spec.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询商品规格列表 export function listSpec(query) { return request({ - url: '/winery/spec/list', + url: '/goods/goods_spec/list', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listSpec(query) { // 查询商品规格详细 export function getSpec(id) { return request({ - url: '/winery/spec/' + id, + url: '/goods/goods_spec/' + id, method: 'get' }) } @@ -20,7 +20,7 @@ export function getSpec(id) { // 新增商品规格 export function addSpec(data) { return request({ - url: '/winery/spec', + url: '/goods/goods_spec', method: 'post', data: data }) @@ -29,7 +29,7 @@ export function addSpec(data) { // 修改商品规格 export function updateSpec(data) { return request({ - url: '/winery/spec', + url: '/goods/goods_spec', method: 'put', data: data }) @@ -38,7 +38,7 @@ export function updateSpec(data) { // 删除商品规格 export function delSpec(id) { return request({ - url: '/winery/spec/' + id, + url: '/goods/goods_spec/' + id, method: 'delete' }) } @@ -46,8 +46,8 @@ export function delSpec(id) { // 导出商品规格 export function exportSpec(query) { return request({ - url: '/winery/spec/export', + url: '/goods/goods_spec/export', method: 'get', params: query }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/views/winery/winery_goods/index.vue b/ruoyi-ui/src/views/goods/goods_main/index.vue similarity index 73% rename from ruoyi-ui/src/views/winery/winery_goods/index.vue rename to ruoyi-ui/src/views/goods/goods_main/index.vue index 7c4cda9e3..90f50e85d 100644 --- a/ruoyi-ui/src/views/winery/winery_goods/index.vue +++ b/ruoyi-ui/src/views/goods/goods_main/index.vue @@ -19,8 +19,6 @@ @keyup.enter.native="handleQuery" /> - - @@ -48,7 +46,7 @@ icon="el-icon-plus" size="mini" @click="handleAdd" - v-hasPermi="['winery:winery_goods:add']" + v-hasPermi="['goods:goods_main:add']" >新增 @@ -59,7 +57,7 @@ size="mini" :disabled="single" @click="handleUpdate" - v-hasPermi="['winery:winery_goods:edit']" + v-hasPermi="['goods:goods_main:edit']" >修改 @@ -70,7 +68,7 @@ size="mini" :disabled="multiple" @click="handleDelete" - v-hasPermi="['winery:winery_goods:remove']" + v-hasPermi="['goods:goods_main:remove']" >删除 @@ -80,27 +78,34 @@ icon="el-icon-download" size="mini" @click="handleExport" - v-hasPermi="['winery:winery_goods:export']" + v-hasPermi="['goods:goods_main:export']" >导出 - + - - + + - + + + + @@ -133,7 +138,7 @@ /> - + @@ -142,27 +147,38 @@ + + + + + + + + + + + + {{dict.dictLabel}} + + - + + - + + - - - - - - - - - @@ -183,18 +199,22 @@ import { addWinery_goods, updateWinery_goods, exportWinery_goods -} from "@/api/winery/winery_goods"; +} from "@/api/goods/goods_main"; import UploadImage from '@/components/UploadImage/index' import UploadImageMultiple from '@/components/UploadImageMultiple/index' import CommonMixin from "@/mixin/common"; +import Editor from '@/components/Editor/index'; +import {listSpec} from "@/api/goods/goods_spec"; +import {getDictName} from "@/utils/utils"; export default { - name: "Winery_goods", - mixins:[CommonMixin], + name: "GoodsMain", + mixins: [CommonMixin], components: { UploadImage, UploadImageMultiple, + Editor }, computed: {}, data() { @@ -212,11 +232,13 @@ export default { // 总条数 total: 0, // 商品信息表格数据 - winery_goodsList: [], + goodsList: [], // 弹出层标题 title: "", // 是否显示弹出层 open: false, + // 状态字典 + stateOptions: [], // 查询参数 queryParams: { pageNum: 1, @@ -228,15 +250,30 @@ export default { goodsDesc: undefined, goodsFaceImg: undefined, goodsImg: undefined, + state: undefined }, // 表单参数 form: {}, // 表单校验 - rules: {} + rules: {}, + + // 规格 + specData: [], + // 已选规格 + selectedSpecData: [] + }; }, + filters: { + getStateName(value, options) { + return getDictName(value, options) + } + }, created() { this.getList(); + this.getDicts("sys_release_status").then(response => { + this.stateOptions = response.data; + }); }, methods: { inputGoodsFaceImg(fileName) { @@ -246,11 +283,15 @@ export default { inputGoodsImg(fileName) { this.form.goodsImg = fileName }, + // 状态字典翻译 + stateFormat(row, column) { + return this.selectDictLabel(this.stateOptions, row.state); + }, /** 查询商品信息列表 */ getList() { this.loading = true; listWinery_goods(this.queryParams).then(response => { - this.winery_goodsList = response.rows; + this.goodsList = response.rows; this.total = response.total; this.loading = false; }); @@ -309,6 +350,22 @@ export default { this.form = response.data; this.open = true; this.title = "修改商品信息"; + + listSpec({ + pageNum: 1, + pageSize: 999 + }).then(r => { + this.specData = [] + for (let i = 0; i < r.rows.length; i++) { + this.specData.push({ + key: r.rows[i].id, + label: r.rows[i].specName, + // disabled: i % 4 === 0 + }); + } + + this.selectedSpecData = this.form.goodsSpec.split(',') + }) }); }, /** 提交按钮 */ @@ -316,6 +373,7 @@ export default { this.$refs["form"].validate(valid => { if (valid) { if (this.form.id != null) { + this.form.goodsSpec = this.selectedSpecData.join(',') updateWinery_goods(this.form).then(response => { this.msgSuccess("修改成功"); this.open = false; @@ -357,6 +415,21 @@ export default { }).then(response => { this.download(response.msg); }) + }, + /** + * 商品详情 + * @param value + */ + onChangeGoodsDesc(value) { + this.form.goodsDesc = value.html + }, + + + /** + * 规格关联穿梭框 + */ + handleChangeSpec(value, direction, movedKeys) { + console.log(value, direction, movedKeys); } } }; diff --git a/ruoyi-ui/src/views/winery/spec/index.vue b/ruoyi-ui/src/views/goods/goods_spec/index.vue similarity index 78% rename from ruoyi-ui/src/views/winery/spec/index.vue rename to ruoyi-ui/src/views/goods/goods_spec/index.vue index d194be2e4..e0499d1ab 100644 --- a/ruoyi-ui/src/views/winery/spec/index.vue +++ b/ruoyi-ui/src/views/goods/goods_spec/index.vue @@ -1,15 +1,15 @@