SpringBoot+boostrap新增修改查询删除

奏乐,代码上场。。。。

SpringBoot+boostrap新增修改查询删除_第1张图片

html

Mapper



    
		insert into gis_user(user_type, sex, name, login_pwd, tellphone, employee_no, job_desc, is_deleted, create_time, modify_time)
		values
		(#{suser_type},#{ssex},#{sname},#{slogin_pwd},#{stellphone},#{semployee_no},#{sjob_desc},#{sis_deleted},#{screate_time},#{smodify_time})
	
    
    
    
        update chuzhou.gis_user
        
            
                user_type = #{suser_type},
            
            
                sex = #{ssex},
            

            
                name = #{sname},
            
            
                login_pwd = #{slogin_pwd},
            
            
                tellphone = #{stellphone},
            
            
                employee_no = #{semployee_no},
            
            
                job_desc = #{sjob_desc},
            
            
                is_deleted = #{sis_deleted},
            
            
                create_time = #{screate_time},
            
            
                modify_time = #{smodify_time},
            
        
        where id = #{sid}
    

    
    
        delete from chuzhou.gis_user where id = #{sid}
    

查询

Controller

 

/**
 * 查询全部
 */
@GetMapping("/getUserList")
public Map getUserList(@RequestParam(name="val") Object val ,
                                       @RequestParam(name="offset") Integer offset ,
                                       @RequestParam(name="limit")Integer limit) {

    sysInfoService.selectAll(offset, limit,val);
    Map resultMap = new HashMap();
    List userList = sysInfoService.selectAll(offset, limit,val);
    Integer total = sysInfoService.findAllCount();
    resultMap.put("data", userList);
    resultMap.put("total", total);
    System.out.println(userList);
    return resultMap;
}

entity

@Data
@NoArgsConstructor
@AllArgsConstructor

public class SysInfo implements Serializable {
    private static final long serialVersionUID = -46710148407440349L;

    /**
     * id
     */
    private Integer sid;
    /**
     * 用户类型
     */
    private Integer suser_type;
    /**
     * 组织机构ID
     */
    private Integer sah_org_code_id;
    /**
     * 性别
     */
    private Integer ssex;
    /**
     * 姓名
     */
    private String sname;
    /**
     * 登录密码
     */
    private String slogin_pwd;
    /**
     * 固定电话
     */
    private String stellphone;
    /**
     * 工号
     */
    private String semployee_no;
    /**
     * 职业描述
     */

    private String sjob_desc;
    /**
     * 是否删除
     */
    private Integer sis_deleted;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date screate_time;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date smodify_time;


    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getSid() {
        return sid;
    }

    public void setSid(Integer sid) {
        this.sid = sid;
    }

    public Integer getSuser_type() {
        return suser_type;
    }

    public void setSuser_type(Integer suser_type) {
        this.suser_type = suser_type;
    }

    public Integer getSah_org_code_id() {
        return sah_org_code_id;
    }

    public void setSah_org_code_id(Integer sah_org_code_id) {
        this.sah_org_code_id = sah_org_code_id;
    }

    public Integer getSsex() {
        return ssex;
    }

    public void setSsex(Integer ssex) {
        this.ssex = ssex;
    }

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    public String getSlogin_pwd() {
        return slogin_pwd;
    }

    public void setSlogin_pwd(String slogin_pwd) {
        this.slogin_pwd = slogin_pwd;
    }

    public String getStellphone() {
        return stellphone;
    }

    public void setStellphone(String stellphone) {
        this.stellphone = stellphone;
    }

    public String getSemployee_no() {
        return semployee_no;
    }

    public void setSemployee_no(String semployee_no) {
        this.semployee_no = semployee_no;
    }

    public String getSjob_desc() {
        return sjob_desc;
    }

    public void setSjob_desc(String sjob_desc) {
        this.sjob_desc = sjob_desc;
    }

    public Integer getSis_deleted() {
        return sis_deleted;
    }

    public void setSis_deleted(Integer sis_deleted) {
        this.sis_deleted = sis_deleted;
    }

    public Date getScreate_time() {
        return screate_time;
    }

    public void setScreate_time(Date screate_time) {
        this.screate_time = screate_time;
    }

    public Date getSmodify_time() {
        return smodify_time;
    }

    public void setSmodify_time(Date smodify_time) {
        this.smodify_time = smodify_time;
    }

}

dao

List selectAll(@Param("offset") Integer offset , @Param("limit") Integer limit,@Param("val") Object val);

serivce

List selectAll(Integer offset , Integer limit ,Object val);

serivceimpl

@Override
public List selectAll(Integer offset , Integer limit ,Object val)
{
    return this.sysInfoDao.selectAll( offset ,  limit , val);
}

新增

dao

/**
 * 新增数据
 *
 * @param sysInfo 实例对象
 * @return 影响行数
 */
int addUser(SysInfo sysInfo);

service

/**
 * 添加用户
 * @param sysInfo
 */

SysInfo addUser(SysInfo sysInfo);

serviceimpl

/**
 * 添加用户
 * @param sysInfo
 */

SysInfo addUser(SysInfo sysInfo);

controller

@RequestMapping("/add")
@ResponseBody
public JsonReturn addUser(HttpServletRequest request) {

    Integer suser_type=Integer.parseInt(request.getParameter("suser_type"));
    Integer ssex=Integer.parseInt(request.getParameter("ssex")) ;
    String sname=request.getParameter("sname");
    String slogin_pwd=request.getParameter("slogin_pwd");
    String stellphone=request.getParameter("stellphone");
    String semployee_no=request.getParameter("semployee_no");
    String sjob_desc=request.getParameter("sjob_desc");
    Integer sis_deleted=Integer.parseInt(request.getParameter("sis_deleted"));
    String screate_time=request.getParameter("screate_time");
    String smodify_time=request.getParameter("smodify_time");

    SysInfo sysInfo= new SysInfo();
    sysInfo.setSuser_type(suser_type);
    sysInfo.setSsex(ssex);
    sysInfo.setSname(sname);
    sysInfo.setSlogin_pwd(slogin_pwd);
    sysInfo.setStellphone(stellphone);
    sysInfo.setSemployee_no(semployee_no);
    sysInfo.setSjob_desc(sjob_desc);
    sysInfo.setSis_deleted(sis_deleted);

    sysInfo.setScreate_time(java.sql.Date.valueOf(screate_time));
    sysInfo.setSmodify_time(java.sql.Date.valueOf(smodify_time));


    sysInfoService.addUser(sysInfo);
    JsonReturn jsonReturn = new JsonReturn();
    jsonReturn.setState(true);
    jsonReturn.setMsg("新增成功");
    return jsonReturn;

    /*//return this.sysInfoService.addUser(sysInfo);*/
}

修改

dao

/**
 * 修改数据
 *
 * @param sysInfo 实例对象
 * @return 影响行数
 */
int update(SysInfo sysInfo);

service

/**
 * 修改用户
 *
 * @param sysInfo 实例对象
 * @return 实例对象
 */
SysInfo update(SysInfo sysInfo);

serviceimpl

/**
 * 修改数据
 *
 * @param sysInfo 实例对象
 * @return 实例对象
 */
@Override
public SysInfo update(SysInfo sysInfo) {
    this.sysInfoDao.update(sysInfo);
    return this.queryById(sysInfo.getSid());
}

controller

@RequestMapping("/seupdateUser")
@ResponseBody
public JsonReturn updateUser(SysInfo sysInfo) {
    sysInfoService.update(sysInfo);
    JsonReturn jsonReturn = new JsonReturn();
    jsonReturn.setState(true);
    jsonReturn.setMsg("修改成功");
    return jsonReturn;
}

删除

dao

/**
 * 通过主键删除数据
 *
 * @param sid 主键
 * @return 影响行数
 */
Integer deleteById(Integer sid);

service

/**
 * 通过主键删除数据
 *
 * @param sid 主键
 * @return 是否成功
 */
SysInfo deleteById(Integer sid);

serviceimpl

/**
 * 通过主键删除数据
 *
 * @param sid 主键
 * @return 是否成功
 */
@Override
public SysInfo deleteById(Integer sid) {
    this.sysInfoDao.deleteById(sid);
    return this.queryById(sid);
}

controller

/*删除*/
@RequestMapping("/delect")
@ResponseBody
public JsonReturn delect(Integer sid){
    System.out.println(sid);
   /* sysInfoService.deleteById(sid);*/
    JsonReturn jsonReturn = new JsonReturn();
    jsonReturn.setState(true);
    jsonReturn.setMsg("删除成功");
    /*return this.sysInfoService.deleteById(sid);*/
    return jsonReturn;
}

 

你可能感兴趣的:(java,spring,boot,boostrap)