国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離

這篇具有很好參考價值的文章主要介紹了操作員管理 微人事 項目 SpringBooot + Vue 前后端分離。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

操作員管理接口設(shè)計

HrController

@RestController
@RequestMapping("/system/hr")
public class HrController {

    @Autowired
    HrService hrService;

    @GetMapping("/")
    public List<Hr> getAllHr(){

        return hrService.getAllHr();
    }

}

HrService

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

 public List<Hr> getAllHr() {
        Hr principal = (Hr) SecurityContextHolder.getContext().getAuthentication().getPrincipal();//獲取存儲在Security當(dāng)前用戶信息
        return hrMapper.getAllHr(principal.getId());
    }

HrMapper

    List<Hr> getAllHr(Integer id);

  <resultMap id="BaseResultMap2" type="com.xyg.pojo.Hr" extends="BaseResultMap">
    <collection property="roles" ofType="com.xyg.pojo.Role" >
      <result column="id" property="id"></result>
      <result column="name" property="name"></result>
      <result column="namezh" property="namezh"></result>
    </collection>
  </resultMap>

  <select id="getAllHr" resultMap="BaseResultMap2">
    select * from hr  LEFT JOIN hr_role as hrr  on hr.id=hrr.hrid LEFT JOIN role on role.id = hrr.rid where hr.id!=#{id}
  </select>

mysql邏輯: 查詢Hr 和 角色之間的信息 每個Hr有哪些角色,除了當(dāng)前用戶不查

操作員管理頁面展示

SysHr.vue

<template>
    <div>
        <div style="display: flex ; justify-content: center;margin-top: 20px">
            <el-input type="text" placeholder="請輸入用戶名" style="width: 500px"></el-input>
            <el-button type="primary" icon="el-icon-search">搜索</el-button>
        </div>
        <div style="display: flex; flex-wrap: wrap; justify-content: space-around ;">
            <el-card style="width: 400px; margin-top: 20px"  v-for="(hr,index) in Hrs" :key="index">
                <div slot="header" class="clearfix" >
                    <span>{{hr.name}}</span>
                    <el-button style="float: right; padding: 3px 0;color: red" type="text" icon="el-icon-delete"></el-button>
                </div>
                <div>
                   <img  style="width: 120px;height: 120px; border-radius: 60px; margin-left: 120px" :src="hr.userface" :alt="hr.name" :title="hr.name"/>
                </div>
                <div style="font-family: 幼圓;color:orange;margin-top: 5px;line-height: 30px ">
                    <div>用戶名: {{hr.name}}</div>
                    <div>手機號碼: {{hr.phone}}</div>
                    <div>地址: {{hr.telephone}}</div>
                    <div>用戶狀態(tài): <el-switch
                            v-model="hr.enabled"
                            active-text="啟用"
                            inactive-text="禁用">
                    </el-switch>
                    </div>
                    <div>用戶角色:
                        <el-tag type="success" style="margin-left: 8px" v-for="(role,index) in hr.roles" :key="index">{{role.namezh}}
                        </el-tag>
                        <el-button size="small" style="" icon="el-icon-more"></el-button>
                    </div>
                    <div>備注:{{hr.remark}}</div>


                </div>
            </el-card>
        </div>
    </div>
</template>

<script>
    export default {
        name: "SysHr",
        data(){
            return{
                Hrs:[]
            }
        },

        mounted(){
            this.initHr()
        },
        methods:{
            initHr(){
                this.getRequest("/system/hr/").then(resp=>{
                    if (resp){
                        this.Hrs=resp
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>

展示效果
操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

問題Bug解決

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot
還有一個BUG

因:org.apache.ibatis.reflection.ReflectionException:非法重載getter方法,在類class
com.chb.vhr.bean.Hr中啟用屬性類型不明確。這違反了JavaBeans規(guī)范,并可能導(dǎo)致不可預(yù)測的結(jié)果

解決方式
SpringSecurity 實現(xiàn)UserDetails 重寫isEnabled 不能有重復(fù)的可能重復(fù)生成,或者加了個@Data也重復(fù)生成了去掉它就好了

用戶狀態(tài)更新

HrController

    @PutMapping("/")
    public RespBean updateHr(@RequestBody Hr hr){
        if(hrService.updateHr(hr)==1){
            return RespBean.ok("更新成功");
        }
        return RespBean.err("更新失敗");
    }

HrService

    public int updateHr(Hr hr) {
        return hrMapper.updateByPrimaryKey(hr);
    }

HrMapper

    int updateByPrimaryKey(Hr record);
  <update id="updateByPrimaryKey" parameterType="com.xyg.pojo.Hr" >
    update hr
    set name = #{name,jdbcType=VARCHAR},
      phone = #{phone,jdbcType=CHAR},
      telephone = #{telephone,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      enabled = #{enabled,jdbcType=BIT},
      username = #{username,jdbcType=VARCHAR},
      password = #{password,jdbcType=VARCHAR},
      userface = #{userface,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

前端對接

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

eanbledChange(hr){
                console.log(hr)
                this.putRequest("/system/hr/",hr).then(resp=>{
                    if(resp){
                        this.initHr()
                    }
                })
           },

操作員角色更新

具體思路是前端傳遞用戶id和需要更新多個角色id,后端接收用戶id和數(shù)組角色id
先刪除原來的角色和用戶關(guān)聯(lián),在重新新增角色和用戶關(guān)聯(lián)

HrController

    @PostMapping("/")
    public RespBean updateHrRole(Integer hrid,Integer[] rid){
        System.out.println(rid);
        if(hrService.updateHrRole(hrid,rid)==rid.length){
            return RespBean.ok("更新成功");
        }
        return RespBean.err("更新失敗");
    }

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

HrService

    @Transactional
    public Integer updateHrRole(Integer hrid, Integer[] rid) {
        hrRoleMapper.deleteByHrId(hrid);

        return  hrRoleMapper.updateHrRole(hrid,rid);
    }

HrRoleMapper

    void deleteByHrId(Integer hrid);

    Integer updateHrRole(@Param("hrid") Integer hrid,@Param("rids") Integer[] rids);
 <delete id="deleteByHrId">
    delete
    from hr_role
    where  hrid=#{hrid};
  </delete>


  <insert id="updateHrRole">
    insert into hr_role  (hrid, rid) values
    <foreach collection="rids" item="rid" separator=",">
      (#{hrid},#{rid})
    </foreach>
  </insert>

前端布局對接后端

加一個彈出框
操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot
操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

 </el-tag>
                            <el-popover
                                    @hide="hidePop(hr)"
                                    @show="showPop(hr)"
                                    placement="bottom"
                                    title="角色列表"
                                    width="100"
                                    trigger="click">
                                <el-button slot="reference" size="mini" style="color: red" icon="el-icon-more">
                                </el-button>
                                <div>
                                    <el-select  v-model="selectrole"  multiple  placeholder="">
                                        <el-option
                                                v-for="(r,indexk) in allRoles"
                                                :key="indexk"
                                                :label="r.namezh"
                                                :value="r.id">
                                        </el-option>
                                    </el-select>
                                </div>
                            </el-popover>

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

          hidePop(hr){
                let url ='/system/hr/?hrid='+hr.id

                this.selectrole.forEach(r=>{   //selectrole[]數(shù)組存儲了角色id
                    url+= '&rid='+r
                })

                this.postRequest(url).then(resp=>{
                    if(resp){
                        this.initHr()
                    }
                })

            },
            showPop(role){
                console.log(role)

                let roles=role.roles;
                this.selectrole=[]
                roles.forEach(r=>{
                    this.selectrole.push(r.id)
                })

彈出的時候進行修改角色,關(guān)閉框的時候就更新成功

問題解決

發(fā)現(xiàn)并沒有選擇修改角色,隱藏彈出框會進行網(wǎng)絡(luò)請求。
具體思路
對比兩個數(shù)組是否一樣長
進行遍歷對比兩個數(shù)組的數(shù)據(jù)角色id是否一樣

兩個條件符合那就是用戶并沒有修改數(shù)據(jù)

  hidePop(hr){
                let roles = []
                Object.assign(roles,hr.roles);//拷貝hr.roles數(shù)據(jù)到roles
                let fla = false;
                if(roles.length != this.selectrole.length){//如果數(shù)組長度不相等說明修改了角色
                    fla=true;
                }else {
                    for(let i=0;i<roles.length;i++){//
                        let role=roles[i]
                        for (let j=0;j<this.selectrole.length;j++){
                            let sr=this.selectrole[j]//和selectrole每個數(shù)據(jù)進行比較
                            if(role.id == sr){//如果有相等的
                                roles.splice(i,1);//數(shù)組中剔除掉
                                i--;//并且數(shù)組roles減少長度
                                break//退出當(dāng)前循環(huán),進入外層循環(huán),進行遍歷判斷
                            }
                        }

                    }
                    if(roles.length != 0){//遍歷完后就判斷,roles數(shù)組為0說明數(shù)組數(shù)據(jù)都相等的就不放行,程序結(jié)束
                        fla=true
                    }
                }

                if(fla){
                    let url ='/system/hr/?hrid='+hr.id

                    this.selectrole.forEach(r=>{   //selectrole[]數(shù)組存儲了角色id
                        url+= '&rid='+r
                    })

                    this.postRequest(url).then(resp=>{
                        if(resp){
                            this.initHr()
                        }
                    })
                }
            },

操作員搜索

HrController

在查詢用戶中加個用戶名參數(shù)

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

HrService

    public List<Hr> getAllHr(String keyW) {
        Hr principal = (Hr) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return hrMapper.getAllHr(principal.getId(),keyW);
    }

HrMapper

    List<Hr> getAllHr(@Param("id") Integer id, @Param("keywords") String keywords);

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

前端接口對接

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot
操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot
操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot
操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot

操作員刪除

HrController

    @DeleteMapping("/{hid}")
    public RespBean deleteHr(@PathVariable Integer hid){
        if(hrService.deleteHr(hid)==1){
         return RespBean.ok("刪除成功");
        }
        return RespBean.err("用戶狀態(tài)開啟,請先禁用");
    }

HrService

    public int deleteHr(Integer hid) {
        Hr hr = hrMapper.selectByPrimaryKey(hid);
        if(!hr.isEnabled()){
            return hrMapper.deleteByPrimaryKey(hid);
        }
        return 0;
    }

HrMapper

    Hr selectByPrimaryKey(Integer id);

  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from hr
    where id = #{id,jdbcType=INTEGER}
  </select>

刪除接口對接前端

操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot
操作員管理 微人事 項目 SpringBooot + Vue 前后端分離,vue.js,前端,spring boot文章來源地址http://www.zghlxwxcb.cn/news/detail-668819.html

 deleteHr(hr){
                this.deleteRequest("/system/hr/"+hr.id).then(resp=>{
                    if(resp){
                        this.initHr()
                    }
                })

            },

到了這里,關(guān)于操作員管理 微人事 項目 SpringBooot + Vue 前后端分離的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 基于springboot實現(xiàn)教師人事檔案管理系統(tǒng)項目【項目源碼+論文說明】

    基于springboot實現(xiàn)教師人事檔案管理系統(tǒng)項目【項目源碼+論文說明】

    基于springboot實現(xiàn)在線商城系統(tǒng)演示 現(xiàn)代經(jīng)濟快節(jié)奏發(fā)展以及不斷完善升級的信息化技術(shù),讓傳統(tǒng)數(shù)據(jù)信息的管理升級為軟件存儲,歸納,集中處理數(shù)據(jù)信息的管理方式。本ONLY在線商城系統(tǒng)就是在這樣的大環(huán)境下誕生,其可以幫助管理者在短時間內(nèi)處理完畢龐大的數(shù)據(jù)信息,

    2024年04月11日
    瀏覽(21)
  • python+java+nodejs基于vue的企業(yè)人事工資管理系統(tǒng)

    python+java+nodejs基于vue的企業(yè)人事工資管理系統(tǒng)

    根據(jù)系統(tǒng)功能需求分析,對系統(tǒng)功能的進行設(shè)計和分解。功能分解的過程就是一個由抽象到具體的過程。 作為人事數(shù)據(jù)庫系統(tǒng),其主要實現(xiàn)的功能應(yīng)包括以下幾個模塊: 1.登錄模塊 登錄模塊是由管理員、員工2種不同身份進行登錄。 2.系統(tǒng)管理模塊 用戶管理:新用戶的添加和

    2024年02月03日
    瀏覽(20)
  • node.js+vue企業(yè)人事管理系統(tǒng)q731f

    node.js+vue企業(yè)人事管理系統(tǒng)q731f

    中小企業(yè)人事管理系統(tǒng)的主要開發(fā)目標(biāo)如下: (1)實現(xiàn)管理系統(tǒng)信息關(guān)系的系統(tǒng)化、規(guī)范化和自動化; (2)減少維護人員的工作量以及實現(xiàn)員工對信息的控制和管理。 (3)方便查詢信息及管理信息等; (4)通過網(wǎng)絡(luò)操作,改善處理問題的效率,提高操作人員利用率; (

    2024年02月10日
    瀏覽(25)
  • PHP+mysql+Vue高校人事教師管理系統(tǒng)15i6f

    PHP+mysql+Vue高校人事教師管理系統(tǒng)15i6f

    利用php、vscode和mysql數(shù)據(jù)庫等知識點,結(jié)合相關(guān)設(shè)計模式、以及軟件工程的相關(guān)知識,設(shè)計一個高校人事管理系統(tǒng),來進行記錄用戶的信息,以及系統(tǒng)信息的增刪改查的功能,根據(jù)實現(xiàn)需求,系統(tǒng)需完成這些基本功能: (1)系統(tǒng)合理顯示職稱申報界面、招聘界面等界面。 (

    2024年01月21日
    瀏覽(29)
  • 課程《JavaWeb基礎(chǔ)框架程序設(shè)計》考試題下篇——數(shù)據(jù)庫與表單操作用題(人事管理平臺的添加員工檔案信息的操作題)

    課程《JavaWeb基礎(chǔ)框架程序設(shè)計》考試題下篇——數(shù)據(jù)庫與表單操作用題(人事管理平臺的添加員工檔案信息的操作題)

    這篇文章是大學(xué)課程《JavaWeb基礎(chǔ)框架程序設(shè)計》考試題目的內(nèi)容,包括了原題和答案。題目只包括了三道編程題,分值為30分、30分和40分,這篇文章繼上一篇(課程《JavaWeb基礎(chǔ)框架程序設(shè)計》考試題上篇——基礎(chǔ)應(yīng)用題(計算應(yīng)用、水仙花數(shù))),介紹40分的那題,以及代碼

    2024年02月04日
    瀏覽(31)
  • 基于springboot人事管理系統(tǒng)

    基于springboot人事管理系統(tǒng)

    末尾獲取源碼 開發(fā)語言:Java Java開發(fā)工具:JDK1.8 后端框架:SpringBoot 前端:Vue 數(shù)據(jù)庫:MySQL5.7和Navicat管理工具結(jié)合 開發(fā)軟件:IDEA / Eclipse 是否Maven項目:是 基于springboot人事管理系統(tǒng)有管理員與員工兩大角色: 管理員:首頁、個人中心、員工管理、部門管理、員工考勤管理

    2024年02月05日
    瀏覽(22)
  • SpringBoot 微人事 職稱管理模塊(十三)

    SpringBoot 微人事 職稱管理模塊(十三)

    在職稱管理頁面添加輸入框 效果圖 添加一個下拉框 v-model的值為當(dāng)前被選中的el-option的 value 屬性值 效果圖 添加按鈕 效果圖 增加數(shù)據(jù)表格 添加一個刪除,修改按鈕 創(chuàng)建一個JobLevelConroller類 JobLevelConroller JobLevelService JoblevelMapper.xml 添加個查詢所有Joblevel,其它接口用自動生成

    2024年02月12日
    瀏覽(17)
  • 微人事項目在線聊天(一)

    微人事項目在線聊天(一)

    添加一個消息按鈕 Home.vue 添加點擊事件方法 創(chuàng)建聊天頁面組件 添加路由

    2024年02月12日
    瀏覽(18)
  • SpringBoot + Vue 微人事(十)

    SpringBoot + Vue 微人事(十)

    先把table中的數(shù)據(jù)展示出來,table里面的數(shù)據(jù)實際上是positions里面的數(shù)據(jù),就是要給positions:[] 賦上值 可以在methods中定義一個initPosition方法 定義好之后去看職位管理的頁面看有沒有渲染出數(shù)據(jù)。 為什么沒數(shù)據(jù)呢?我們可以看到我們定義的initPositions并沒有調(diào)用,我們以前是登錄

    2024年02月12日
    瀏覽(14)
  • SpringBoot + Vue 微人事(十二)

    SpringBoot + Vue 微人事(十二)

    編寫后端接口 PositionController PositionsService PositionMapper PositionMapper.xml 添加批量刪除按鈕 沒有選中肯定默認是禁用批量刪除按鈕的,添加一個 賦值就是當(dāng)前選擇的項 定義一個變量,空數(shù)組變量 添加一個點擊事件,這個是一個點擊多選框會觸發(fā)的點擊事件 賦值給這個空數(shù)組變量

    2024年02月12日
    瀏覽(13)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包