Browse Source

参数管理提交_20210815_2

MSY 3 years ago
parent
commit
d5fa4dfaa6

+ 79 - 0
src/main/java/com/jkcredit/invoice/controller/manager/ParamController.java

@@ -0,0 +1,79 @@
+package com.jkcredit.invoice.controller.manager;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jkcredit.invoice.annotation.LoginRequired;
+import com.jkcredit.invoice.model.entity.manager.Param;
+import com.jkcredit.invoice.service.manager.ParamService;
+import com.jkcredit.invoice.util.RespR;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @description:
+ * @author: sunzhaoning
+ * @create: 2019-05-29 09:14
+ * @version: V1.0
+ **/
+@Api(tags = "参数管理")
+@RestController
+@RequestMapping(value = {"/param"})
+public class ParamController {
+
+
+
+    @Autowired
+    private ParamService paramService;
+
+
+    /**
+     * 分页查询参数
+     *
+     * @param page    参数集
+     * @param param 查询参数列表
+     * @return 用户集合
+     */
+    @PostMapping("/page")
+    @ApiOperation(value="分页查询参数管理", notes="分页查询参数管理")
+    @LoginRequired
+    public RespR getParamPage(Page page, Param param) {
+        return new RespR<>(paramService.getParamWithRolePage(page, param));
+    }
+
+
+
+    /**
+     * 添加参数
+     *
+     * @param param 参数信息
+     * @return success/false
+     */
+    @PostMapping
+    @ApiOperation(value="新增参数详细信息", notes="新增参数详细信息")
+    @LoginRequired
+    public RespR param(@RequestBody Param param) {
+        Param param1 = paramService.getParamsByParamName(param.getParamName());
+        if(param1 != null){
+            return new RespR<>(false,"参数名称已存在,请重新维护!");
+        }
+        return new RespR<>(paramService.saveParam(param));
+    }
+
+
+
+
+    /**
+     * 更新参数信息
+     *
+     * @param param 参数信息
+     * @return R
+     */
+    @PostMapping("/updateParam")
+    @ApiOperation(value="更新参数信息", notes="更新参数信息")
+    @LoginRequired
+    public RespR updateUser(@RequestBody Param param) {
+        return new RespR<>(paramService.updateParam(param));
+    }
+
+}

+ 46 - 0
src/main/java/com/jkcredit/invoice/mapper/manager/ParamMapper.java

@@ -0,0 +1,46 @@
+package com.jkcredit.invoice.mapper.manager;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+
+
+import java.util.List;
+
+/**
+ * @description:
+ * @author: sunzhaoning
+ * @create: 2019-05-28 17:47
+ * @version: V1.0
+ **/
+public interface ParamMapper extends BaseMapper<com.jkcredit.invoice.model.entity.manager.Param> {
+
+
+    /**
+     * 分页查询参数信息
+     *
+     * @param page    分页
+     * @param param 查询参数
+     * @return list
+     */
+    IPage<List<com.jkcredit.invoice.model.entity.manager.Param>> getParamsPage(Page page, @Param("query") com.jkcredit.invoice.model.entity.manager.Param param);
+
+
+    /**
+     * 通过参数名称查询参数信息
+     *
+     * @param paramName 参数名称
+     * @return Param
+     */
+    com.jkcredit.invoice.model.entity.manager.Param getParamByParamName(String paramName);
+
+
+
+    /**
+     * 修改参数信息
+     * @param param
+     * @return
+     */
+    Boolean  updateParam(com.jkcredit.invoice.model.entity.manager.Param param);
+}

+ 49 - 0
src/main/java/com/jkcredit/invoice/model/entity/manager/Param.java

@@ -0,0 +1,49 @@
+package com.jkcredit.invoice.model.entity.manager;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+
+/**
+ * @description:
+ * @author: sunzhaoning
+ * @create: 2019-05-28 17:44
+ * @version: V1.0
+ **/
+@Data
+@ApiModel(value = "参数实体")
+public class Param implements Serializable {
+
+    private static final long serialVersionUID = -526324944915280489L;
+
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 参数名称
+     */
+    @ApiModelProperty(value = "参数名称")
+    private String paramName;
+
+    /**
+     * 参数值
+     */
+    @ApiModelProperty(value = "参数值")
+    private String paramValue;
+
+
+
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String paramNote;
+
+
+
+}

+ 59 - 0
src/main/java/com/jkcredit/invoice/service/manager/ParamService.java

@@ -0,0 +1,59 @@
+package com.jkcredit.invoice.service.manager;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jkcredit.invoice.model.entity.manager.Param;
+import com.jkcredit.invoice.util.RespR;
+
+
+/**
+ * @description:
+ * @author: sunzhaoning
+ * @create: 2019-05-28 17:49
+ * @version: V1.0
+ **/
+public interface ParamService extends IService<Param> {
+
+    /**
+     * 分页查询用户信息(含有角色信息)
+     * @param page    分页对象
+     * @param param 参数列表
+     * @return
+     */
+    IPage getParamWithRolePage(Page page, Param param);
+
+
+
+    /**
+     * 通过参数名称查询参数信息
+     *
+     * @param paramName 参数名称
+     * @return param
+     */
+    Param getParamsByParamName(String paramName);
+
+
+
+    /**
+     * 保存参数信息
+     *
+     * @param param DTO 对象
+     * @return success/fail
+     */
+    Boolean saveParam(Param param);
+
+
+
+
+    /**
+     * 修改参数信息
+     * @param param
+     * @return
+     */
+    RespR<Boolean> updateParam(Param param);
+
+
+
+
+}

+ 58 - 0
src/main/java/com/jkcredit/invoice/service/manager/impl/ParamServiceImpl.java

@@ -0,0 +1,58 @@
+package com.jkcredit.invoice.service.manager.impl;
+
+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.jkcredit.invoice.mapper.manager.ParamMapper;
+import com.jkcredit.invoice.model.entity.manager.Param;
+import com.jkcredit.invoice.service.manager.ParamService;
+import com.jkcredit.invoice.util.RespR;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+
+/**
+ * @description:
+ * @author: sunzhaoning
+ * @create: 2019-05-28 17:53
+ * @version: V1.0
+ **/
+@Slf4j
+@Service
+public class ParamServiceImpl extends ServiceImpl<ParamMapper, Param> implements ParamService {
+
+    @Override
+    public IPage getParamWithRolePage(Page page, Param param) {
+        return baseMapper.getParamsPage(page, param);
+    }
+
+    @Override
+    public Param getParamsByParamName(String paramName) {
+        return baseMapper.getParamByParamName(paramName);
+    }
+
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean saveParam(Param param) {
+        this.save(param);
+        return Boolean.TRUE;
+    }
+
+
+
+
+    @Override
+    public RespR<Boolean> updateParam(Param param){
+       /* if(user.getRoleId()!=null){
+            //根据角色ID查询角色信息
+            Role role =roleService.getById(user.getRoleId());
+            //设置角色名称
+            user.setRoleName(role.getRoleName());
+        }*/
+        return new RespR<>(baseMapper.updateParam(param));
+    }
+
+}

+ 84 - 0
src/main/resources/mapper/manager/ParamMapper.xml

@@ -0,0 +1,84 @@
+<?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.jkcredit.invoice.mapper.manager.ParamMapper">
+    <!-- 通用查询映射结果 -->
+    <resultMap id="baseResultMap" type="com.jkcredit.invoice.model.entity.manager.Param">
+        <id column="id" property="id"/>
+        <result column="param_name" property="paramName"/>
+        <result column="param_value" property="paramValue"/>
+        <result column="param_note" property="paramNote"/>
+    </resultMap>
+
+    <sql id="paramSql">
+		id,
+		param_name,
+		param_value,
+		param_note
+	</sql>
+
+
+
+    <select id="getParamsPage" resultMap="baseResultMap">
+        SELECT
+        <include refid="paramSql"/>
+        FROM
+        t_manager_param
+        <where>
+            <if test="query.paramName != null and query.paramName != ''">
+                and param_name LIKE CONCAT('%',#{query.paramName},'%')
+            </if>
+            <if test="query.paramValue != null and query.paramValue != ''">
+                and param_value = #{query.paramValue}
+            </if>
+            <if test="query.paramNote != null and query.paramNote != ''">
+                and param_note LIKE CONCAT('%',#{query.paramNote},'%')
+            </if>
+        </where>
+    </select>
+
+
+
+    <select id="getParamByParamName" resultMap="baseResultMap">
+        SELECT
+        <include refid="paramSql" />
+        FROM
+        t_manager_param
+        WHERE
+        param_name = #{paramName}
+
+    </select>
+
+
+
+
+    <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.manager.Param" >
+        insert into t_manager_param (
+            param_name,
+            param_value,
+            param_note
+        )
+        values ( #{paramName,jdbcType=VARCHAR},#{paramValue,jdbcType=VARCHAR},#{paramNote,jdbcType=VARCHAR}
+        )
+    </insert>
+
+
+
+    <update id="updateParam">
+        UPDATE
+        t_manager_param
+        <set>
+            <if test="paramName != null and paramName != ''">
+                param_name = #{paramName},
+            </if>
+            <if test="paramValue != null and paramValue != ''">
+                param_value = #{paramValue},
+            </if>
+            <if test="paramNote != null and paramNote != ''">
+                param_note = #{paramNote},
+            </if>
+        </set>
+        WHERE
+        id = #{id}
+    </update>
+
+</mapper>