项目-03

1、分页列表

方案1:设置查询条件通过EntityWrapper-不能返回关联对象

@PostMapping("/list")
    public PageList<TenantType> json(@RequestBody TenantTypeQuery query)
    {
        System.out.println(query.getKeyword());

        //分页携带查询条件EntityWrapper keywords要作用于name或者descrition
        EntityWrapper<TenantType> wrapper = new EntityWrapper<>();
        //wrapper.eq() 相等
        wrapper.like("name",query.getKeyword()) //模糊查询
                .or()
                .like("description",query.getKeyword());

        Page<TenantType> page = new Page<TenantType>(query.getPage(),query.getRows());
        page = tenantTypeService.selectPage(page, wrapper);
        return new PageList<TenantType>(page.getTotal(),page.getRecords());

    }

方案2:自己写sql,还能返回关联对象

controller:

@PostMapping("/list")
    public PageList<TenantType> json(@RequestBody TenantTypeQuery query)
    {
        return tenantTypeService.selectPageLiset(query);

    }

Service
在这里插入图片描述

Mapper

在这里插入图片描述

Mapper.xml

在这里插入图片描述

这两种方案高级查询方案,第一种比较简单,第二种比较复杂,如果返回值不需要关联对象,就用第一种,否则就用第二种

3.跨越配置-在zuul进行配置(所有前端统一入口)

package cn.itsource.aigou.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class GlobalCorsConfig {
    @Bean
    public CorsFilter corsFilter() {
        //1.添加CORS配置信息
        CorsConfiguration config = new CorsConfiguration();
        //1) 允许的域,不要写*,否则cookie就无法使用了
        config.addAllowedOrigin("http://127.0.0.1:6001");
config.addAllowedOrigin("http://localhost:6001");
        //2) 是否发送Cookie信息
        config.setAllowCredentials(true);
        //3) 允许的请求方式
        config.addAllowedMethod("OPTIONS");
        config.addAllowedMethod("HEAD");
        config.addAllowedMethod("GET");
        config.addAllowedMethod("PUT");
        config.addAllowedMethod("POST");
        config.addAllowedMethod("DELETE");
        config.addAllowedMethod("PATCH");
        // 4)允许的头信息
        config.addAllowedHeader("*");
        //2.添加映射路径,我们拦截一切请求
        UrlBasedCorsConfigurationSource configSource = new
                UrlBasedCorsConfigurationSource();
        configSource.registerCorsConfiguration("/**", config);
        //3.返回新的CorsFilter.
        return new CorsFilter(configSource);
    }
}

2. 机构管理(tenant)

分页+高级查询+关联查询

 后台:
        Domain
 
Mapper.xml
<sql id="whereSql">
    <where>
        <if test="keyword!=null and keyword!=''">

             and t.companyName like concat('%',#{keyword},"%")
        </if>
    </where>
</sql>
<!--List<Tenant> loadPageList(Page<Tenant> page, TenantQuery query);-->
<select id="loadPageList" resultMap="TenantMap">
    SELECT
        t.*, type.id tid,
        type. NAME tname,
      e.id eid,e.realName
    FROM
        t_tenant t
    LEFT JOIN t_tenant_type type ON t.tenant_type = type.id
    LEFT JOIN t_employee e on t.admin_id = e.id
    <include refid="whereSql"></include>
</select>

<resultMap id="TenantMap" type="Tenant">
    <id column="id" property="id" />
    <result column="tenant_type" property="tenantType" />
    <result column="companyName" property="companyName" />
    <result column="companyNum" property="companyNum" />
    <result column="registerTime" property="registerTime" />
    <result column="state" property="state" />
    <result column="address" property="address" />
    <result column="logo" property="logo" />
    <result column="admin_id" property="adminId" />

    <!-- 机构类型多对一关联-->
    <association property="type" javaType="TenantType">
        <id column="tid" property="id" />
        <result column="tname" property="name" />
    </association>

    <!--管理员的关联查询-->
    <association property="admin" javaType="Employee">
        <id column="eid" property="id" />
        <result column="realName" property="realName" />
    </association>
</resultMap>


删除

service
在这里插入图片描述

Mapper.xml

在这里插入图片描述

3. 机构入驻

. 前台传递参数

在这里插入图片描述

后台实现

package cn.itsource.hrm.service.impl;

import cn.itsource.hrm.domain.Employee;
import cn.itsource.hrm.domain.Tenant;
import cn.itsource.hrm.mapper.EmployeeMapper;
import cn.itsource.hrm.mapper.TenantMapper;
import cn.itsource.hrm.service.ITenantService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yhptest
 * @since 2019-09-02
 */
@Service
public class TenantServiceImpl extends ServiceImpl<TenantMapper, Tenant> implements ITenantService {

    @Autowired
    private TenantMapper tenantMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public boolean insert(Tenant tenant) {
        //保存公司管理员信息-没有租户id
        Employee admin = entity.getAdmin();
        admin.setInputTime(new Date()); //输入时间
        admin.setState(0); // 正常
        admin.setType(1); //是否是租户管理员
        employeeMapper.insert(admin);
        System.out.println(admin.getId()+"iiii");

        //保存公司信息-要返回自增id
        entity.setAdminId(admin.getId());
        tenantMapper.insert(entity);

        System.out.println(entity.getId()+"jjjj");
        //修改管理员的租户id
        admin.setTenantId(entity.getId());
        employeeMapper.updateById(admin);        //添加套餐中间表
        tenantMapper.saveTenantMeals(tenant.getMealsMap());
        return true;
    }

    @Override
    public boolean deleteById(Serializable id) {

        //删除机构
        tenantMapper.deleteById(id);
        //删除管理员
        Wrapper<Employee> wapper = new EntityWrapper<>();
        wapper.eq("tenant_id",id);
        employeeMapper.delete(wapper);
        //删除中间表
        tenantMapper.removeTenantMeal(id);
        return true;
    }

    @Override
    public boolean updateById(Tenant tenant) {
        // 修改机构
        tenantMapper.updateById(tenant);
        //修改管理员
        employeeMapper.updateById(tenant.getAdminUser());
        //修改中间表-先删除后添加
        tenantMapper.removeTenantMeal(tenant.getId());
        tenantMapper.saveTenantMeals(tenant.getMealsMap());
        return true;
    }
}

package cn.itsource.hrm.mapper;

import cn.itsource.hrm.domain.Tenant;
import com.baomidou.mybatisplus.mapper.BaseMapper;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author yhptest
 * @since 2019-09-02
 */
public interface TenantMapper extends BaseMapper<Tenant> {

    /**
     * 保存机构所对应的套餐的中间表信息
     * @param mealsMap
     */
    void saveTenantMeals(List<Map<String, Long>> mealsMap);

    /**
     * 删除中间表
     * @param id
     */
    void removeTenantMeal(Serializable id);
}

<!--void saveTenantMeals(List<Map<String, Long>> mealsMap);-->
<insert id="saveTenantMeals" parameterType="arrayList">
    insert into t_tenant_meal(tenant_id,meal_id) VALUES
    <foreach collection="list" separator="," item="item">
        (#{item.tenantId},#{item.mealId})
    </foreach>
</insert>

<!--void removeTenantMeal(Serializable id);-->
<delete id="removeTenantMeal" parameterType="long">
    DELETE  from t_tenant_meal where tenant_id =#{id}
</delete>



简历书写

系统中心是我做的,数据字典,操作日志,员工,部门,角色,权限,菜单,机构类型,机构,套餐

embedcpp-2021-03是一个有关嵌入式C++编程的课程,于2021年3月举办。嵌入式C++编程是指在嵌入式系统中使用C++编程语言进行开发的一种方法。 在嵌入式系统中,资源通常是有限的,例如处理器速度、内存容量和存储空间等。因此,使用C++编程语言可以提供更高的灵活性和效率,帮助开发人员充分利用有限的资源。C++在嵌入式系统中的应用范围广泛,例如物联网设备、汽车电子和工业自动化等领域。 embedcpp-2021-03课程旨在向学员介绍嵌入式C++编程的基础知识和技巧。课程内容通常包括以下方面: 1. C++语法和特性:介绍C++的基本语法、面向对象编程和泛型编程等概念,以及C++11、C++14和C++17的一些新特性。 2. 嵌入式系统概述:了解嵌入式系统的基本特点、硬件和软件组成,以及与传统桌面开发的区别。 3. 低级编程:学习如何与硬件交互,包括使用寄存器、配置外设和处理中断等。还可以介绍使用汇编语言优化性能的技巧。 4. 内存管理:探讨嵌入式系统中的内存管理技术,包括堆栈和堆的使用、动态内存分配和对象生命周期管理等。 5. 实时操作系统(RTOS):介绍嵌入式系统中常用的实时操作系统,如FreeRTOS和µC/OS等,学习如何使用RTOS进行任务调度和资源管理。 除了理论知识,embedcpp-2021-03课程通常还包括实际的项目练习,以帮助学员将所学知识应用于实际场景。通过该课程,学员可以了解嵌入式C++编程的基础概念和实践技巧,为嵌入式系统开发提供了一定的基础。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值