| | |
| | | import com.yeshi.fanli.service.inter.goods.GoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperBannerService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | |
|
| | |
| | | throw new HomeNavbarException(1, "控制时间不能为空");
|
| | | }
|
| | |
|
| | | |
| | | Integer sex = null;
|
| | | NavbarTypeEnum type = record.getType();
|
| | | if (NavbarTypeEnum.category.equals(type)) {
|
| | | Long classId = record.getClassId();
|
| | | if (classId == null) {
|
| | | throw new HomeNavbarException(1, "请选择分类");
|
| | | }
|
| | | record.setUrl(null);
|
| | |
|
| | | GoodsClass goodsClass = goodsClassService.getGoodsClass(record.getClassId());
|
| | | if (goodsClass == null) {
|
| | | throw new HomeNavbarException(1, "分类不存在");
|
| | | }
|
| | | sex = goodsClass.getSex();
|
| | | if (sex == null) {
|
| | | throw new HomeNavbarException(1, "分类未指定适用版本");
|
| | | }
|
| | | record.setUrl(null);
|
| | | } else if(NavbarTypeEnum.weex.equals(type) || NavbarTypeEnum.web.equals(type)) {
|
| | | String url = record.getUrl();
|
| | | if (url == null || url.trim().length() == 0) {
|
| | |
| | | picture = uploadPicture(file);
|
| | | }
|
| | |
|
| | | Boolean isDefault = record.getIsDefault();
|
| | | if (isDefault == null) {
|
| | | record.setIsDefault(false);
|
| | | }
|
| | | |
| | | Boolean isFixed = record.getIsFixed();
|
| | | if (isFixed == null) {
|
| | | record.setIsFixed(false);
|
| | | }
|
| | | |
| | | Long id = record.getId();
|
| | | if (id == null) {
|
| | | record.setPicture(picture);
|
| | |
| | | if (state == null) {
|
| | | record.setState(0);
|
| | | }
|
| | | int maxOrder = homeNavbarMapper.getMaxOrder();
|
| | | record.setOrderby(maxOrder + 1);
|
| | | |
| | | record.setOrderby(homeNavbarMapper.getDefaultMaxOrder() + 1);
|
| | | record.setOrderMan(homeNavbarMapper.getManMaxOrder() + 1);
|
| | | record.setOrderWoman(homeNavbarMapper.getWomanMaxOrder() + 1);
|
| | | |
| | | record.setIsFixed(false);//目前无固定项
|
| | | homeNavbarMapper.insert(record);
|
| | | } else {
|
| | |
| | | }
|
| | |
|
| | | record.setOrderby(resultObj.getOrderby());
|
| | | record.setOrderMan(resultObj.getOrderMan());
|
| | | record.setOrderWoman(resultObj.getOrderWoman());
|
| | | record.setCreatetime(resultObj.getCreatetime());
|
| | | record.setUpdatetime(new Date());
|
| | | record.setIsFixed(false);//目前无固定项
|
| | | homeNavbarMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | |
| | | /**
|
| | | * 上传图片
|
| | | * @param file
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/HomeNavbar/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath= FilePathEnum.homeNavbar.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateOrder(Long id, Integer moveType) throws HomeNavbarException, Exception{
|
| | | public void updateOrder(Long id, Integer moveType, Integer sex) throws HomeNavbarException, Exception{
|
| | |
|
| | | if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
|
| | | throw new HomeNavbarException(1, "传递的类型不正确");
|
| | |
| | | throw new HomeNavbarException(1, "ID不能为空");
|
| | | }
|
| | |
|
| | | |
| | | HomeNavbar resultObj = homeNavbarMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | throw new HomeNavbarException(1, "操作数据已不存在");
|
| | | }
|
| | |
|
| | | Integer oldOrder = resultObj.getOrderby();
|
| | | HomeNavbar changeObj = homeNavbarMapper.getChangeOrder(moveType, oldOrder);
|
| | | if (sex == null) {
|
| | | sex = GoodsClass.SEX_DEFAULT;
|
| | | }
|
| | | |
| | | HomeNavbar changeObj = null;
|
| | | if (GoodsClass.SEX_ALL == sex || GoodsClass.SEX_DEFAULT == sex) {
|
| | | Integer orderby = resultObj.getOrderby();
|
| | | changeObj = homeNavbarMapper.getDefaultChangeOrder(moveType, orderby);
|
| | | if (changeObj == null ) {
|
| | | throw new HomeNavbarException(1, "已经在最边缘,无可交换的位置");
|
| | | }
|
| | | resultObj.setOrderby(changeObj.getOrderby());
|
| | | changeObj.setOrderby(orderby);
|
| | | } else if (GoodsClass.SEX_MAN == sex) {
|
| | | Integer orderMan = resultObj.getOrderMan();
|
| | | changeObj = homeNavbarMapper.getManChangeOrder(moveType, orderMan);
|
| | | if (changeObj == null ) {
|
| | | throw new HomeNavbarException(1, "已经在最边缘,无可交换的位置");
|
| | | }
|
| | | resultObj.setOrderMan(changeObj.getOrderMan());
|
| | | changeObj.setOrderMan(orderMan);
|
| | | } else if (GoodsClass.SEX_WOMAN == sex) {
|
| | | Integer orderWoman = resultObj.getOrderWoman();
|
| | | changeObj = homeNavbarMapper.getWomanChangeOrder(moveType, orderWoman);
|
| | | if (changeObj == null ) {
|
| | | throw new HomeNavbarException(1, "已经在最边缘,无可交换的位置");
|
| | | }
|
| | | resultObj.setOrderWoman(changeObj.getOrderWoman());
|
| | | changeObj.setOrderWoman(orderWoman);
|
| | | }
|
| | |
|
| | | if (changeObj == null ) {
|
| | | throw new HomeNavbarException(1, "已经在最边缘,无可交换的位置");
|
| | | throw new HomeNavbarException(1, "无可交换的位置");
|
| | | }
|
| | | // 交换排序序号
|
| | | resultObj.setOrderby(changeObj.getOrderby());
|
| | | changeObj.setOrderby(oldOrder);
|
| | |
|
| | | homeNavbarMapper.updateByPrimaryKeySelective(changeObj);
|
| | | homeNavbarMapper.updateByPrimaryKeySelective(resultObj);
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<HomeNavbar> listQuery(long start, int count, String key) {
|
| | | public List<HomeNavbar> listQuery(long start, int count, String key, Integer sex) {
|
| | |
|
| | | List<HomeNavbar> listObj = homeNavbarMapper.listQuery(start, count, key);
|
| | | List<HomeNavbar> listObj = homeNavbarMapper.listQuery(start, count, key, sex);
|
| | | if (listObj == null || listObj.size() == 0) {
|
| | | return null;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public long countlistQuery(String key) {
|
| | | return homeNavbarMapper.countListQuery(key);
|
| | | public long countlistQuery(String key, Integer sex) {
|
| | | return homeNavbarMapper.countListQuery(key, sex);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | public List<HomeNavbar> listQueryDefaultNavbar(Integer sex) {
|
| | | return homeNavbarMapper.listQueryDefaultNavbar(sex);
|
| | | }
|
| | | |
| | | |
| | |
|
| | |
|
| | | @Override
|