| | |
| | | @Autowired |
| | | DictService dictService; |
| | | |
| | | @GetMapping({"/selectCount"}) |
| | | public Integer selectCount(String tab) { |
| | | return dictService.selectCount(tab); |
| | | } |
| | | |
| | | @GetMapping(value = "/selectByPage") |
| | | public List<DictEntity> selectByPage(String tab, Integer pageSize, Integer pageIndex) { |
| | | if (pageSize < 1 || pageIndex < 0) { |
| | | return null; |
| | | } |
| | | |
| | | return dictService.selectByPage(tab, pageSize, pageSize * pageIndex); |
| | | } |
| | | |
| | | @RequestMapping(value = "/insertDict", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") |
| | | public Integer insertDict(DictEntity dictEntity) { |
| | | |
| | |
| | | @Repository |
| | | public interface DictMapper { |
| | | /** |
| | | * 根据表名查询记录数 |
| | | * |
| | | * @param tab 表名 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String tab); |
| | | |
| | | /** |
| | | * 根据表名分页查询 |
| | | * |
| | | * @param tab 表名 |
| | | * @param limit 记录表 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<DictEntity> selectByPage(String tab, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 添加数据 |
| | | * |
| | | * @param dictEntity |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 批量添加 |
| | | * |
| | | * @param dictEntity |
| | | * @return |
| | | */ |
| | | public Integer insertDicts(List<DictEntity> dictEntity); |
| | | |
| | | /** |
| | | * 刪除数据 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * |
| | | * @param dictEntity |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询单条数据 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询全部数据 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<DictEntity> selectDictAll(); |
| | | |
| | | /** |
| | | * 查询表格中文名 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<DictEntity> selectDictTab(); |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | @Service |
| | | public class DictService implements DictMapper { |
| | | |
| | | @Autowired |
| | | DictMapper dictMapper; |
| | | |
| | | @Override |
| | | public Integer selectCount(String tab) { |
| | | return dictMapper.selectCount(tab); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictEntity> selectByPage(String tab, Integer limit, Integer offset) { |
| | | return dictMapper.selectByPage(tab, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | | public Integer insertDict(DictEntity dictEntity) { |
| | |
| | | public List<DictEntity> selectDictTab() { |
| | | return dictMapper.selectDictTab(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | <result property="updateTime" column="update_time"></result> |
| | | </resultMap> |
| | | |
| | | <!-- 统计行数 --> |
| | | <select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.String"> |
| | | select count(*) from lf.sys_dict |
| | | <where> |
| | | <if test="tab != null"> |
| | | tab = #{tab} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <!-- 分页查询 --> |
| | | <select id="selectByPage" resultMap="resultMap" resultType="com.lf.server.entity.data.DictEntity"> |
| | | select * from lf.sys_dict |
| | | <where> |
| | | <if test="tab != null"> |
| | | tab = #{tab} |
| | | </if> |
| | | </where> |
| | | order by ns,tab,order_num |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectDictTab" resultMap="resultMap" resultType="com.lf.server.entity.data.DictEntity"> |
| | | select Distinct tab,tab_desc from lf.sys_dict; |
| | | </select> |
| | |
| | | update lf.sys_dict set ns=#{ns},tab=#{tab},tab_desc=#{tabDesc},field=#{field},alias=#{alias},type=#{type}, |
| | | len=#{len},precision=#{precision}, order_num=#{orderNum},update_user=#{updateUser},update_time=now(),bak=#{bak} where id=#{id} |
| | | </update> |
| | | |
| | | </mapper> |