Browse Source

新增品类上移、置顶

anderx 7 years ago
parent
commit
9891ee599a

+ 35 - 0
src/main/java/com/goafanti/business/controller/AdminJtBusinessController.java

@@ -199,6 +199,7 @@ public class AdminJtBusinessController extends CertifyApiController{
 		return result;
 	}
 	
+	
 	@RequestMapping(value="/project/update",method=RequestMethod.POST)
 	private Result updateProject(JtBusinessProject jtBusinessProject) {
 		Result result=new Result();
@@ -329,6 +330,40 @@ public class AdminJtBusinessController extends CertifyApiController{
 		result.data(jtTagService.selectListJtTag(a,pageNo,pageSize));
 		return result;
 	}
+	/*
+	 * 上移品类
+	 * */
+	@RequestMapping(value="/project/moveUp",method=RequestMethod.POST)
+	private Result updateProjectMoveUp(String id) {
+		Result result=new Result();
+		if(StringUtils.isBlank(id)) {
+    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"品类ID","品类ID"));return result;
+    	}
+		int x=jtBusinessService.updateProjectMoveUp(id);
+		if(x==-1) {
+    		result.getError().add(buildError("上移失败","上移失败"));return result;
+    	}
+		result.data(x);
+		return result;
+	}
+	/*
+	 * 品类置顶
+	 * */
+	@RequestMapping(value="/project/setTop",method=RequestMethod.POST)
+	private Result updateProjectSetTop(String id) {
+		Result result=new Result();
+		if(StringUtils.isBlank(id)) {
+    		result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"品类ID","品类ID"));return result;
+    	}
+		int x=jtBusinessService.updateProjectSetTop(id);
+		if(x==-1) {
+    		result.getError().add(buildError("置顶失败","置顶失败"));return result;
+    	}
+		result.data(x);
+		return result;
+	}
+	
+	
 	
 	
 }

+ 14 - 0
src/main/java/com/goafanti/business/service/JtBusinessService.java

@@ -56,5 +56,19 @@ public interface JtBusinessService {
 	 * @return
 	 */
 	List<JtBusinessProject> getModuleByName(String  name, Integer isHost, Integer size);
+	/**
+	 * 品类上移
+	 * @param id
+	 * @return
+	 */
+	int updateProjectMoveUp(String id);
+	/**
+	 * 品类置顶
+	 * @param id
+	 * @return
+	 */
+	int updateProjectSetTop(String id);
+	
+	
 	
 }

+ 2 - 0
src/main/java/com/goafanti/business/service/JtTagService.java

@@ -16,4 +16,6 @@ public interface JtTagService {
 
 	Pagination<JtTagBo> selectListJtTag(JtTag a, Integer pageNo, Integer pageSize);
 
+	
+
 }

+ 37 - 0
src/main/java/com/goafanti/business/service/impl/JtBusinessServiceImpl.java

@@ -450,6 +450,43 @@ public class JtBusinessServiceImpl  extends BaseMybatisDao<JtBusinessProjectMapp
 			Integer size) {
 		return jtBusinessProjectMapper.getModuleByName(name, isHost, size);
 	}
+
+	@Override
+	public int updateProjectMoveUp(String id) {
+		JtBusinessCategory j1=jtBusinessCategoryMapper.selectByPrimaryKey(id);
+		JtBusinessCategory j2=jtBusinessCategoryMapper.selectFirstLevel(id,j1.getModule(),j1.getLayer(),0);
+		if(null==j1||null==j2){
+			return -1;
+		}
+		Integer i=j1.getSort();
+		JtBusinessCategory jtBusinessCategory=new JtBusinessCategory();
+		jtBusinessCategory.setId(j1.getId());
+		jtBusinessCategory.setSort(j2.getSort());
+		jtBusinessCategoryMapper.updateByPrimaryKeySelective(jtBusinessCategory);
+		jtBusinessCategory.setId(j2.getId());
+		jtBusinessCategory.setSort(i);
+		jtBusinessCategoryMapper.updateByPrimaryKeySelective(jtBusinessCategory);
+		
+		return 1;
+	}
+
+	@Override
+	public int updateProjectSetTop(String id) {
+		JtBusinessCategory j1=jtBusinessCategoryMapper.selectByPrimaryKey(id);
+		JtBusinessCategory j2=jtBusinessCategoryMapper.selectFirstLevel(id,j1.getModule(),j1.getLayer(),1);
+		if(null==j1||null==j2){
+			return -1;
+		}
+		Integer i=j1.getSort();
+		JtBusinessCategory jtBusinessCategory=new JtBusinessCategory();
+		jtBusinessCategory.setId(j1.getId());
+		jtBusinessCategory.setSort(j2.getSort());
+		jtBusinessCategoryMapper.updateByPrimaryKeySelective(jtBusinessCategory);
+		jtBusinessCategory.setId(j2.getId());
+		jtBusinessCategory.setSort(i);
+		jtBusinessCategoryMapper.updateByPrimaryKeySelective(jtBusinessCategory);
+		return 1;
+	}
 	
 
 }

+ 5 - 3
src/main/java/com/goafanti/business/service/impl/JtBusinessServiceWithCategoryMapperImpl.java

@@ -18,21 +18,23 @@ public class JtBusinessServiceWithCategoryMapperImpl   extends BaseMybatisDao<Jt
 		@Override
 		public Pagination<JtBusinessCategory> getCategoryListByCondition(JtBusinessCategory jtBusinessCategory,Integer pageNo,Integer pageSize) {
 			
-			Map<String, Object>params=disposeCategoryParams(jtBusinessCategory.getName(), jtBusinessCategory.getLayer());
+			Map<String, Object>params=disposeCategoryParams(jtBusinessCategory.getName(), jtBusinessCategory.getLayer(),jtBusinessCategory.getModule());
 			if(pageNo==null ||pageNo<1)pageNo=1;
 			if(pageSize==null ||pageSize<1)pageSize=10;
 			// TODO Auto-generated method stub
 			return (Pagination<JtBusinessCategory>)findPage("getCategoryListByCondition", "getCategoryCountByCondition", params, pageNo, pageSize);
 		}
 		
-		private Map<String, Object> disposeCategoryParams(String name,Integer layer ) {
+		private Map<String, Object> disposeCategoryParams(String name,Integer layer ,Integer module) {
 			Map<String, Object> params = new HashMap<>();
 
 			if (layer!=null) {
 				params.put("layer", layer);
 			}
 
-		
+			if (module!=null) {
+				params.put("module", module);
+			}
 
 		
 			if (StringUtils.isNotBlank(name)) {

+ 1 - 1
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -673,7 +673,7 @@ public class PublicController extends BaseController {
 		}*/
 		User user = userService.selectByMobieAndType(mobile, type);
 		if (null == user) {
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户"));
+			res.getError().add(buildError( "用户未注册", "用户未注册"));
 			return res;
 		}
 		if (null!=user.getMobile()&&!user.getMobile().equals(mobile)) {

+ 2 - 0
src/main/java/com/goafanti/common/dao/JtBusinessCategoryMapper.java

@@ -96,5 +96,7 @@ public interface JtBusinessCategoryMapper {
     Integer updateNumberPrefix(JtBusinessCategory jtBusinessCategory);
     
     List<JtBusinessCategory> getCategoryByModule(Integer module);
+
+	JtBusinessCategory selectFirstLevel(String id, Integer module, Integer layer,@Param("type")Integer type);
     
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/JtBusinessProjectMapper.java

@@ -86,6 +86,8 @@ public interface JtBusinessProjectMapper {
   
 	List<JtBusinessProject> getKJListByIds(@Param("module")Integer module, @Param("isHot")Integer isHost, @Param("size")Integer size);
 	List<JtBusinessProject> getModuleByName(@Param("name")String name, @Param("isHot")Integer isHost, @Param("size")Integer size);
+
+	JtBusinessProject selectFirstLevel(String id);
      
   
 }

+ 15 - 0
src/main/java/com/goafanti/common/mapper/JtBusinessCategoryMapper.xml

@@ -519,4 +519,19 @@ and layer=#{0}
     select id, name, summary, number, create_time, super_id, img_url, layer, sort, module
     from jt_business_category where module = #{module,jdbcType=INTEGER} order by layer,sort
     </select>
+    
+    <select id="selectFirstLevel" resultMap="BaseResultMap">
+  select
+   <include refid="Base_Column_List" /> 
+   from jt_business_category
+	where module=#{1} and layer=#{2}
+	and   sort &lt; (select sort from jt_business_category where id=#{0})
+	order by sort
+	
+	<if test="type ==0">
+	desc 
+	</if> 
+	limit 1
+  </select>
+  
 </mapper>

+ 1 - 0
src/main/java/com/goafanti/common/mapper/JtBusinessProjectMapper.xml

@@ -873,4 +873,5 @@
 	order by b.release_date desc 
 	limit #{size}
   </select>
+  
 </mapper>