Browse Source

重构关注

master
陈裕财 4 years ago
parent
commit
63290e0850
  1. 27
      xm-core/src/main/java/com/xm/core/ctrl/XmMyFocusController.java
  2. 8
      xm-core/src/main/java/com/xm/core/service/XmMyFocusService.java
  3. 16
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMyFocusMapper.xml

27
xm-core/src/main/java/com/xm/core/ctrl/XmMyFocusController.java

@ -4,6 +4,7 @@ import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException; import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils; import com.mdp.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils; import com.mdp.mybatis.PageUtils;
import com.mdp.qx.HasRole;
import com.mdp.safe.client.entity.User; import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils; import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams; import com.mdp.swagger.ApiEntityParams;
@ -71,8 +72,30 @@ public class XmMyFocusController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
@ApiOperation( value = "查询我关注的项目或者任务信息列表",notes=" ")
@ApiEntityParams( XmMyFocus.class )
@ApiImplicitParams({
@ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false),
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false),
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false),
@ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false),
@ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false),
})
@ApiResponses({
@ApiResponse(code = 200,response=XmMyFocus.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}")
})
@HasRole
@RequestMapping(value="/myFocusForIndex",method=RequestMethod.GET)
public Map<String,Object> myFocusForIndex( ){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("查询成功");
List<Map<String,Object>> xmMyFocusList = xmMyFocusService.myFocusForIndex(LoginUtils.getCurrentUserInfo().getUserid());
m.put("data",xmMyFocusList);
m.put("tips", tips);
return m;
}
@ApiOperation( value = "新增一条我关注的项目或者任务信息",notes=" ") @ApiOperation( value = "新增一条我关注的项目或者任务信息",notes=" ")
@ApiResponses({ @ApiResponses({

8
xm-core/src/main/java/com/xm/core/service/XmMyFocusService.java

@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map;
/** /**
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> * 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
@ -73,7 +75,11 @@ public class XmMyFocusService extends BaseService {
} }
} }
public List<Map<String, Object>> myFocusForIndex(String userid) {
return super.selectList("myFocusForIndex",userid);
}
/** 请在此类添加自定义函数 */ /** 请在此类添加自定义函数 */
} }

16
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmMyFocusMapper.xml

@ -14,7 +14,21 @@
<if test="key != null and key !='' "> </if> <if test="key != null and key !='' "> </if>
</sql> </sql>
<select id="myFocusForIndex" parameterType="String" resultType="HashMap">
select t.*
from
(select t1.*,
(select count(*)+1
from xm_my_focus a
where a.userid=#{userid} and a.focus_type=t1.focus_type
and a.ftime>t1.ftime
) as group_id
from xm_my_focus t1
where t1.userid=#{userid}
) t
where group_id &lt;=5
order by ftime desc, group_id asc
</select>
<!--结束 自定义sql函数区域--> <!--结束 自定义sql函数区域-->

Loading…
Cancel
Save