New file |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.service.MenuConfigService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @Api(tags = "配置") |
| | | @RequestMapping("menuConfig") |
| | | public class MenuConfigController { |
| | | @Autowired |
| | | private MenuConfigService service; |
| | | |
| | | @ApiOperation(value = "查询当前的配置") |
| | | @GetMapping("searchMenuConfig") |
| | | public Response searchMenuConfig(){ |
| | | return service.searchMenuConfig(); |
| | | } |
| | | |
| | | @ApiOperation(value = "窗口配置显示/隐藏确认提交") |
| | | @PostMapping("updateMenuConfig") |
| | | public Response updateMenuConfig(@RequestBody Map<Integer, Integer> map){ |
| | | return service.updateMenuConfig(map); |
| | | } |
| | | } |
New file |
| | |
| | | package com.whyc.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 接口数据响应对象 |
| | | */ |
| | | @ApiModel |
| | | public class Response<T> implements Serializable { |
| | | |
| | | private Integer code; |
| | | @ApiModelProperty |
| | | private T data; |
| | | private T data2; |
| | | private T data3; |
| | | private T data4; |
| | | private String msg; |
| | | |
| | | public Response<T> setCode(Integer code) { |
| | | this.code = code; |
| | | return this; |
| | | } |
| | | |
| | | public Response<T> setData(T data) { |
| | | this.data = data; |
| | | return this; |
| | | } |
| | | |
| | | public Response<T> set(Integer code,T data) { |
| | | this.code = code; |
| | | this.data = data; |
| | | return this; |
| | | } |
| | | |
| | | public Response<T> set(Integer code,T data,String msg) { |
| | | this.code = code; |
| | | this.data = data; |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public Response<T> set(Integer code) { |
| | | this.code = code; |
| | | return this; |
| | | } |
| | | |
| | | public Response<T> setII(Integer code,String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | return this; |
| | | } |
| | | |
| | | public Response<T> setII(Integer code,T data,T data2,String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | this.data = data; |
| | | this.data2 = data2; |
| | | return this; |
| | | } |
| | | public Response<T> setIII(Integer code,T data,T data2,T data3,String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | this.data = data; |
| | | this.data2 = data2; |
| | | this.data3 = data3; |
| | | return this; |
| | | } |
| | | public Response<T> setIIII(Integer code,T data,T data2,T data3,T data4,String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | this.data = data; |
| | | this.data2 = data2; |
| | | this.data3 = data3; |
| | | this.data4 = data4; |
| | | return this; |
| | | } |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public T getData() { |
| | | return data; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public T getData2() { |
| | | return data2; |
| | | } |
| | | |
| | | public void setData2(T data2) { |
| | | this.data2 = data2; |
| | | } |
| | | |
| | | public T getData3() { |
| | | return data3; |
| | | } |
| | | |
| | | public void setData3(T data3) { |
| | | this.data3 = data3; |
| | | } |
| | | |
| | | public T getData4() { |
| | | return data4; |
| | | } |
| | | |
| | | public void setData4(T data4) { |
| | | this.data4 = data4; |
| | | } |
| | | } |
| | |
| | | //获取根元素 |
| | | Element rootElement = document.getRootElement(); |
| | | //获取根元素下的所有子元素 |
| | | List<Element> es = rootElement.elements(); |
| | | for (Element e:es) { |
| | | List<Element> list = rootElement.elements(); |
| | | if(list!=null&&map!=null){ |
| | | for (Element e:list) { |
| | | for (Map.Entry<String, String> entry:map.entrySet()) { |
| | | String mapKey = entry.getKey(); |
| | | String mapValue = entry.getValue(); |
| | |
| | | //format.setEncoding("UTF-8");//默认的编码就是UTF-8 |
| | | XMLWriter writer = new XMLWriter( new FileOutputStream(xmlFilePath), format ); |
| | | writer.write( document ); |
| | | }else{ |
| | | res=false; |
| | | } |
| | | } catch (DocumentException | FileNotFoundException | UnsupportedEncodingException e) { |
| | | res = false; |
| | | e.printStackTrace(); |
New file |
| | |
| | | package com.whyc.mapper; |
| | | |
| | | import com.whyc.pojo.MenuConfig; |
| | | |
| | | public interface MenuConfigMapper extends CustomMapper<MenuConfig>{ |
| | | } |
New file |
| | |
| | | package com.whyc.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author lxw |
| | | * @since 2022-09-07 |
| | | */ |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | @TableName("tb_menu_config") |
| | | @ApiModel(value="MenuConfig对象", description="") |
| | | public class MenuConfig implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "num", type = IdType.AUTO) |
| | | private Long num; |
| | | |
| | | @ApiModelProperty(value = "系数英文") |
| | | private String configName; |
| | | |
| | | @ApiModelProperty(value = "系数名称") |
| | | private String configInfo; |
| | | |
| | | @ApiModelProperty(value = "单位") |
| | | private String configUnit; |
| | | |
| | | @ApiModelProperty(value = "显示/隐藏") |
| | | private Integer configFlag; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.MenuConfigMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class MenuConfigService { |
| | | @Autowired(required = false) |
| | | private MenuConfigMapper mapper; |
| | | |
| | | //查询当前的配置 |
| | | public Response searchMenuConfig() { |
| | | List list=mapper.selectList(null); |
| | | return new Response().setII(1,list.size()>0,list,"当前配置返回"); |
| | | } |
| | | //窗口配置显示/隐藏确认提交 |
| | | @Transactional |
| | | public Response updateMenuConfig(Map<Integer, Integer> map) { |
| | | int flag=0; |
| | | if(map!=null){ |
| | | for (Map.Entry<Integer, Integer> entry:map.entrySet()) { |
| | | int id = entry.getKey(); |
| | | int configFlag = entry.getValue(); |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.set("configFlag",configFlag); |
| | | flag+=mapper.update(null,wrapper); |
| | | } |
| | | }else{ |
| | | flag=0; |
| | | } |
| | | return new Response().set(1,flag>0,"修改窗口配置"); |
| | | } |
| | | } |