指标库:根据分类显示指标列表
This commit is contained in:
parent
2784b050f3
commit
af17053ee5
6
pom.xml
6
pom.xml
@ -63,13 +63,17 @@
|
|||||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
<version>3.5.12</version>
|
<version>3.5.12</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||||
|
<version>3.5.12</version>
|
||||||
|
</dependency>
|
||||||
<!-- fastjson -->
|
<!-- fastjson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.29</version>
|
<version>1.2.29</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
40
src/main/java/iet/ustb/sf/controller/TargetController.java
Normal file
40
src/main/java/iet/ustb/sf/controller/TargetController.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package iet.ustb.sf.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import iet.ustb.sf.common.R;
|
||||||
|
import iet.ustb.sf.domain.Target;
|
||||||
|
import iet.ustb.sf.service.TargetService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标管控-指标
|
||||||
|
* TargetController
|
||||||
|
*
|
||||||
|
* @author huangge1199
|
||||||
|
* @since 2025/8/5 16:24:06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/mbgk/target")
|
||||||
|
@Tag(name = "目标管控-指标")
|
||||||
|
public class TargetController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TargetService targetService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分类显示指标列表
|
||||||
|
*/
|
||||||
|
@Operation(summary = "根据分类显示指标列表")
|
||||||
|
@PostMapping("/getTargetsByCategory")
|
||||||
|
public R<IPage<Target>> getTargetsByCategory(@RequestBody JSONObject params) {
|
||||||
|
IPage<Target> result = targetService.getTargetsByCategory(params);
|
||||||
|
return R.ok(result);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package iet.ustb.sf.service;
|
package iet.ustb.sf.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import iet.ustb.sf.domain.Target;
|
import iet.ustb.sf.domain.Target;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
@ -10,4 +12,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface TargetService extends IService<Target> {
|
public interface TargetService extends IService<Target> {
|
||||||
|
|
||||||
|
IPage<Target> getTargetsByCategory(JSONObject params);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category>
|
|||||||
|
|
||||||
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
|
||||||
if (!StringUtils.isEmpty(category.getOrganization())) {
|
if (!StringUtils.isEmpty(category.getOrganization())) {
|
||||||
queryWrapper.like("organization", category.getOrganization());
|
queryWrapper.like("organization", "%" + category.getOrganization() + "%");
|
||||||
}
|
}
|
||||||
List<Category> categoryList = new ArrayList<>();
|
List<Category> categoryList = new ArrayList<>();
|
||||||
if (StringUtils.isEmpty(category.getTopic())) {
|
if (StringUtils.isEmpty(category.getTopic())) {
|
||||||
|
@ -1,20 +1,73 @@
|
|||||||
package iet.ustb.sf.service.impl;
|
package iet.ustb.sf.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import iet.ustb.sf.domain.Category;
|
||||||
import iet.ustb.sf.domain.Target;
|
import iet.ustb.sf.domain.Target;
|
||||||
|
import iet.ustb.sf.exception.ErrorCode;
|
||||||
|
import iet.ustb.sf.exception.ThrowUtils;
|
||||||
|
import iet.ustb.sf.mapper.CategoryMapper;
|
||||||
import iet.ustb.sf.service.TargetService;
|
import iet.ustb.sf.service.TargetService;
|
||||||
import iet.ustb.sf.mapper.TargetMapper;
|
import iet.ustb.sf.mapper.TargetMapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.val;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hyy
|
* @author hyy
|
||||||
* @description 针对表【mbgk_target】的数据库操作Service实现
|
* @description 针对表【mbgk_target】的数据库操作Service实现
|
||||||
* @createDate 2025-08-05 15:40:19
|
* @createDate 2025-08-05 15:40:19
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TargetServiceImpl extends ServiceImpl<TargetMapper, Target>
|
public class TargetServiceImpl extends ServiceImpl<TargetMapper, Target>
|
||||||
implements TargetService{
|
implements TargetService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TargetMapper targetMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CategoryMapper categoryMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<Target> getTargetsByCategory(JSONObject params) {
|
||||||
|
int pageIndex = Optional.ofNullable(params.getInteger("pageIndex")).orElse(1);
|
||||||
|
int pageSize = Optional.ofNullable(params.getInteger("pageSize")).orElse(10);
|
||||||
|
String topic = params.getString("topic");
|
||||||
|
String organization = params.getString("organization");
|
||||||
|
String categoryId = params.getString("categoryId");
|
||||||
|
String name = params.getString("name");
|
||||||
|
|
||||||
|
boolean bl = StringUtils.isEmpty(organization) && StringUtils.isEmpty(topic);
|
||||||
|
ThrowUtils.throwIf(bl, ErrorCode.PARAMS_ERROR, "主题和组织必须传入一个!");
|
||||||
|
|
||||||
|
Page<Target> pageRequest = new Page<>(pageIndex, pageSize);
|
||||||
|
|
||||||
|
QueryWrapper<Target> query = new QueryWrapper<>();
|
||||||
|
if (!StringUtils.isEmpty(topic)) {
|
||||||
|
query.eq("topic", topic);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(organization)) {
|
||||||
|
query.eq("organization", organization);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(categoryId)) {
|
||||||
|
query.eq("category_id",categoryId);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(name)) {
|
||||||
|
query.like("name","%" + name + "%");
|
||||||
|
}
|
||||||
|
query.orderByDesc("update_time");
|
||||||
|
|
||||||
|
return this.page(pageRequest, query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ server:
|
|||||||
port: 9900
|
port: 9900
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /api
|
context-path: /api
|
||||||
# springdoc-openapi????
|
# springdoc-openapi
|
||||||
springdoc:
|
springdoc:
|
||||||
group-configs:
|
group-configs:
|
||||||
- group: 'default'
|
- group: 'default'
|
||||||
paths-to-match: '/**'
|
paths-to-match: '/**'
|
||||||
packages-to-scan: iet.ustb.sf.controller
|
packages-to-scan: iet.ustb.sf.controller
|
||||||
# knife4j???????????????
|
# knife4j
|
||||||
knife4j:
|
knife4j:
|
||||||
enable: true
|
enable: true
|
||||||
setting:
|
setting:
|
||||||
@ -22,8 +22,6 @@ mybatis-plus:
|
|||||||
global-config:
|
global-config:
|
||||||
enable-sql-runner: true
|
enable-sql-runner: true
|
||||||
configuration:
|
configuration:
|
||||||
# ??????????
|
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
# ????SQL
|
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user