| | |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "sys_ver"), |
| | | @ApiImplicitParam(name = "depName", value = "目录", dataType = "String", paramType = "query", example = ""), |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(String name, String depName) { |
| | | try { |
| | | int count = versionService.selectCount(name, depName); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "sys_ver"), |
| | | @ApiImplicitParam(name = "depName", value = "目录", dataType = "String", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<VerEntity>> selectByPage(String name, String depName, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | List<VerEntity> rs = versionService.selectByPage(name, depName, pageSize, pageSize * (pageIndex - 1)); |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "depName", value = "目录", dataType = "String", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "dirid", value = "目录ID", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageAndCount") |
| | | public ResponseMsg<List<VerEntity>> selectByPageAndCount(String name, String depName, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<VerEntity>> selectByPageAndCount(Integer dirid, String name, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = versionService.selectCount(name, depName); |
| | | int count = versionService.selectCount(dirid, name); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<VerEntity> rs = versionService.selectByPage(name, depName, pageSize, pageSize * (pageIndex - 1)); |
| | | List<VerEntity> rs = versionService.selectByPage(dirid, name, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | |
| | | private String descr; |
| | | |
| | | private String depName; |
| | | |
| | | private int createUser; |
| | | |
| | | private Timestamp createTime; |
| | |
| | | private int updateUser; |
| | | |
| | | private Timestamp updateTime; |
| | | |
| | | private String depName; |
| | | |
| | | private String createName; |
| | | |
| | | public int getId() { |
| | | return id; |
| | |
| | | this.descr = descr; |
| | | } |
| | | |
| | | public String getDepName() { |
| | | return depName; |
| | | } |
| | | |
| | | public void setDepName(String depName) { |
| | | this.depName = depName; |
| | | } |
| | | |
| | | public int getCreateUser() { |
| | | return createUser; |
| | | } |
| | |
| | | public void setUpdateTime(Timestamp updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getDepName() { |
| | | return depName; |
| | | } |
| | | |
| | | public void setDepName(String depName) { |
| | | this.depName = depName; |
| | | } |
| | | |
| | | public String getCreateName() { |
| | | return createName; |
| | | } |
| | | |
| | | public void setCreateName(String createName) { |
| | | this.createName = createName; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param name 名称 |
| | | * @param depName 名称 |
| | | * @param dirid 目录ID |
| | | * @param name 名称 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String name,String depName); |
| | | public Integer selectCount(Integer dirid, String name); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 名称 |
| | | * @param depName 名称 |
| | | * @param dirid 目录ID |
| | | * @param name 名称 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<VerEntity> selectByPage(String name, String depName, Integer limit, Integer offset); |
| | | public List<VerEntity> selectByPage(Integer dirid, String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 根据目录ID查询版本列表 |
| | |
| | | package com.lf.server.service.data; |
| | | |
| | | import com.lf.server.entity.data.VerEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.data.VerMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | VerMapper verMapper; |
| | | |
| | | @Override |
| | | public Integer selectCount(String name,String depName) { |
| | | return verMapper.selectCount(name,depName); |
| | | public Integer selectCount(Integer dirid, String name) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return verMapper.selectCount(dirid, name); |
| | | } |
| | | |
| | | @Override |
| | | public List<VerEntity> selectByPage(String name, String depName, Integer limit, Integer offset) { |
| | | return verMapper.selectByPage(name,depName, limit, offset); |
| | | public List<VerEntity> selectByPage(Integer dirid, String name, Integer limit, Integer offset) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return verMapper.selectByPage(dirid, name, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | |
| | | <mapper namespace="com.lf.server.mapper.data.VerMapper"> |
| | | <!-- 统计行数 --> |
| | | <select id="selectCount" resultType="java.lang.Integer"> |
| | | select count(*) from lf.sys_ver a inner join lf.sys_dir b |
| | | on a.dirid = b.id |
| | | select count(*) from lf.sys_ver a |
| | | <where> |
| | | 1=1 |
| | | <if test="name != null"> |
| | | and a.name = #{name} |
| | | 1 = 1 |
| | | <if test="dirid != null"> |
| | | and a.dirid = ANY(fn_rec_array(#{dirid}, 'dir')) |
| | | </if> |
| | | |
| | | <if test="depName != null"> |
| | | and b.name = #{depName} |
| | | <if test="name != null"> |
| | | and a.name like #{name} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <!-- 分页查询 --> |
| | | <select id="selectByPage" resultType="com.lf.server.entity.data.VerEntity"> |
| | | select a.*,b.name as dep_name |
| | | from lf.sys_ver a inner join lf.sys_dir b |
| | | on a.dirid = b.id |
| | | select a.*, fn_rec_query(a.dirid, 'dir') depName, fn_uname(create_user) createName from lf.sys_ver a |
| | | <where> |
| | | 1=1 |
| | | <if test="name != null"> |
| | | and a.name = #{name} |
| | | <if test="dirid != null"> |
| | | and a.dirid = ANY(fn_rec_array(#{dirid}, 'dir')) |
| | | </if> |
| | | |
| | | <if test="depName != null"> |
| | | and b.name = #{depName} |
| | | <if test="name != null"> |
| | | and a.name like #{name} |
| | | </if> |
| | | </where> |
| | | order by id |