Commit 652b4e9c by 张新旗

代码修改

parent d83dc360
package com.ruoyi.web.controller.coffee;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.system.domain.Machine;
import com.ruoyi.system.domain.vo.PushBean;
......@@ -60,11 +61,10 @@ public class ApplicationController {
@RequestMapping("/jgRegister")
public AjaxResult jgRegister(@RequestParam String machineCode,@RequestParam String registerId){
Machine machine = new Machine();
machine.setId(machineCode);
List<Machine> machines = machineService.selectMachineList(machine);
if(machines==null ||machines.isEmpty()){
return AjaxResult.error("该机器未绑定店铺,请先绑定店铺");
Machine machine = machineService.selectMachineById(machineCode);
if(machine==null ){
throw new ServiceException("该机器未绑定店铺,请先绑定店铺");
}
machine.setRegister(registerId);
......
......@@ -102,7 +102,7 @@ public class ShopController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:shop:addGoods')")
@GetMapping(value = "/addGoods")
public AjaxResult addGoods(long shopId,String goodsIds)
public AjaxResult addGoods(Long shopId,String goodsIds)
{
return AjaxResult.success(shopService.addGoods(shopId,goodsIds));
}
......
......@@ -38,7 +38,7 @@ public class ShopRecommendController extends BaseController
/**
* 查询推荐和今日特惠列表
*/
@PreAuthorize("@ss.hasPermi('system:recommend:list')")
// @PreAuthorize("@ss.hasPermi('system:recommend:list')")
@GetMapping("/list")
public TableDataInfo list(ShopRecommend shopRecommend)
{
......
......@@ -82,7 +82,7 @@ public class SpecController extends BaseController
/**
* 删除规格
*/
@PreAuthorize("@ss.hasPermi('system:spec:remove')")
//@PreAuthorize("@ss.hasPermi('system:spec:remove')")
@Log(title = "规格", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable String id)
......
package com.ruoyi.framework.config;
import com.ruoyi.framework.interceptor.GlobalExceptionHandlerFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
......@@ -11,6 +12,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.access.channel.ChannelProcessingFilter;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutFilter;
import org.springframework.web.filter.CorsFilter;
......@@ -55,6 +57,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
*/
@Autowired
private CorsFilter corsFilter;
@Autowired
private GlobalExceptionHandlerFilter globalExceptionHandlerFilter;
/**
* 解决 无法直接注入 AuthenticationManager
......@@ -122,6 +126,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 添加CORS filter
httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
httpSecurity.addFilterBefore(globalExceptionHandlerFilter, ChannelProcessingFilter.class);
}
/**
......
package com.ruoyi.framework.interceptor;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Component;
import org.springframework.web.util.NestedServletException;
import javax.servlet.*;
import java.io.IOException;
import java.sql.SQLIntegrityConstraintViolationException;
@Component
public class GlobalExceptionHandlerFilter implements Filter {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
try {
filterChain.doFilter(servletRequest,servletResponse);
}catch (Exception e){
/**
* 捕捉出现的异常,根据自己的需求进行处理
* ResultEntity 自定义的响应结果封装类
* SCSException 自定义异常
*/
servletResponse.setCharacterEncoding("UTF-8");
AjaxResult ajaxResult = null;
Throwable throwable;
if(e instanceof NestedServletException){
throwable = e.getCause();
}else{
throwable = e;
}
/**
* 重复数据异常
*/
if(throwable instanceof DuplicateKeyException){
ajaxResult = AjaxResult.error("该数据已经存在");
}else if(throwable instanceof SQLIntegrityConstraintViolationException){
ajaxResult = AjaxResult.error("该数据已经存在");
}else if(throwable instanceof ServiceException){
ajaxResult = AjaxResult.error(e.getMessage());
}else{
throw e;
}
servletResponse.getWriter().write(JSONObject.toJSONString(ajaxResult));
}
}
}
......@@ -147,6 +147,7 @@ public class WeixinServiceImpl {
customer.setId(cutomerId);
customer.setHeadSculpturePath(encDataInf.getString("avatarUrl"));
customer.setUserName(encDataInf.getString("nickName"));
customer.setPhone(encDataInf.getString("phoneNumber"));
customer.setCreateTime(new Date());
if(StringUtils.isNotEmpty(source)){
customer.setSoucre(source);
......
......@@ -110,14 +110,14 @@ public class Goods extends BaseEntity
@Excel(name = "商品编码")
private String code;
private List<GoodsTag> goodsTagList;
private List<String> goodsTagList;
public List<GoodsTag> getGoodsTagList() {
public List<String> getGoodsTagList() {
return goodsTagList;
}
public void setGoodsTagList(List<GoodsTag> goodsTagList) {
public void setGoodsTagList(List<String> goodsTagList) {
this.goodsTagList = goodsTagList;
}
public void setId(long id)
......
......@@ -18,7 +18,7 @@ public class SpecRuleMaterial extends BaseEntity
private static final long serialVersionUID = 1L;
/** 主键 */
private long id;
private Long id;
/** 规则名称 */
@Excel(name = "规则名称")
......@@ -26,15 +26,15 @@ public class SpecRuleMaterial extends BaseEntity
/** 规格ID */
@Excel(name = "规格ID")
private long specId;
private Long specId;
/** 选项ID */
@Excel(name = "选项ID")
private long ruleId;
private Long ruleId;
/** 原料ID */
@Excel(name = "原料ID")
private long materialId;
private Long materialId;
/** 原料名称 */
@Excel(name = "原料名称")
......@@ -62,12 +62,12 @@ public class SpecRuleMaterial extends BaseEntity
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt;
public void setId(long id)
public void setId(Long id)
{
this.id = id;
}
public long getId()
public Long getId()
{
return id;
}
......@@ -80,12 +80,12 @@ public class SpecRuleMaterial extends BaseEntity
{
return name;
}
public void setSpecId(long specId)
public void setSpecId(Long specId)
{
this.specId = specId;
}
public long getSpecId()
public Long getSpecId()
{
return specId;
}
......@@ -94,16 +94,16 @@ public class SpecRuleMaterial extends BaseEntity
this.ruleId = ruleId;
}
public long getRuleId()
public Long getRuleId()
{
return ruleId;
}
public void setMaterialId(long materialId)
public void setMaterialId(Long materialId)
{
this.materialId = materialId;
}
public long getMaterialId()
public Long getMaterialId()
{
return materialId;
}
......
......@@ -61,4 +61,6 @@ public interface GoodsSkuMapper
public int deleteGoodsSkuByIds(String[] ids);
void deleteGoodsSkuByGoodsId(@Param("goodsId") String id);
List<GoodsSku> selectSpec(String query);
}
......@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.exception.ServiceException;
......@@ -52,7 +53,7 @@ public class GoodsServiceImpl implements IGoodsService
Goods goods = goodsMapper.selectGoodsById(id);
GoodsTag goodsTag = new GoodsTag();
goodsTag.setGoodsId(goods.getId());
goods.setGoodsTagList(goodsTagMapper.selectGoodsTagList(goodsTag));
goods.setGoodsTagList(goodsTagMapper.selectGoodsTagList(goodsTag).stream().map(GoodsTag::getTag).collect(Collectors.toList()));
return goods;
}
......@@ -124,12 +125,14 @@ public class GoodsServiceImpl implements IGoodsService
}
createSku(ruleNodeList,goodsId,goods.getDiscount(),goods.getPrice());
}
List<GoodsTag> goodsTagList = goods.getGoodsTagList();
List<String> goodsTagList = goods.getGoodsTagList();
if(goodsTagList!=null &&!goodsTagList.isEmpty()){
for (GoodsTag goodsTag : goodsTagList) {
for (String tagName : goodsTagList) {
GoodsTag goodsTag = new GoodsTag();
goodsTag.setGoodsId(goodsId);
goodsTag.setState("1");
goodsTag.setCreatedAt(new Date());
goodsTag.setTag(tagName);
goodsTagMapper.insertGoodsTag(goodsTag);
}
}
......
......@@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.service.IMachineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -95,10 +96,21 @@ public class MachineServiceImpl implements IMachineService
@Override
public String bindMachine(String code, Long shopId) {
Machine machine1 = machineMapper.selectMachineById(code);
if(machine1!=null){
throw new ServiceException("该机器已经被绑定,请先解绑再绑定");
}
Machine machine = new Machine();
machine.setShopId(shopId);
List<Machine> machines = machineMapper.selectMachineList(machine);
if(!machines.isEmpty()){
throw new ServiceException("目前只允许一个店铺绑定一台机器");
}
machine.setId(code);
machine.setCode(code);
machine.setShopId(shopId);
machine.setBindTime(new Date());
machine.setCreatedAt(new Date());
machine.setUpdatedAt(new Date());
......
......@@ -3,9 +3,12 @@ package com.ruoyi.system.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.GenerateCode;
import com.ruoyi.system.domain.GoodsSku;
import com.ruoyi.system.domain.SpecRule;
import com.ruoyi.system.domain.SpecRuleMaterial;
import com.ruoyi.system.mapper.GoodsSkuMapper;
import com.ruoyi.system.service.ISpecService;
import com.ruoyi.system.mapper.SpecRuleMapper;
import com.ruoyi.system.mapper.SpecRuleMaterialMapper;
......@@ -30,6 +33,8 @@ public class SpecServiceImpl implements ISpecService
private SpecRuleMapper specRuleMapper;
@Autowired
private SpecRuleMaterialMapper specRuleMaterialMapper;
@Autowired
private GoodsSkuMapper goodsSkuMapper;
/**
* 查询规格
......@@ -190,6 +195,11 @@ public class SpecServiceImpl implements ISpecService
@Override
public int deleteSpecById(String id)
{
String query ="\"specId\": "+id;
List<GoodsSku> goodsSkus = goodsSkuMapper.selectSpec(query);
if(!goodsSkus.isEmpty()){
throw new ServiceException("当前还有商品使用,请先删除商品");
}
long specId = Long.parseLong(id);
specRuleMapper.deleteSpecRuleBySpecId(specId);
specRuleMaterialMapper.deleteSpecRuleMaterialBySpecId(specId);
......
......@@ -87,4 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="deleteGoodsSkuByGoodsId">
update goods_sku set is_deleted ='1' where goods_id=#{goodsId}
</update>
<select id="selectSpec" resultMap="GoodsSkuResult">
<include refid="selectGoodsSkuVo"/>
where rule_list like concat('%',#{query},'%')
</select>
</mapper>
\ No newline at end of file
......@@ -144,16 +144,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sg.state,
g.code
from
shop s ,
shop_recommend sr,
shop_goods sg,
goods g
where
sr.goods_id = sg.goods_id
and g.id = sg.goods_id
and g.state = '3'
sr.shop_id = #{shopId}
and type = #{type}
and sr.shop_id = s.id
and g.is_deleted = 0
and sr.`type` = #{type}
and sr.shop_id = #{shopId}
and g.id = sr.goods_id
order by
sr.turn
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment