parent
0467919a1a
commit
a29275ef9a
@ -0,0 +1,130 @@ |
||||
package com.bweb.controller.goods; |
||||
|
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.SessionObject; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.GoodsBrand; |
||||
import com.hfkj.model.GoodsBrandModel; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.service.goods.GoodsBrandService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/goodsBrand") |
||||
@Api(value="商品品牌") |
||||
public class GoodsBrandController { |
||||
private static final Logger log = LoggerFactory.getLogger(GoodsBrandController.class); |
||||
|
||||
@Resource |
||||
private GoodsBrandService goodsBrandService; |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@RequestMapping(value="/editGoodsBrand",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "编辑商品类型") |
||||
public ResponseData editGoodsBrand(@RequestBody GoodsBrand body, HttpServletRequest request) { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
|
||||
if (body == null |
||||
|| body.getImgUrl() == null |
||||
|| StringUtils.isBlank(body.getTitle())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
GoodsBrand GoodsBrand; |
||||
|
||||
if (body.getId() != null) { |
||||
// 查询商品类型
|
||||
GoodsBrand = goodsBrandService.queryDetail(body.getId()); |
||||
if (GoodsBrand == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
} else { |
||||
GoodsBrand = new GoodsBrand(); |
||||
GoodsBrand.setCreateTime(new Date()); |
||||
} |
||||
|
||||
GoodsBrand.setUpdateTime(new Date()); |
||||
GoodsBrand.setStatus(1); |
||||
GoodsBrand.setTitle(body.getTitle()); |
||||
GoodsBrand.setParentId(body.getParentId()); |
||||
GoodsBrand.setBusinessType(body.getBusinessType()); |
||||
GoodsBrand.setImgUrl(body.getImgUrl()); |
||||
GoodsBrand.setOpId(userModel.getAccount().getId()); |
||||
GoodsBrand.setOpName(userModel.getAccount().getUserName()); |
||||
|
||||
if (body.getId() != null) { |
||||
GoodsBrandService.update(GoodsBrand); |
||||
} else { |
||||
GoodsBrandService.create(GoodsBrand); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
} |
||||
|
||||
@RequestMapping(value="/getList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询列表") |
||||
public ResponseData getList() { |
||||
try { |
||||
|
||||
|
||||
List<GoodsBrand> list = GoodsBrandService.getList(new HashMap<>()); |
||||
|
||||
List<GoodsBrandModel> GoodsBrandModels = GoodsBrandService.getGoodsBrandModelList(list); |
||||
|
||||
|
||||
return ResponseMsgUtil.success(GoodsBrandModels); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/delete",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除") |
||||
public ResponseData delete(@RequestParam(value = "id" , required = false) Long id) { |
||||
try { |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("parentId" , id); |
||||
List<GoodsBrand> list = GoodsBrandService.getList(map); |
||||
|
||||
if (!list.isEmpty()) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "存在下级分类,不可删除!"); |
||||
} |
||||
|
||||
GoodsBrandService.delete(id , false); |
||||
|
||||
return ResponseMsgUtil.success("删除成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,77 @@ |
||||
package com.hfkj.service.goods; |
||||
|
||||
import com.hfkj.entity.GoodsBrand; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName GoodsBrandService.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 商品品牌管理
|
||||
* @createTime 15:07 2024/4/19 |
||||
**/ |
||||
public interface GoodsBrandService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name create |
||||
* @Description // 创建
|
||||
* @Date 15:11 2024/4/19 |
||||
* @Param GoodsBrand |
||||
* @return void |
||||
*/ |
||||
void create(GoodsBrand GoodsBrand); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name update |
||||
* @Description // 修改
|
||||
* @Date 15:12 2024/4/19 |
||||
* @Param GoodsBrand |
||||
* @return void |
||||
*/ |
||||
void update(GoodsBrand GoodsBrand); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name delete |
||||
* @Description // 修改
|
||||
* @Date 15:12 2024/4/19 |
||||
* @Param id |
||||
* @return void |
||||
*/ |
||||
void delete(Long id , Boolean fullDelete); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name queryDetail |
||||
* @Description // 根据ID查询产品类型详情
|
||||
* @Date 15:12 2024/4/19 |
||||
* @Param id |
||||
* @return com.hfkj.entity.GoodsBrand |
||||
*/ |
||||
GoodsBrand queryDetail(Long id); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name queryDetailByMap |
||||
* @Description // 根据多条件查询产品类型
|
||||
* @Date 15:12 2024/4/19 |
||||
* @Param map |
||||
* @return com.hfkj.entity.GoodsBrand |
||||
*/ |
||||
GoodsBrand queryDetailByMap(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getList |
||||
* @Description // 根据多条件查询列表
|
||||
* @Date 15:13 2024/4/19 |
||||
* @Param map |
||||
* @return java.util.List<com.hfkj.entity.GoodsBrand> |
||||
*/ |
||||
List<GoodsBrand> getList(Map<String , Object> map); |
||||
|
||||
} |
@ -0,0 +1,48 @@ |
||||
package com.hfkj.service.goods.impl; |
||||
|
||||
import com.hfkj.dao.GoodsBrandMapper; |
||||
import com.hfkj.entity.GoodsBrand; |
||||
import com.hfkj.service.goods.GoodsBrandService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("goodsBrandService") |
||||
public class GoodsBrandServiceImpl implements GoodsBrandService { |
||||
|
||||
@Resource |
||||
private GoodsBrandMapper goodsBrandMapper; |
||||
|
||||
@Override |
||||
public void create(GoodsBrand GoodsBrand) { |
||||
goodsBrandMapper.insert(GoodsBrand); |
||||
} |
||||
|
||||
@Override |
||||
public void update(GoodsBrand GoodsBrand) { |
||||
goodsBrandMapper.updateByPrimaryKeySelective(GoodsBrand); |
||||
} |
||||
|
||||
@Override |
||||
public void delete(Long id, Boolean fullDelete) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public GoodsBrand queryDetail(Long id) { |
||||
return goodsBrandMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public GoodsBrand queryDetailByMap(Map<String, Object> map) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<GoodsBrand> getList(Map<String, Object> map) { |
||||
return Collections.emptyList(); |
||||
} |
||||
} |
Loading…
Reference in new issue