whycxzp
2021-03-17 1fc5c5b72db71c8c36c7d64950e2795cc8a5b3ac
更新
7个文件已修改
5个文件已删除
230 ■■■■ 已修改文件
src/main/java/com/whyc/controller/ApplicationController.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/ApplicationConfigDTO.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ApplicationConfigMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ApplicationConfigPicMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BattDevDataMapper.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/Application.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/ApplicationConfig.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/ApplicationConfigPic.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ApplicationService.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ApplicationConfigMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ApplicationConfigPicMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BattDevDataMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ApplicationController.java
@@ -24,31 +24,29 @@
    @Autowired
    private ApplicationService service;
    /*======应用管理,admin才有权限更改======*/
    /*======应用管理======*/
    @PostMapping
    @ApiOperation(value = "应用-创建")
    public Response create(@RequestBody ApplicationDTO app){
    public Response create(@RequestBody Application app){
        return service.insert(app);
    }
    @GetMapping("all")
    @ApiOperation(value = "应用-查询所有")
    public Response getAll(){
        return service.getAll();
    public Response getAll(@RequestParam Integer userId){
        return service.getAll(userId);
    }
    /**TODO:需要添加操作日志*/
    @PutMapping
    @ApiOperation(value = "应用-更新名称")
    public Response update(@RequestBody ApplicationDTO app){
    public Response update(@RequestBody Application app){
        return service.update(app);
    }
    /**TODO:需要添加操作日志*/
    @DeleteMapping
    @ApiOperation(value = "应用-删除")
    public Response delete(@RequestBody ApplicationDTO app){
        return service.delete(app);
    public Response delete(@RequestParam Integer appId){
        return service.delete(appId);
    }
    /*======应用配置======*/
@@ -61,7 +59,7 @@
    @GetMapping("allConfig")
    @ApiOperation(value = "配置-查询当前应用的配置")
    public Response getAllConfig(@RequestParam int appId,@RequestParam int userId){
        return service.getAllConfig(appId,userId);
    public Response getAllConfig(@RequestParam Integer appId){
        return service.getAllConfig(appId);
    }
}
src/main/java/com/whyc/dto/ApplicationConfigDTO.java
@@ -16,7 +16,6 @@
    private String appName;
    private String headPic;
    private String bgPic;
    private Integer userId;
    /**应用缩略图的base64*/
    private String fileData;
    private List<ApplicationConfig> children;
@@ -61,6 +60,7 @@
        this.appName = appName;
    }
    @Transient
    public String getFileData() {
        return fileData;
    }
@@ -69,11 +69,4 @@
        this.fileData = fileData;
    }
    public Integer getUserId() {
        return userId;
    }
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
}
src/main/java/com/whyc/mapper/ApplicationConfigMapper.java
@@ -9,5 +9,5 @@
public interface ApplicationConfigMapper extends CustomMapper<ApplicationConfig> {
    int saveConfig(@Param("configDTO") ApplicationConfigDTO configDTO);
    ApplicationConfigDTO getAllConfig(int appId,int userId);
    ApplicationConfigDTO getAllConfig(int appId);
}
src/main/java/com/whyc/mapper/ApplicationConfigPicMapper.java
File was deleted
src/main/java/com/whyc/mapper/BattDevDataMapper.java
File was deleted
src/main/java/com/whyc/pojo/Application.java
@@ -14,6 +14,12 @@
    private String name;
    /**应用的缩略图*/
    private String screenshot;
    /**应用的配置页图片-头部*/
    private String headPic;
    /**应用的配置页面图片-背景*/
    private String bgPic;
    /**所属的用户id*/
    private Integer userId;
    public Integer getId() {
        return id;
@@ -39,4 +45,27 @@
        this.screenshot = screenshot;
    }
    public Integer getUserId() {
        return userId;
    }
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    public String getHeadPic() {
        return headPic;
    }
    public void setHeadPic(String headPic) {
        this.headPic = headPic;
    }
    public String getBgPic() {
        return bgPic;
    }
    public void setBgPic(String bgPic) {
        this.bgPic = bgPic;
    }
}
src/main/java/com/whyc/pojo/ApplicationConfig.java
@@ -26,8 +26,6 @@
    private Double y;
    /**模块图表展示类型*/
    private String type;
    /**所属用户*/
    private Integer userId;
    public Integer getId() {
        return id;
@@ -95,14 +93,4 @@
        this.type = type;
    }
    /**传入的时候可以接收,传出的时候无需传递*/
    //@Transient
    public Integer getUserId() {
        return userId;
    }
    @Transient
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
}
src/main/java/com/whyc/pojo/ApplicationConfigPic.java
File was deleted
src/main/java/com/whyc/service/ApplicationService.java
@@ -1,5 +1,6 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -23,33 +24,21 @@
    @Resource
    private ApplicationConfigMapper configMapper;
    @Resource
    private ApplicationConfigPicMapper configPicMapper;
    @Resource
    private UserInfMapper userInfMapper;
    /*======应用管理,admin才有权限更改======*/
    public Response insert(ApplicationDTO app) {
        UserInf userInf = userInfMapper.selectById(app.getUserId());
        if(!userInf.getUName().equals("admin")){
            return new Response<>().setMsg(0,"创建应用需admin权限");
        }
        mapper.insertApp(app.getApplication());
    /*======应用管理======*/
    public Response insert(Application app) {
        mapper.insert(app);
        return new Response<>().set(1,app,"创建成功");
    }
    public Response getAll() {
        List<Application> applications = mapper.selectList(null);
    public Response getAll(Integer userId) {
        QueryWrapper<Application> wrapper = Wrappers.query();
        wrapper.eq("user_id",userId);
        List<Application> applications = mapper.selectList(wrapper);
        return new Response<>().set(1,applications);
    }
    public Response update(ApplicationDTO app) {
        UserInf userInf = userInfMapper.selectById(app.getUserId());
        if(!userInf.getUName().equals("admin")){
            return new Response<>().setMsg(0,"更新应用需admin权限");
        }
        int res = mapper.updateById(app.getApplication());
    public Response update(Application app) {
        int res = mapper.updateById(app);
        if(res==1){
            return new Response<>().setMsg(1,"更新成功");
        }else{
@@ -57,21 +46,13 @@
        }
    }
    public Response delete(ApplicationDTO app) {
        UserInf userInf = userInfMapper.selectById(app.getUserId());
        if(!userInf.getUName().equals("admin")){
            return new Response<>().setMsg(0,"创建应用需admin权限");
        }
    public Response delete(Integer appId) {
        //删除应用
        mapper.deleteById(app.getApplication().getId());
        mapper.deleteById(appId);
        //删除应用的模块配置
        UpdateWrapper<ApplicationConfig> updateWrapper = Wrappers.update();
        updateWrapper.eq("app_id",app.getApplication().getId());
        updateWrapper.eq("app_id",appId);
        configMapper.delete(updateWrapper);
        //删除应用的模块图片
        UpdateWrapper<ApplicationConfigPic> wrapper = Wrappers.update();
        wrapper.eq("app_id",app.getApplication().getId());
        configPicMapper.delete(wrapper);
        return new Response<>().setMsg(1,"删除成功");
    }
@@ -80,18 +61,17 @@
    @Transactional
    public Response saveConfig(ApplicationConfigDTO configDTO) {
        try {
            //保存应用的图片信息,appId+userId为联合主键
            ApplicationConfigPic configPic = new ApplicationConfigPic();
            configPic.setAppId(configDTO.getAppId());
            configPic.setUserId(configDTO.getUserId());
            configPic.setBgPic(configDTO.getBgPic());
            configPic.setHeadPic(configDTO.getHeadPic());
            //保存应用的图片信息
            Application app = new Application();
            app.setId(configDTO.getAppId());
            app.setBgPic(configDTO.getBgPic());
            app.setHeadPic(configDTO.getHeadPic());
            configPicMapper.insertOrUpdate(configPic);
            mapper.updateById(app);
            //首先删除原有配置,再保存配置
            UpdateWrapper<ApplicationConfig> wrapper = Wrappers.update();
            wrapper.eq("app_id",configDTO.getAppId()).eq("user_id",configDTO.getUserId());
            wrapper.eq("app_id",configDTO.getAppId());
            configMapper.delete(wrapper);
            configMapper.saveConfig(configDTO);
        }catch (Exception e){
@@ -101,8 +81,8 @@
    }
    /**查询应用和对应的配置模块*/
    public Response getAllConfig(int appId,int userId) {
        ApplicationConfigDTO applicationConfigDTO = configMapper.getAllConfig(appId,userId);
    public Response getAllConfig(Integer appId) {
        ApplicationConfigDTO applicationConfigDTO = configMapper.getAllConfig(appId);
        return new Response<>().set(1,applicationConfigDTO);
    }
src/main/resources/mapper/ApplicationConfigMapper.xml
@@ -4,7 +4,6 @@
    <resultMap id="Map_ApplicationConfigDTO" type="com.whyc.dto.ApplicationConfigDTO">
        <id column="appId" property="appId" />
        <result column="user_id" property="userId" />
        <result column="appName" property="appName"/>
        <result column="head_pic" property="headPic"/>
        <result column="bg_pic" property="bgPic"/>
@@ -22,18 +21,17 @@
    </resultMap>
    <insert id="saveConfig">
        insert into db_app_sys.tb_application_config(id,app_id,name,w,h,x,y,type,user_id) values
        insert into db_app_sys.tb_application_config(id,app_id,name,w,h,x,y,type) values
        <foreach collection="configDTO.children" item="module" separator=",">
            (#{module.id},#{configDTO.appId},#{module.name},#{module.w},#{module.h},#{module.x},#{module.y},#{module.type},#{configDTO.userId})
            (#{module.id},#{configDTO.appId},#{module.name},#{module.w},#{module.h},#{module.x},#{module.y},#{module.type})
        </foreach>
    </insert>
    <select id="getAllConfig" resultMap="Map_ApplicationConfigDTO">
        SELECT
            app.id AS appId,
            app.NAME AS appName,
            config.user_id,
            pic.head_pic,
            pic.bg_pic,
            app.head_pic,
            app.bg_pic,
            config.id,
            config.NAME,
            config.w,
@@ -43,11 +41,9 @@
            config.type
        FROM
            db_app_sys.tb_application app,
            db_app_sys.tb_application_config config,
            db_app_sys.tb_application_config_pic pic
            db_app_sys.tb_application_config config
        WHERE
            config.app_id = app.id
            AND config.app_id = #{param1}
            AND config.user_id = #{param2}
    </select>
</mapper>
src/main/resources/mapper/ApplicationConfigPicMapper.xml
File was deleted
src/main/resources/mapper/BattDevDataMapper.xml
File was deleted