• (免费分享)基于springboot医药进销存系统


    源码获取:关注文末gongzhonghao,输入014领取下载链接

    开发工具:IDEA,数据库mysql

    技术:springboot+mybatis

    系统主要分两个角色,客户和员工
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    package cn.tedu.drug.controller;
    
    import java.io.File;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.PostMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.RestController;
    import org.springframework.web.multipart.MultipartFile;
    
    import com.fasterxml.jackson.core.JsonProcessingException;
    
    import cn.tedu.drug.controller.exception.FileContentTypeException;
    import cn.tedu.drug.controller.exception.FileEmptyException;
    import cn.tedu.drug.controller.exception.FileIOException;
    import cn.tedu.drug.controller.exception.FileIllegalStateException;
    import cn.tedu.drug.controller.exception.FileSizeException;
    import cn.tedu.drug.entity.Customer;
    import cn.tedu.drug.entity.CustomerTime;
    import cn.tedu.drug.entity.domain.PaginationVO;
    import cn.tedu.drug.service.ICustomerService;
    import cn.tedu.drug.util.ResponseResult;
    
    @RestController		//相当于配置文件(Controller,ResponseBody)
    @RequestMapping("/customer")
    public class CustomerController extends BaseController {
    	@Autowired	//自动装配
    	private ICustomerService customerService;
    	
    	/**
    	 * 注册用户
    	 * @param user
    	 * @return	返回成功
    	 */
    	@RequestMapping("/reg")
    	public ResponseResult<Void> reg(Customer customer) {
    		customerService.reg(customer);
    		return new ResponseResult<Void>(SUCCESS);
    	}
    	
    	/**
    	 * 登录
    	 * @param username
    	 * @param password
    	 * @return
    	 */
    	@PostMapping("/login")
    	public ResponseResult<Customer> login(String phone,String password,HttpSession session) {
    		Customer customer = customerService.getloginCustomer(phone, password);
    		session.setAttribute( "user", customer );
    		session.setAttribute( "uid", customer.getUid());
    		session.setAttribute( "username", customer.getUsername() );
    		return new ResponseResult<Customer>(SUCCESS,customer);
    	}
    	
    	/**
    	 * 查询客户数据,多条件查询
    	 * @param drugCategory
    	 * @return
    	 * @throws JsonProcessingException 
    	 */
    	@RequestMapping("/selectCustomer")
    	public ResponseResult<PaginationVO<Customer>> selectCustomer
    	(String username,String gender,String address,String pageNoStr,String pageSizeStr) throws JsonProcessingException {
    		//获取参数
    		long pageNo = 1;	//如果没有传数据,默认为第一页
    		if( pageNoStr != null && pageNoStr.trim().length()>0 ){
    			pageNo = Long.parseLong(pageNoStr);
    		}
    		int pageSize = 1;	//如果没有传数据,默认为10条数据
    		if( pageSizeStr != null && pageSizeStr.trim().length()>0 ){
    			pageSize = Integer.parseInt(pageSizeStr);
    		}
    		long beginNo = (pageNo-1)*pageSize;
    		Map<String ,Object> map = new HashMap<String ,Object>();
    		map.put("beginNo", beginNo);
    		map.put("pageSize", pageSize);
    		map.put("username", username);
    		map.put("gender", gender);
    		map.put("address", address);
    		PaginationVO<Customer> vo = customerService.getSelectCustomer(map);
    		return new ResponseResult<PaginationVO<Customer>>(SUCCESS,vo);
    	}
    	
    	/**
    	 * 删除客户数据
    	 * @param uid
    	 * @param session
    	 * @return
    	 */
    	@RequestMapping("/deleteCustomer")
    	public ResponseResult<Void> deleteCustomer(Integer uid,HttpSession session){
    		String username = (String) session.getAttribute("username");
    		customerService.getdeleteId(uid, username);
    		return new ResponseResult<Void>(SUCCESS);
    	}
    	
    	/**
    	 * 修改客户数据
    	 */
    	@RequestMapping("/updateCustomer")
    	public ResponseResult<Void> updateCustomer(Customer customer,HttpSession session){
    		String username = (String) session.getAttribute("username");
    		customerService.getupdateCustomer(customer, username);
    		return new ResponseResult<Void>(SUCCESS);
    	}
    	
    	/**
    	 * 展示个人信息
    	 */
    	@RequestMapping("/getfindByUid")
    	public ResponseResult<Customer> getfindByUid(Integer uid){
    		Customer customer = customerService.getfindByUid(uid);
    		return new ResponseResult<Customer>(SUCCESS,customer);
    	}
    	
    	/**
    	 * 修改密码
    	 */
    	@RequestMapping("/getfindByUidPassword")
    	public ResponseResult<Void> getfindByUidPassword(Integer uid,HttpSession session,String oldPassword,String newPassword){
    		String username = (String) session.getAttribute("username");
    		customerService.getfindByUidPassword(uid, username, oldPassword, newPassword);
    		return new ResponseResult<Void>(SUCCESS);
    	}
    	
    	/**
    	 * 上传头像
    	 * @param request
    	 * @param file
    	 * @return MultipartFile file
    	 */
    	@RequestMapping("/change_avatar")
    	public ResponseResult<String> changeAvatar(HttpServletRequest request,@RequestParam("file") MultipartFile file){
    		if(file.isEmpty()) {
    			throw new FileEmptyException("上传头像错误!上传文件不能为空!");
    		}
    		if(!UPLOAD_CONTENT_TYPE.contains(file.getContentType())) {
    			throw new FileContentTypeException("上传头像错误!不支持所选的文件类型!");
    		}
    		if(file.getSize()>UPLOAD_MAX_SIZE) {
    			throw new FileSizeException("上传文件过大!请选择小于"+UPLOAD_MAX_SIZE+"的文件!");
    		}
    		String parentPath = request.getServletContext().getRealPath(UPLOAD_DIR);
    		File parent = new File(parentPath);
    		if(!parent.exists()) {
    			parent.mkdirs();
    		}
    		String originalFilename = file.getOriginalFilename();
    		//使用系统纳秒值给头像命名
    		//String prefic = System.nanoTime()+"";
    		//使用uid+username为头像文件命名,新头像会将旧头像替换
    		HttpSession session = request.getSession();
    		String prefic = session.getAttribute("uid").toString()+session.getAttribute("username").toString();
    		int beginIndex = originalFilename.lastIndexOf(".");
    		String suffix = "";
    		if(beginIndex > 0) {
    			suffix = originalFilename.substring(beginIndex);
    		}
    		String filename = prefic+suffix;
    		File dest = new File(parent,filename);
    		try {
    			file.transferTo(dest);
    		} catch (IllegalStateException e) {
    			e.printStackTrace();
    			throw new FileIllegalStateException("上传头像错误!存储头像文件时状态异常!");
    		} catch (IOException e) {
    			e.printStackTrace();
    			throw new FileIOException("上传头像错误!读写文件时出现错误!");
    		}
    		Integer uid = getUidFromSession(session);
    		String avatar = "/"+UPLOAD_DIR+"/"+filename;
    		
    		customerService.changeAvatar(avatar,uid);
    		return new ResponseResult<String>(SUCCESS,avatar);
    	}
    	
    	/**
    	 * 查询客户的数量
    	 */
    	@RequestMapping("/selectIdCount")
    	public ResponseResult<Long> selectIdCount(){
    		Long count = customerService.getselectIdCount();
    		return new ResponseResult<Long>(SUCCESS,count);
    	}
    	
    	/**
    	 * 图表展示,客户流量,输入年份,展示该年每一个月的客户注册量
    	 * @param createdTime
    	 * @return
    	 */
    	@RequestMapping("/selectYearTime")
    	public ResponseResult<List<CustomerTime>> selectYearTime(String createdTime){
    		String str = createdTime.substring(0, createdTime.indexOf("-"));
    		Map<String,Object> map = new HashMap<String,Object>();
    		map.put("createdTime", str);
    		List<CustomerTime> customerTimeList = customerService.getselectYearMonth(map);
    		return new ResponseResult<List<CustomerTime>>(SUCCESS,customerTimeList);
    	}
    	
    	
    	
    	
    	
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214

    package cn.tedu.drug.controller;

    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;

    import javax.servlet.http.HttpSession;

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;

    import com.fasterxml.jackson.core.JsonProcessingException;

    import cn.tedu.drug.entity.Drug;
    import cn.tedu.drug.entity.DrugANDDrugCategory;
    import cn.tedu.drug.entity.DrugCategory;
    import cn.tedu.drug.entity.domain.PaginationVO;
    import cn.tedu.drug.service.IDrugCategoryService;
    import cn.tedu.drug.service.IDrugService;
    import cn.tedu.drug.util.ResponseResult;

    @RestController
    @RequestMapping(“/drug”)
    public class DrugController extends BaseController{
    @Autowired //自动装配
    private IDrugService drugService;
    @Autowired //自动装配
    private IDrugCategoryService drugCategoryService;

    /**
     * 添加数据。药品类别信息
     * @param user
     * @return	返回成功
     */
    @RequestMapping("/addDrug")
    public ResponseResult addDrug(Drug drug,HttpSession session) {
    	String username = (String) session.getAttribute("username");
    	drugService.addDrug(drug, username);
    	return new ResponseResult(SUCCESS);
    }
    
    /**
     * 为添加药品时,药品类别选择所设计
     * @return
     */
    @RequestMapping("/selectDrugCategory")
    public ResponseResult> selectDrugCategory(){
    	List list = drugCategoryService.getfindByCategoryIdCategoryName();
    	return new ResponseResult>(SUCCESS,list);
    }
    
    /**
     * 查询药品数据(关联查询)药品类别表,后期改为多条件查询
     * @param drugCategory
     * @return
     * @throws JsonProcessingException 
     */
    @RequestMapping("/selectDrug")
    public ResponseResult> selectDrug(String drugName,String unit,String origin,Integer categoryId,String pageNoStr,String pageSizeStr) throws JsonProcessingException {
    	//获取参数
    	long pageNo = 1;	//如果没有传数据,默认为第一页
    	if( pageNoStr != null && pageNoStr.trim().length()>0 ){
    		pageNo = Long.parseLong(pageNoStr);
    	}
    	int pageSize = 1;	//如果没有传数据,默认为10条数据
    	if( pageSizeStr != null && pageSizeStr.trim().length()>0 ){
    		pageSize = Integer.parseInt(pageSizeStr);
    	}
    	long beginNo = (pageNo-1)*pageSize;
    	Map map = new HashMap();
    	map.put("drugName", drugName);
    	map.put("unit", unit);
    	map.put("origin", origin);
    	map.put("beginNo", beginNo);
    	map.put("categoryId", categoryId);
    	map.put("pageSize", pageSize);
    	PaginationVO vo = drugService.getselectDrug(map);
    	return new ResponseResult>(SUCCESS,vo);
    }
    
    /**
     * 根据uid查询药品全部数据
     * @param uid
     * @return
     */
    @RequestMapping("/findId")
    public ResponseResult getfindId(Integer id){
    	Drug data = drugService.getfindId(id);
    	return new ResponseResult(SUCCESS,data);
    };
    
    /**
     * 修改药品数据
     * @param drug
     * @param session
     * @return
     */
    @RequestMapping("/updateIdDrug")
    public ResponseResult updateIdDrug(Drug drug,HttpSession session) {
    	String username = (String) session.getAttribute("username");
    	drugService.getupdateIdDrug(drug, username);
    	return new ResponseResult(SUCCESS);
    }
    
    /**
     * 根据id删除药品数据
     * @param id
     * @param session
     * @return
     */
    @RequestMapping("/deleteIdDrug")
    public ResponseResult deleteIdDrug(String id,HttpSession session) {
    	String[] ids = id.split(",");
    	String username = (String) session.getAttribute("username");
    	drugService.getdeleteIdDrug(ids, username);
    	return new ResponseResult(SUCCESS);
    }
    
    
    /**
     * 查询药品的数量
     */
    @RequestMapping("/selectIdCount")
    public ResponseResult selectIdCount(){
    	Long count = drugService.getselectIdCount();
    	return new ResponseResult(SUCCESS,count);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98

    }

  • 相关阅读:
    三网91话费接口源码分享
    IDEA Gradle Lombok错误:找不到符号 setter getter方法没有
    CSS 创建
    Qt第六章:渲染树
    第18节 动态规划一讲
    云计算有什么作用
    linux基本指令以及热键
    F5.5G落进现实:目标网带来的光之路
    RAC/RAC One Node 修改私网/心跳网卡名
    Linux_安装docker
  • 原文地址:https://blog.csdn.net/weixin_42899150/article/details/127945613