Commit 26abc8dc by 吴迪

【新增】培训计划管理模块接口新增

parent 99cc08b0
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* <p>
* https://www.renren.io
*
* <p>
* 版权所有,侵权必究!
*/
......@@ -32,11 +32,11 @@ public class Query<T> {
long curPage = 1;
long limit = 10;
if(params.get(Constant.PAGE) != null){
curPage = Long.parseLong((String)params.get(Constant.PAGE));
if (params.get(Constant.PAGE) != null) {
curPage = Long.parseLong((String) params.get(Constant.PAGE));
}
if(params.get(Constant.LIMIT) != null){
limit = Long.parseLong((String)params.get(Constant.LIMIT));
if (params.get(Constant.LIMIT) != null) {
limit = Long.parseLong((String) params.get(Constant.LIMIT));
}
//分页对象
......@@ -47,28 +47,28 @@ public class Query<T> {
//排序字段
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD));
String order = (String)params.get(Constant.ORDER);
String orderField = SQLFilter.sqlInject((String) params.get(Constant.ORDER_FIELD));
String order = (String) params.get(Constant.ORDER);
//前端字段排序
if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){
if(Constant.ASC.equalsIgnoreCase(order)) {
return page.addOrder(OrderItem.asc(orderField));
}else {
if (StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)) {
if (Constant.ASC.equalsIgnoreCase(order)) {
return page.addOrder(OrderItem.asc(orderField));
} else {
return page.addOrder(OrderItem.desc(orderField));
}
}
//没有排序字段,则不排序
if(StringUtils.isBlank(defaultOrderField)){
if (StringUtils.isBlank(defaultOrderField)) {
return page;
}
//默认排序
if(isAsc) {
if (isAsc) {
page.addOrder(OrderItem.asc(defaultOrderField));
}else {
} else {
page.addOrder(OrderItem.desc(defaultOrderField));
}
......
......@@ -11,12 +11,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CorsConfig implements WebMvcConfigurer {
/* @Override
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.maxAge(3600);
}*/
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ public class NewsMovieController extends AbstractController {
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:newsmovie:list")
public R list(@RequestParam Map<String, Object> params){
public R list(@RequestBody Map<String, Object> params){
PageUtils page = newsMovieService.queryPage(params);
return R.ok().put("page", page);
......
package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.office.modules.manage.entity.PlanBranchEntity;
import io.office.modules.manage.service.PlanBranchService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-10-25 16:00:07
*/
@RestController
@RequestMapping("/planbranch")
public class PlanBranchController {
@Autowired
private PlanBranchService planBranchService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:planbranch:list")
public R list(@RequestBody Map<String, Object> params){
PageUtils page = planBranchService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("manage:planbranch:info")
public R info(@PathVariable("id") Integer id){
PlanBranchEntity planBranch = planBranchService.getById(id);
return R.ok().put("planBranch", planBranch);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("manage:planbranch:save")
public R save(@RequestBody PlanBranchEntity planBranch){
planBranchService.save(planBranch);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("manage:planbranch:update")
public R update(@RequestBody PlanBranchEntity planBranch){
planBranchService.updateById(planBranch);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:planbranch:delete")
public R delete(@RequestBody Integer[] ids){
planBranchService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.PlanBranchEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-10-25 16:00:07
*/
@Mapper
public interface PlanBranchDao extends BaseMapper<PlanBranchEntity> {
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-10-25 16:00:07
*/
@Data
@TableName("Plan_branch")
public class PlanBranchEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
@TableId
private Integer id;
/**
* $column.comments
*/
private Integer idNum;
/**
* $column.comments
*/
private String name;
/**
* $column.comments
*/
private String ppath;
/**
* $column.comments
*/
private Integer classnum;
/**
* $column.comments
*/
private String lasteditor;
/**
* $column.comments
*/
private Date updatetime;
/**
* $column.comments
*/
private Integer state;
/**
* $column.comments
*/
private String auditor;
/**
* $column.comments
*/
private Integer checkflag;
}
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.modules.manage.entity.PlanBranchEntity;
import java.util.Map;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-10-25 16:00:07
*/
public interface PlanBranchService extends IService<PlanBranchEntity> {
PageUtils queryPage(Map<String, Object> params);
}
package io.office.modules.manage.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.PlanBranchDao;
import io.office.modules.manage.entity.PlanBranchEntity;
import io.office.modules.manage.service.PlanBranchService;
@Service("planBranchService")
public class PlanBranchServiceImpl extends ServiceImpl<PlanBranchDao, PlanBranchEntity> implements PlanBranchService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
QueryWrapper<PlanBranchEntity> planBranchEntityQueryWrapper = new QueryWrapper<>();
planBranchEntityQueryWrapper.eq(params.containsKey("classnum"),"classnum",params.get("classnum"));
planBranchEntityQueryWrapper.orderByAsc("id");
IPage<PlanBranchEntity> page = this.page(
new Query<PlanBranchEntity>().getPage(params),
planBranchEntityQueryWrapper
);
return new PageUtils(page);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.office.modules.manage.dao.PlanBranchDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.PlanBranchEntity" id="planBranchMap">
<result property="id" column="id"/>
<result property="idNum" column="id_num"/>
<result property="name" column="name"/>
<result property="ppath" column="Ppath"/>
<result property="classnum" column="classnum"/>
<result property="lasteditor" column="lasteditor"/>
<result property="updatetime" column="updatetime"/>
<result property="state" column="state"/>
<result property="auditor" column="auditor"/>
<result property="checkflag" column="checkflag"/>
</resultMap>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment