Commit 58bc7217 authored by cuijun's avatar cuijun

成果数据接口

parent e8959f7e
......@@ -135,6 +135,10 @@ public abstract class BaseBiz<M extends Mapper<T>, T> {
return mapper.selectAll();
}
public List<T> selectAll(T entity) {
return mapper.select(entity);
}
public Long selectCount(T entity) {
return new Long(mapper.selectCount(entity));
......
......@@ -118,6 +118,29 @@ public class BaseController<Biz extends BaseBiz,Entity> extends CommonBaseContro
return ObjectRestResponse.succ();
}
@RequestMapping(value = "baseDetail",method = RequestMethod.GET)
@ResponseBody
public ObjectRestResponse<Entity> baseDetail(Entity entity){
Object o = baseBiz.selectOne(entity);
return ObjectRestResponse.succ(o);
}
@RequestMapping(value = "baseAdd",method = RequestMethod.POST)
@ResponseBody
public ObjectRestResponse<Entity> baseAdd(@RequestBody Entity entity){
baseBiz.insertSelective(entity);
return new ObjectRestResponse<Entity>();
}
@RequestMapping(value = "baseUpdate",method = RequestMethod.POST)
@ResponseBody
public ObjectRestResponse<Entity> baseUpdate(@RequestBody Entity entity){
baseBiz.updateSelectiveById(entity);
return new ObjectRestResponse<Entity>();
}
@Data
public static class BaseDetailDTO {
Integer id;
......
package com.upyuns.platform.rs.website.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 菜单
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-05-15 18:31:37
*/
@Data
@Table(name = "data_menu")
public class DataMenu implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty("")
private Integer id;
/**
* 标题
*/
@Column(name = "title")
@ApiModelProperty(value = "标题")
private String title;
/**
* 父级节点
*/
@Column(name = "parent_id")
@ApiModelProperty(value = "父级节点")
private Integer parentId;
/**
* 排序
*/
@Column(name = "order_num")
@ApiModelProperty(value = "排序")
private Integer orderNum;
/**
* 描述
*/
@Column(name = "description")
@ApiModelProperty(value = "描述")
private String description;
/**
* 菜单上下级关系
*/
@Column(name = "path")
@ApiModelProperty(value = "菜单上下级关系")
private String path;
/**
*
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "", hidden = true )
private Date crtTime;
/**
*
*/
@Column(name = "crt_user")
@ApiModelProperty(value = "")
private String crtUser;
/**
*
*/
@Column(name = "crt_name")
@ApiModelProperty(value = "")
private String crtName;
/**
*
*/
@Column(name = "crt_host")
@ApiModelProperty(value = "")
private String crtHost;
/**
*
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "", hidden = true )
private Date updTime;
/**
*
*/
@Column(name = "upd_user")
@ApiModelProperty(value = "")
private String updUser;
/**
*
*/
@Column(name = "upd_name")
@ApiModelProperty(value = "")
private String updName;
/**
*
*/
@Column(name = "upd_host")
@ApiModelProperty(value = "")
private String updHost;
}
package com.upyuns.platform.rs.website.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 成果数据
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-05-15 18:31:38
*/
@Data
@Table(name = "gain_data")
public class GainData implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty("id")
private Integer id;
/**
* 名称
*/
@Column(name = "name")
@ApiModelProperty(value = "名称")
private String name;
/**
* 时间
*/
@Column(name = "time")
@ApiModelProperty(value = "时间")
private String time;
/**
* 排序
*/
@Column(name = "rank")
@ApiModelProperty(value = "排序")
private Integer rank;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Date crtTime;
/**
* 修改时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "修改时间", hidden = true )
private Date updTime;
/**
* 图片地址
*/
@Column(name = "picture_url")
@ApiModelProperty(value = "图片地址")
private String pictureUrl;
/**
* 是否删除,0否,1是
*/
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除,0否,1是")
private Integer isDel;
/**
* 状态1--上架;2--下架
*/
@Column(name = "status")
@ApiModelProperty(value = "状态1--上架;2--下架")
private Integer status;
/**
* 菜单id
*/
@Column(name = "menu_id")
@ApiModelProperty(value = "菜单id")
private Integer menuId;
}
package com.upyuns.platform.rs.website.vo;
import cn.hutool.core.collection.CollUtil;
import com.github.wxiaoqi.security.common.vo.TreeNode;
import com.upyuns.platform.rs.website.entity.GainData;
import lombok.Data;
import java.util.List;
/**
* Created by Ace on 2017/6/12.
*/
@Data
public class DataMenuTree extends TreeNode {
String icon;
String title;
boolean spread = false;
String component;
String path;
String code;
String type;
List<GainData> elements = CollUtil.newArrayList();
String label;
public DataMenuTree() {
}
public DataMenuTree(int id, String name, int parentId) {
this.id = id;
this.parentId = parentId;
this.title = name;
this.label = name;
}
public DataMenuTree(int id, String name, DataMenuTree parent) {
this.id = id;
this.parentId = parent.getId();
this.title = name;
this.label = name;
}
}
package com.upyuns.platform.rs.website.biz;
import com.github.wxiaoqi.security.common.util.TreeUtil;
import com.upyuns.platform.rs.website.entity.GainData;
import com.upyuns.platform.rs.website.vo.DataMenuTree;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.upyuns.platform.rs.website.entity.DataMenu;
import com.upyuns.platform.rs.website.mapper.DataMenuMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.util.ArrayList;
import java.util.List;
/**
* 菜单
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-05-15 18:31:37
*/
@Service
public class DataMenuBiz extends BaseBiz<DataMenuMapper,DataMenu> {
@Autowired
GainDataBiz gainDataBiz;
public List<DataMenuTree> getImageMenuTree(List<DataMenu> menus, int root) {
List<DataMenuTree> trees = new ArrayList<DataMenuTree>();
DataMenuTree node = null;
for (DataMenu imageMenu : menus) {
node = new DataMenuTree();
BeanUtils.copyProperties(imageMenu, node);
node.setLabel(imageMenu.getTitle());
node.setElements(gainDataBiz.selectAll(new GainData(){{
setMenuId(imageMenu.getId());
}}));
if (node.getChildren() == null) {
node.setChildren(new ArrayList<>());
}
trees.add(node);
}
return TreeUtil.bulid(trees,root);
}
}
package com.upyuns.platform.rs.website.biz;
import org.springframework.stereotype.Service;
import com.upyuns.platform.rs.website.entity.GainData;
import com.upyuns.platform.rs.website.mapper.GainDataMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
/**
* 成果数据
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-05-15 18:31:38
*/
@Service
public class GainDataBiz extends BaseBiz<GainDataMapper,GainData> {
}
\ No newline at end of file
package com.upyuns.platform.rs.website.controller.web;
import com.github.wxiaoqi.security.admin.constant.AdminCommonConstant;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.upyuns.platform.rs.website.biz.DataMenuBiz;
import com.upyuns.platform.rs.website.entity.DataMenu;
import com.upyuns.platform.rs.website.vo.DataMenuTree;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("dataMenu/web")
public class DataMenuController extends BaseController<DataMenuBiz,DataMenu> {
@RequestMapping(value = "/app/unauth/imageMenuTree", method = RequestMethod.GET)
@IgnoreUserToken
@IgnoreClientToken
@ResponseBody
public ObjectRestResponse<List<DataMenuTree>> listMenu(Integer parentId) {
try {
if (parentId == null) {
parentId = AdminCommonConstant.ROOT;
}
} catch (Exception e) {
return ObjectRestResponse.succ(new ArrayList<DataMenuTree>());
}
List<DataMenuTree> trees = new ArrayList<DataMenuTree>();
DataMenuTree node = null;
Example example = new Example(DataMenu.class);
DataMenu parent = baseBiz.selectById(parentId);
if(null != parent) {
example.createCriteria().andLike("path", parent.getPath() + "%").andNotEqualTo("id",parent.getId());
}else {
example.createCriteria().andNotEqualTo("id",parentId);
}
return ObjectRestResponse.succ(baseBiz.getImageMenuTree(baseBiz.selectByExample(example), parentId));
}
}
\ No newline at end of file
package com.upyuns.platform.rs.website.controller.web;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.upyuns.platform.rs.website.biz.GainDataBiz;
import com.upyuns.platform.rs.website.entity.GainData;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("gainData")
public class GainDataController extends BaseController<GainDataBiz,GainData> {
}
\ No newline at end of file
package com.upyuns.platform.rs.website.mapper;
import com.upyuns.platform.rs.website.entity.DataMenu;
import tk.mybatis.mapper.common.Mapper;
/**
* 菜单
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-05-15 18:31:37
*/
public interface DataMenuMapper extends Mapper<DataMenu> {
}
package com.upyuns.platform.rs.website.mapper;
import com.upyuns.platform.rs.website.entity.GainData;
import tk.mybatis.mapper.common.Mapper;
/**
* 成果数据
*
* @author zjw
* @email jiaoruizhen@126.com
* @date 2024-05-15 18:31:38
*/
public interface GainDataMapper extends Mapper<GainData> {
}
<?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="com.upyuns.platform.rs.website.mapper.DataMenuMapper">
</mapper>
\ 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="com.upyuns.platform.rs.website.mapper.GainDataMapper">
</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