Browse Source

推荐区域轮播图数据

dev
liwenxuan 2 years ago
parent
commit
775faf855c
  1. 9
      src/main/java/com/hxgk/zxxy/controller/GraphicformController.java
  2. 6
      src/main/java/com/hxgk/zxxy/mapper/GraphicformMapper.java
  3. 2
      src/main/java/com/hxgk/zxxy/service/GraphicformService.java
  4. 24
      src/main/java/com/hxgk/zxxy/service/impl/GraphicformServiceImpl.java
  5. 2
      src/main/java/com/hxgk/zxxy/service/impl/HrServiceImpl.java
  6. 2
      src/main/resources/application.properties
  7. 34
      src/main/resources/mapper/GraphicformMapper.xml

9
src/main/java/com/hxgk/zxxy/controller/GraphicformController.java

@ -22,9 +22,16 @@ import java.util.List;
public class GraphicformController {
@Autowired
private GraphicformService graphicformService;
@PostMapping("zxxy")
@PostMapping("cardlist")
public JsonData getZxxyArchivesType(@RequestBody GraphicformRequest graphicformRequest) throws Exception {
PageInfo<Graphicform> graphicformList = graphicformService.queryListByParam(graphicformRequest);
return JsonData.buildSuccess(graphicformList);
}
@PostMapping("carousel")
public JsonData getCarousel(@RequestBody GraphicformRequest graphicformRequest) throws Exception {
PageInfo<Graphicform> graphicformList = graphicformService.getCarousel(graphicformRequest);
return JsonData.buildSuccess(graphicformList);
}
}

6
src/main/java/com/hxgk/zxxy/mapper/GraphicformMapper.java

@ -5,7 +5,7 @@ import com.hxgk.zxxy.model.entity.Graphicform;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@DS("readdocument")
public interface GraphicformMapper {
/*
SELECT
@ -36,6 +36,8 @@ public interface GraphicformMapper {
g_recommend ASC
*/
@DS("readdocument")
List<Graphicform> queryListByParam(@Param("g_parent") String gParent,@Param("g_parent_sun") String gParentSun, @Param("gBfIdList") List<Long> gBfIdList, @Param("gWsIdList") List<Long> gWsIdList, @Param("key") Long key);
List<Graphicform> queryCarousel(@Param("g_parent") String gParent,@Param("g_parent_sun") String gParentSun, @Param("gBfIdList") List<Long> gBfIdList, @Param("gWsIdList") List<Long> gWsIdList, @Param("key") Long key);
}

2
src/main/java/com/hxgk/zxxy/service/GraphicformService.java

@ -8,4 +8,6 @@ import com.hxgk.zxxy.model.request.GraphicformRequest;
public interface GraphicformService {
PageInfo<Graphicform> queryListByParam(GraphicformRequest graphicformRequest) throws Exception;
PageInfo<Graphicform> getCarousel(GraphicformRequest graphicformRequest);
}

24
src/main/java/com/hxgk/zxxy/service/impl/GraphicformServiceImpl.java

@ -44,4 +44,28 @@ public class GraphicformServiceImpl implements GraphicformService {
PageInfo<Graphicform> pageInfo = new PageInfo<Graphicform>(graphicforms);
return pageInfo;
}
@Override
public PageInfo<Graphicform> getCarousel(GraphicformRequest graphicformRequest) {
Map<String, String> userInfo = new HashMap<>();
userInfo.put("userkey",graphicformRequest.getUserkey());
userInfo.put("usertoken",graphicformRequest.getUsertoken());
UserDetail userDetail = userService.getUserDetailFromRedis(userInfo);
//去Hr中查询分厂(部门)和工段,工段可能是list(如果该用户层级较高,则拥有多个工段的权限.)当该用户层级低时,需向上查询他的上级机构码
List<Long> gBfIdList = hrService.queryGBfId( userDetail.getAdminorg());
//工段(list)
List<Long> gWsIdList = null;
try {
gWsIdList = hrService.queryGWsId( userDetail.getAdminorg());
} catch (Exception e) {
e.printStackTrace();
}
//开启分页
PageHelper.startPage(graphicformRequest.getPage(), 4);
List<Graphicform> graphicforms = graphicformMapper
.queryCarousel(graphicformRequest.getArchivesTypeAtParentId(),graphicformRequest.getgParentSun(), gBfIdList, gWsIdList, Long.parseLong(graphicformRequest.getKey()));
PageInfo<Graphicform> pageInfo = new PageInfo<Graphicform>(graphicforms);
return pageInfo;
}
}

2
src/main/java/com/hxgk/zxxy/service/impl/HrServiceImpl.java

@ -60,7 +60,7 @@ public class HrServiceImpl implements HrService {
//备煤,机焦表里是车间,level5,但是要当成部门,level4,我查时,向上向下查询时,如果adminorg in[282,115],则说明他是机焦或者备煤,他level看作4
//如果当前org的superior(父级)为115或282(备煤或机焦),则当前org即可能是level6,也可能是level5,如果是level6,则加入list,如果是level5则继续查询
@Override
public List<Long> queryGWsId(Long adminorg) throws Exception {
public List<Long> queryGWsId(Long adminorg) {
//adminorg = 313L;
List<Long> gGWsIdList = new ArrayList<Long>();
OrgContType orgContType = queryOrgContTypeByAdminorg(adminorg);

2
src/main/resources/application.properties

@ -90,7 +90,7 @@ spring.redis.database=5
## Redis服务器连接端口
spring.redis.port=6379
## 连接超时时间(毫秒)
#spring.redis.timeout=10000
spring.redis.timeout=10000
## Redis服务器连接密码(默认为空)
#spring.redis.password=123456
## 连接池中的最大连接数

34
src/main/resources/mapper/GraphicformMapper.xml

@ -36,4 +36,38 @@
g_recommend ASC
</select>
<select id="queryCarousel" resultType="Graphicform">
SELECT * FROM graphicform WHERE 1 = 1
<if test='g_parent_sun != "" and g_parent_sun!=null' >
AND g_parent_sun = #{g_parent_sun}
</if>
and g_parent = #{g_parent}
and g_thumbnail !=''
AND g_state = 2
AND (
( g_visit_strat = 1 )
OR ( g_visit_strat = 2 AND g_bf_id IN
<foreach collection="gBfIdList" item="gBfId" index="index" open="(" close=")" separator=",">
#{gBfId}
</foreach>
)
<if test="gWsIdList.size() >'0'">
OR ( g_visit_strat = 3 AND g_ws_id IN
<foreach collection="gWsIdList" item="gWsId" index="index" open="(" close=")" separator=",">
#{gWsId}
</foreach>
)
</if>
OR (
g_visit_strat = 4 AND FIND_IN_SET( #{key}, g_range )
)
)
ORDER BY
g_add_time DESC,
g_recommend ASC
</select>
</mapper>
Loading…
Cancel
Save